diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/example.c | 156 | ||||
-rw-r--r-- | lib/example.dsp | 311 | ||||
-rw-r--r-- | lib/example.dsw | 29 | ||||
-rw-r--r-- | lib/example.h | 27 | ||||
-rw-r--r-- | lib/htssystem.h | 12 | ||||
-rw-r--r-- | lib/readme.txt | 35 |
6 files changed, 570 insertions, 0 deletions
diff --git a/lib/example.c b/lib/example.c new file mode 100644 index 0000000..33a7cc1 --- /dev/null +++ b/lib/example.c @@ -0,0 +1,156 @@ +/*
+ HTTrack library example
+ .c file
+
+ To Build on Windows:
+ - compile everything in src/ BUT htsparse.c, compile example.c
+ - multithreaded
+ - avoid precompiled headers with VC
+
+ To Build on Linux:
+ make lib_linux (or "make lib_netbsd", or "make lib_default" and so on)
+ cp htssystem.h src/htssystem.h
+ make build_httracklib
+*/
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "src/httrack-library.h"
+
+#include "example.h"
+
+
+
+/*
+ * Name: main
+ * Description: main() function
+ * Parameters: None
+ * Should return: error status
+*/
+int main(void) {
+ /*
+ First, ask for an URL
+ Note: For the test, option r2 (mirror max depth=1) and --testscan (no index, no cache, do not store, no log files)
+ */
+ char _argv[][256] = {"httrack_test" , "<URL>" , "-r3" , "--testscan" , "" };
+ char* argv[] = {NULL , NULL , NULL , NULL , NULL};
+ int argc = 0;
+ while(strlen(_argv[argc])) {
+ argv[argc]=_argv[argc];
+ argc++;
+ }
+ argv[argc]=NULL;
+ printf("HTTrackLib test program\n");
+ printf("Enter URL (example: www.foobar.com/index.html) :");
+ scanf("%s",argv[1]);
+ printf("Test: 1 depth\n");
+
+ hts_init();
+ htswrap_add("init",httrack_wrapper_init);
+ htswrap_add("free",httrack_wrapper_uninit);
+ htswrap_add("start",httrack_wrapper_start);
+ htswrap_add("change-options",httrack_wrapper_chopt);
+ htswrap_add("end",httrack_wrapper_end);
+ htswrap_add("check-html",httrack_wrapper_checkhtml);
+ htswrap_add("loop",httrack_wrapper_loop);
+ htswrap_add("query",httrack_wrapper_query);
+ htswrap_add("query2",httrack_wrapper_query2);
+ htswrap_add("query3",httrack_wrapper_query3);
+ htswrap_add("check-link",httrack_wrapper_check);
+ htswrap_add("pause",httrack_wrapper_pause);
+ htswrap_add("save-file",httrack_wrapper_filesave);
+ htswrap_add("link-detected",httrack_wrapper_linkdetected);
+ htswrap_add("transfer-status",httrack_wrapper_xfrstatus);
+ htswrap_add("save-name",httrack_wrapper_savename);
+
+ /* Then, launch the mirror */
+ hts_main(argc,argv);
+
+ /* Wait for a key */
+ printf("\nPress ENTER key to exit\n");
+ scanf("%s",argv[1]);
+
+ /* That's all! */
+ return 0;
+}
+
+
+/* CALLBACK FUNCTIONS */
+
+/* Initialize the Winsock */
+void __cdecl httrack_wrapper_init(void) {
+ printf("Engine started\n");
+#ifdef _WIN32
+ {
+ WORD wVersionRequested; // requested version WinSock API
+ WSADATA wsadata; // Windows Sockets API data
+ int stat;
+ wVersionRequested = 0x0101;
+ stat = WSAStartup( wVersionRequested, &wsadata );
+ if (stat != 0) {
+ printf("Winsock not found!\n");
+ return;
+ } else if (LOBYTE(wsadata.wVersion) != 1 && HIBYTE(wsadata.wVersion) != 1) {
+ printf("WINSOCK.DLL does not support version 1.1\n");
+ WSACleanup();
+ return;
+ }
+ }
+#endif
+
+}
+void __cdecl httrack_wrapper_uninit(void) {
+ printf("Engine exited\n");
+#ifdef _WIN32
+ WSACleanup();
+#endif
+}
+int __cdecl httrack_wrapper_start(httrackp* opt) {
+ printf("Start of mirror\n");
+ return 1;
+}
+int __cdecl httrack_wrapper_chopt(httrackp* opt) {
+ return __cdecl httrack_wrapper_start(opt);
+}
+int __cdecl httrack_wrapper_end(void) {
+ printf("End of mirror\n");
+ return 1;
+}
+int __cdecl httrack_wrapper_checkhtml(char* html,int len,char* url_adresse,char* url_fichier) {
+ printf("Parsing html file: http://%s%s\n",url_adresse,url_fichier);
+ return 1;
+}
+int __cdecl httrack_wrapper_loop(void* _back,int back_max,int back_index,int lien_n,int lien_tot,int stat_time,hts_stat_struct* stats) {
+ /* printf("..httrack_wrapper_loop called\n"); */
+ return 1;
+}
+char* __cdecl httrack_wrapper_query(char* question) {
+ return "N";
+}
+char* __cdecl httrack_wrapper_query2(char* question) {
+ return "N";
+}
+char* __cdecl httrack_wrapper_query3(char* question) {
+ return "";
+}
+int __cdecl httrack_wrapper_check(char* adr,char* fil,int status) {
+ printf("Link status tested: http://%s%s\n",adr,fil);
+ return -1;
+}
+void __cdecl httrack_wrapper_pause(char* lockfile) {
+}
+void __cdecl httrack_wrapper_filesave(char* file) {
+}
+void __cdecl httrack_wrapper_savename(char* adr_complete,char* fil_complete,char* referer_adr,char* referer_fil,char* save) {
+/* strcpy(save, "foo.html"); */ +}
+int __cdecl httrack_wrapper_linkdetected(char* link) {
+ printf("Link detected: %s\n",link);
+ return 1;
+}
+int __cdecl httrack_wrapper_xfrstatus(void* back) {
+ return 1;
+}
+
diff --git a/lib/example.dsp b/lib/example.dsp new file mode 100644 index 0000000..4da0cb4 --- /dev/null +++ b/lib/example.dsp @@ -0,0 +1,311 @@ +# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=example - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "example - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x40c /d "NDEBUG"
+# ADD RSC /l 0x40c /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 wsock32.lib /nologo /subsystem:console /machine:I386
+
+!ELSEIF "$(CFG)" == "example - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /FD /GZ /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x40c /d "_DEBUG"
+# ADD RSC /l 0x40c /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 wsock32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "example - Win32 Release"
+# Name "example - Win32 Debug"
+# Begin Source File
+
+SOURCE=.\example.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\example.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsalias.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsalias.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsback.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsback.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsbase.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsbasenet.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsbauth.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsbauth.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htscache.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htscache.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htscatchurl.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htscatchurl.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsconfig.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htscore.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htscore.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htscoremain.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htscoremain.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsdefines.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsfilters.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsfilters.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsftp.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsftp.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsglobal.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htshash.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htshash.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htshelp.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htshelp.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsindex.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsindex.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsjava.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsjava.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htslib.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htslib.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsmd5.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsmd5.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsname.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsname.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsnet.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsopt.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsrobots.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsrobots.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsthread.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htsthread.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htstools.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htstools.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htswizard.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htswizard.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htswrap.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\htswrap.h
+# End Source File
+# Begin Source File
+
+SOURCE=".\src\httrack-library.h"
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\httrack.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\httrack.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\md5.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\md5.h
+# End Source File
+# End Target
+# End Project
diff --git a/lib/example.dsw b/lib/example.dsw new file mode 100644 index 0000000..8ddad80 --- /dev/null +++ b/lib/example.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "example"=.\example.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/lib/example.h b/lib/example.h new file mode 100644 index 0000000..2ea0a67 --- /dev/null +++ b/lib/example.h @@ -0,0 +1,27 @@ +/*
+ HTTrack library example
+ .h file
+*/
+
+#if __WIN32
+#else
+#define __cdecl
+#endif
+
+void __cdecl httrack_wrapper_init(void);
+void __cdecl httrack_wrapper_uninit(void);
+int __cdecl httrack_wrapper_start(httrackp* opt);
+int __cdecl httrack_wrapper_chopt(httrackp* opt);
+int __cdecl httrack_wrapper_end(void);
+int __cdecl httrack_wrapper_checkhtml(char* html,int len,char* url_adresse,char* url_fichier);
+int __cdecl httrack_wrapper_loop(void* _back,int back_max,int back_index,int lien_n,int lien_tot,int stat_time,hts_stat_struct* stats);
+char* __cdecl httrack_wrapper_query(char* question);
+char* __cdecl httrack_wrapper_query2(char* question);
+char* __cdecl httrack_wrapper_query3(char* question);
+int __cdecl httrack_wrapper_check(char* adr,char* fil,int status);
+void __cdecl httrack_wrapper_pause(char* lockfile);
+void __cdecl httrack_wrapper_filesave(char* file);
+int __cdecl httrack_wrapper_linkdetected(char* link);
+int __cdecl httrack_wrapper_xfrstatus(void* back);
+void __cdecl httrack_wrapper_savename(char* adr_complete,char* fil_complete,char* referer_adr,char* referer_fil,char* save);
+
diff --git a/lib/htssystem.h b/lib/htssystem.h new file mode 100644 index 0000000..5112ece --- /dev/null +++ b/lib/htssystem.h @@ -0,0 +1,12 @@ +/*
+ HTTrack library example
+*/
+
+#define HTS_PLATFORM 1
+#define HTS_ANALYSTE 1
+#define HTS_PLATFORM_NAME "example" +#ifdef _WIN32
+#define HTS_WIN 1
+#define HTS_USEZLIB 0
+#endif
+
diff --git a/lib/readme.txt b/lib/readme.txt new file mode 100644 index 0000000..658cfdf --- /dev/null +++ b/lib/readme.txt @@ -0,0 +1,35 @@ +HTTrack library example
+-----------------------
+
+Here is an example of how to integrate HTTrack Website Copier into a project
+to use it as a "core engine". Copy the src/ directory and the Makefile.*/configure
+scripts in lib/ to have a working example.
+
+
+Important Notice:
+----------------
+
+These sources are covered by the GNU General Public License (see below)
+(Projects based on these sources must follow the GPL, too)
+
+
+Copyright notice:
+----------------
+
+HTTrack Website Copier, Offline Browser for Windows and Unix
+Copyright (C) Xavier Roche and other contributors
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
|