home *** CD-ROM | disk | FTP | other *** search
- /*
- HTTrack library example
-
- To Build on Windows:
- - compile everything in src/ BUT htsparse.c, compile httracklib.c and example.c
- - multithreaded
- - no 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 <string.h>
- #include "httracklib.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>" , "-r2" , "--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");
-
- /* Then, launch the mirror */
- HTTrackLib_main(argc,argv);
-
- /* Wait for a key */
- printf("\nPress ENTER key to exit\n");
- scanf("%s",argv[1]);
-
- /* That's all! */
- return 0;
- }
-
- /*
- * Name: HTTrackLib_Init
- * Description: Called during HTTrack initialization
- * Parameters: None
- * Should return: Nothing
- */
- void HTTrackLib_Init() {
- printf("HTTrack initialized\n");
- }
-
- /*
- * Name: HTTrackLib_Close
- * Description: Called during HTTrack termination
- * Parameters: None
- * Should return: Nothing
- */
- void HTTrackLib_Close() {
- printf("HTTrack closed\n");
- }
-
- /*
- * Name: HTTrackLib_Start
- * Description: Called before HTTrack starts the mirror
- * Parameters: None
- * Should return: 1 if no error has been detected
- */
- int HTTrackLib_Start() {
- printf("HTTrack started\n");
- return 1;
- }
-
- /*
- * Name: HTTrackLib_End
- * Description: Called after HTTrack ends the mirror
- * Parameters: None
- * Should return: 1 if no error has been detected
- */
- int HTTrackLib_End() {
- printf("HTTrack ended\n");
- return 1;
- }
-
- /*
- * Name: HTTrackLib_TestLink
- * Description: Test if a link has to be caught
- * Parameters: host_name (host name, www.foo.com)
- * filename (filename, /index.html)
- * current_status
- * 0: link should be accepted
- * 1: link should be refused
- * -1: the engine has no opinion (by default, the link will be refused)
- * Should return: new status
- * 0: link will be accepted
- * 1: link will be refused
- * -1: we do not have any opinion (by default, current status will be kept)
- */
- int HTTrackLib_TestLink(char* host_name,char* filename,int current_status) {
- printf("HTTrack asked for status for this link link: %s%s (current is %s)\n",host_name,filename,(current_status==0)?"accepted":"refused");
- return -1;
- }
-
- /*
- * Name: HTTrackLib_TestParse
- * Description: Test if an HTML file has to be parsed (after download)
- * Parameters: host_name (host name, www.foo.com)
- * filename (filename, /index.html)
- * buffer_html (address of the HTML buffer)
- * buffer_html_size (size of this buffer in bytes)
- * Should return: response
- * 0: do not parse this file
- * 1: parse this file (default behaviour)
- */
- int HTTrackLib_TestParse(char* host_name,char* filename,char* buffer_html,int buffer_html_size) {
- printf("HTTrack asks whether to parse %s%s (%d bytes)\n",host_name,filename,buffer_html_size);
- return 1;
- }
-
-