/* module entry point */ EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv) { const char *arg = strchr(argv, ','); if (arg != NULL) arg++; /* Check args */ fprintf(stderr, "Plugged..\n"); if (arg == NULL || *arg == '\0' || strlen(arg) >= HTS_URLMAXSIZE / 2) { fprintf(stderr, "** callback error: arguments expected or bad arguments\n"); fprintf(stderr, "usage: httrack --wrapper modulename,base\n"); fprintf(stderr, "example: httrack --wrapper callback,http://www.example.com/\n"); return 0; /* failed */ } else { char *callbacks_userdef = strdup(arg); /* userdef */ /* Plug callback functions */ CHAIN_FUNCTION(opt, check_html, process_file, callbacks_userdef); CHAIN_FUNCTION(opt, linkdetected, check_detectedlink, callbacks_userdef); CHAIN_FUNCTION(opt, end, check_detectedlink_end, callbacks_userdef); fprintf(stderr, "Using root '%s'\n", callbacks_userdef); } return 1; /* success */ }
EXTERNAL_FUNCTION int hts_plug(httrackp * opt, const char *argv) { /* Plug callback functions */ CHAIN_FUNCTION(opt, detect, hts_detect_java, NULL); CHAIN_FUNCTION(opt, parse, hts_parse_java, NULL); return 1; /* success */ }
/* module entry point the function name and prototype MUST match this prototype */ EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv) { /* optional argument passed in the commandline we won't be using here */ const char *arg = strchr(argv, ','); if (arg != NULL) arg++; /* plug callback functions */ CHAIN_FUNCTION(opt, check_html, process_file, /*optional user-defined arg*/NULL); CHAIN_FUNCTION(opt, end, end_of_mirror, /*optional user-defined arg*/NULL); return 1; /* success */ }
/* module entry point */ EXTERNAL_FUNCTION int hts_plug(httrackp * opt, const char *argv) { const char *arg = strchr(argv, ','); if (arg != NULL) arg++; /* Check args */ if (arg == NULL || *arg == '\0') { fprintf(stderr, "** callback error: arguments expected or bad arguments\n"); fprintf(stderr, "usage: httrack --wrapper callback,stringtofind,stringtofind..\n"); fprintf(stderr, "example: httrack --wrapper callback,apple,orange,lemon\n"); return 0; } else { t_my_userdef *userdef = (t_my_userdef *) malloc(sizeof(t_my_userdef)); /* userdef */ char *const stringfilter = userdef->stringfilter; char **const stringfilters = userdef->stringfilters; /* */ char *a = stringfilter; int i = 0; fprintf(stderr, "** info: wrapper_init(%s) called!\n", arg); fprintf(stderr, "** callback example: crawling pages only if specific keywords are found\n"); /* stringfilters = split(arg, ','); */ strcpy(stringfilter, arg); while(a != NULL) { stringfilters[i] = a; a = strchr(a, ','); if (a != NULL) { *a = '\0'; a++; } fprintf(stderr, "** callback info: will crawl pages with '%s' in them\n", stringfilters[i]); i++; } stringfilters[i++] = NULL; /* Plug callback functions */ CHAIN_FUNCTION(opt, check_html, process, userdef); CHAIN_FUNCTION(opt, end, end, userdef); } return 1; /* success */ }
/* module entry point the function name and prototype MUST match this prototype */ EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv) { /* optional argument passed in the commandline we won't be using here */ const char *arg = strchr(argv, ','); if (arg != NULL) arg++; /* plug callback functions */ if (arg == NULL) arg = "log-wrapper-info"; hts_log(opt, arg, "* plugging functions"); CHAIN_FUNCTION(opt, check_html, process_file, (char*) arg); CHAIN_FUNCTION(opt, start, start_of_mirror, (char*) arg); CHAIN_FUNCTION(opt, end, end_of_mirror, (char*) arg); hts_log(opt, arg, "* module successfully plugged"); return 1; /* success */ }
/* module entry point */ EXTERNAL_FUNCTION int hts_plug(httrackp * opt, const char *argv) { const char *arg = strchr(argv, ','); if (arg != NULL) arg++; CHAIN_FUNCTION(opt, savename, mysavename, NULL); return 1; /* success */ }
/* module entry point */ EXTERNAL_FUNCTION int hts_plug(httrackp *opt, const char* argv) { t_my_userdef *userdef; /* */ const char *arg = strchr(argv, ','); if (arg != NULL) arg++; /* Create user-defined structure */ userdef = (t_my_userdef*) malloc(sizeof(t_my_userdef)); /* userdef */ userdef->currentURLBeingParsed[0] = '\0'; /* Plug callback functions */ CHAIN_FUNCTION(opt, check_html, process_file, userdef); CHAIN_FUNCTION(opt, end, end, userdef); CHAIN_FUNCTION(opt, linkdetected, check_detectedlink, userdef); CHAIN_FUNCTION(opt, loop, check_loop, userdef); return 1; /* success */ }
void start_dl(proj) { arg_init(&proj); CHAIN_FUNCTION(opt, init, htsshow_init, &proj); CHAIN_FUNCTION(opt, uninit, htsshow_uninit, &proj); CHAIN_FUNCTION(opt, start, htsshow_start, &proj); CHAIN_FUNCTION(opt, end, htsshow_end, &proj); CHAIN_FUNCTION(opt, chopt, htsshow_chopt, &proj); CHAIN_FUNCTION(opt, preprocess, htsshow_preprocesshtml, &proj); CHAIN_FUNCTION(opt, postprocess, htsshow_postprocesshtml, &proj); CHAIN_FUNCTION(opt, check_html, htsshow_checkhtml, &proj); CHAIN_FUNCTION(opt, query, htsshow_query, &proj); CHAIN_FUNCTION(opt, query2, htsshow_query2, &proj); CHAIN_FUNCTION(opt, query3, htsshow_query3, &proj); CHAIN_FUNCTION(opt, loop, htsshow_loop, &proj); CHAIN_FUNCTION(opt, check_link, htsshow_check, &proj); CHAIN_FUNCTION(opt, check_mime, htsshow_check_mime, &proj); CHAIN_FUNCTION(opt, pause, htsshow_pause, &proj); CHAIN_FUNCTION(opt, filesave, htsshow_filesave, &proj); CHAIN_FUNCTION(opt, filesave2, htsshow_filesave2, &proj); CHAIN_FUNCTION(opt, linkdetected, htsshow_linkdetected, &proj); CHAIN_FUNCTION(opt, linkdetected2, htsshow_linkdetected2, &proj); CHAIN_FUNCTION(opt, xfrstatus, htsshow_xfrstatus, &proj); CHAIN_FUNCTION(opt, savename, htsshow_savename, &proj); CHAIN_FUNCTION(opt, sendhead, htsshow_sendheader, &proj); CHAIN_FUNCTION(opt, receivehead, htsshow_receiveheader, &proj); if (hts_main2(proj.argc, proj.argv, opt)) { fprintf(stderr, "hts_main2 with error %s\n", hts_errmsg(opt)); } }
int main(int argc, char **argv) { int ret = 0; httrackp *opt; signal_handlers(); hts_init(); opt = global_opt = hts_create_opt(); CHAIN_FUNCTION(opt, init, htsshow_init, NULL); CHAIN_FUNCTION(opt, uninit, htsshow_uninit, NULL); CHAIN_FUNCTION(opt, start, htsshow_start, NULL); CHAIN_FUNCTION(opt, end, htsshow_end, NULL); CHAIN_FUNCTION(opt, chopt, htsshow_chopt, NULL); CHAIN_FUNCTION(opt, preprocess, htsshow_preprocesshtml, NULL); CHAIN_FUNCTION(opt, postprocess, htsshow_postprocesshtml, NULL); CHAIN_FUNCTION(opt, check_html, htsshow_checkhtml, NULL); CHAIN_FUNCTION(opt, query, htsshow_query, NULL); CHAIN_FUNCTION(opt, query2, htsshow_query2, NULL); CHAIN_FUNCTION(opt, query3, htsshow_query3, NULL); CHAIN_FUNCTION(opt, loop, htsshow_loop, NULL); CHAIN_FUNCTION(opt, check_link, htsshow_check, NULL); CHAIN_FUNCTION(opt, check_mime, htsshow_check_mime, NULL); CHAIN_FUNCTION(opt, pause, htsshow_pause, NULL); CHAIN_FUNCTION(opt, filesave, htsshow_filesave, NULL); CHAIN_FUNCTION(opt, filesave2, htsshow_filesave2, NULL); CHAIN_FUNCTION(opt, linkdetected, htsshow_linkdetected, NULL); CHAIN_FUNCTION(opt, linkdetected2, htsshow_linkdetected2, NULL); CHAIN_FUNCTION(opt, xfrstatus, htsshow_xfrstatus, NULL); CHAIN_FUNCTION(opt, savename, htsshow_savename, NULL); CHAIN_FUNCTION(opt, sendhead, htsshow_sendheader, NULL); CHAIN_FUNCTION(opt, receivehead, htsshow_receiveheader, NULL); ret = hts_main2(argc, argv, opt); if (ret) { fprintf(stderr, "* %s\n", hts_errmsg(opt)); } global_opt = NULL; hts_free_opt(opt); htsthread_wait(); /* wait for pending threads */ hts_uninit(); return ret; }
int main(int argc, char **argv) { int ret = 0; httrackp *opt; #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 signal_handlers(); hts_init(); // Check version compatibility if (hts_sizeof_opt() != sizeof(httrackp)) { fprintf(stderr, "incompatible current httrack library version %s, expected version %s", hts_version(), HTTRACK_VERSIONID); abortLog("incompatible httrack library version, please update both httrack and its library"); } opt = global_opt = hts_create_opt(); assert(opt->size_httrackp == sizeof(httrackp)); CHAIN_FUNCTION(opt, init, htsshow_init, NULL); CHAIN_FUNCTION(opt, uninit, htsshow_uninit, NULL); CHAIN_FUNCTION(opt, start, htsshow_start, NULL); CHAIN_FUNCTION(opt, end, htsshow_end, NULL); CHAIN_FUNCTION(opt, chopt, htsshow_chopt, NULL); CHAIN_FUNCTION(opt, preprocess, htsshow_preprocesshtml, NULL); CHAIN_FUNCTION(opt, postprocess, htsshow_postprocesshtml, NULL); CHAIN_FUNCTION(opt, check_html, htsshow_checkhtml, NULL); CHAIN_FUNCTION(opt, query, htsshow_query, NULL); CHAIN_FUNCTION(opt, query2, htsshow_query2, NULL); CHAIN_FUNCTION(opt, query3, htsshow_query3, NULL); CHAIN_FUNCTION(opt, loop, htsshow_loop, NULL); CHAIN_FUNCTION(opt, check_link, htsshow_check, NULL); CHAIN_FUNCTION(opt, check_mime, htsshow_check_mime, NULL); CHAIN_FUNCTION(opt, pause, htsshow_pause, NULL); CHAIN_FUNCTION(opt, filesave, htsshow_filesave, NULL); CHAIN_FUNCTION(opt, filesave2, htsshow_filesave2, NULL); CHAIN_FUNCTION(opt, linkdetected, htsshow_linkdetected, NULL); CHAIN_FUNCTION(opt, linkdetected2, htsshow_linkdetected2, NULL); CHAIN_FUNCTION(opt, xfrstatus, htsshow_xfrstatus, NULL); CHAIN_FUNCTION(opt, savename, htsshow_savename, NULL); CHAIN_FUNCTION(opt, sendhead, htsshow_sendheader, NULL); CHAIN_FUNCTION(opt, receivehead, htsshow_receiveheader, NULL); ret = hts_main2(argc, argv, opt); if (ret) { fprintf(stderr, "* %s\n", hts_errmsg(opt)); } global_opt = NULL; hts_free_opt(opt); htsthread_wait(); /* wait for pending threads */ hts_uninit(); #ifdef _WIN32 WSACleanup(); #endif return ret; }
static int webhttrack_runmain(httrackp *opt, int argc, char** argv) { int ret; CHAIN_FUNCTION(opt, init, htsshow_init, NULL); CHAIN_FUNCTION(opt, uninit, htsshow_uninit, NULL); CHAIN_FUNCTION(opt, start, htsshow_start, NULL); CHAIN_FUNCTION(opt, end, htsshow_end, NULL); CHAIN_FUNCTION(opt, chopt, htsshow_chopt, NULL); CHAIN_FUNCTION(opt, preprocess, htsshow_preprocesshtml, NULL); CHAIN_FUNCTION(opt, postprocess, htsshow_postprocesshtml, NULL); CHAIN_FUNCTION(opt, check_html, htsshow_checkhtml, NULL); CHAIN_FUNCTION(opt, query, htsshow_query, NULL); CHAIN_FUNCTION(opt, query2, htsshow_query2, NULL); CHAIN_FUNCTION(opt, query3, htsshow_query3, NULL); CHAIN_FUNCTION(opt, loop, htsshow_loop, NULL); CHAIN_FUNCTION(opt, check_link, htsshow_check, NULL); CHAIN_FUNCTION(opt, check_mime, htsshow_check_mime, NULL); CHAIN_FUNCTION(opt, pause, htsshow_pause, NULL); CHAIN_FUNCTION(opt, filesave, htsshow_filesave, NULL); CHAIN_FUNCTION(opt, filesave2, htsshow_filesave2, NULL); CHAIN_FUNCTION(opt, linkdetected, htsshow_linkdetected, NULL); CHAIN_FUNCTION(opt, linkdetected2, htsshow_linkdetected2, NULL); CHAIN_FUNCTION(opt, xfrstatus, htsshow_xfrstatus, NULL); CHAIN_FUNCTION(opt, savename, htsshow_savename, NULL); CHAIN_FUNCTION(opt, sendhead, htsshow_sendheader, NULL); CHAIN_FUNCTION(opt, receivehead, htsshow_receiveheader, NULL); ret = hts_main2(argc, argv, opt); htsthread_wait_n(1); return ret; }
/* * 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; httrackp *opt; int ret; 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"); /* Initialize the library */ #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 hts_init(); /* Create option settings and set callbacks (wrappers) */ opt = hts_create_opt(); CHAIN_FUNCTION(opt, init, httrack_wrapper_init, NULL); CHAIN_FUNCTION(opt, uninit, httrack_wrapper_uninit, NULL); CHAIN_FUNCTION(opt, start, httrack_wrapper_start, NULL); CHAIN_FUNCTION(opt, end, httrack_wrapper_end, NULL); CHAIN_FUNCTION(opt, chopt, httrack_wrapper_chopt, NULL); CHAIN_FUNCTION(opt, preprocess, httrack_wrapper_preprocesshtml, NULL); CHAIN_FUNCTION(opt, postprocess, httrack_wrapper_postprocesshtml, NULL); CHAIN_FUNCTION(opt, check_html, httrack_wrapper_checkhtml, NULL); CHAIN_FUNCTION(opt, query, httrack_wrapper_query, NULL); CHAIN_FUNCTION(opt, query2, httrack_wrapper_query2, NULL); CHAIN_FUNCTION(opt, query3, httrack_wrapper_query3, NULL); CHAIN_FUNCTION(opt, loop, httrack_wrapper_loop, NULL); CHAIN_FUNCTION(opt, check_link, httrack_wrapper_check, NULL); CHAIN_FUNCTION(opt, check_mime, httrack_wrapper_check_mime, NULL); CHAIN_FUNCTION(opt, pause, httrack_wrapper_pause, NULL); CHAIN_FUNCTION(opt, filesave, httrack_wrapper_filesave, NULL); CHAIN_FUNCTION(opt, filesave2, httrack_wrapper_filesave2, NULL); CHAIN_FUNCTION(opt, linkdetected, httrack_wrapper_linkdetected, NULL); CHAIN_FUNCTION(opt, linkdetected2, httrack_wrapper_linkdetected2, NULL); CHAIN_FUNCTION(opt, xfrstatus, httrack_wrapper_xfrstatus, NULL); CHAIN_FUNCTION(opt, savename, httrack_wrapper_savename, NULL); CHAIN_FUNCTION(opt, sendhead, httrack_wrapper_sendheader, NULL); CHAIN_FUNCTION(opt, receivehead, httrack_wrapper_receiveheader, NULL); /* Then, launch the mirror */ ret = hts_main2(argc, argv, opt); /* Wait for a key */ printf("\nPress ENTER key to exit\n"); scanf("%s",argv[1]); /* Clear option state */ hts_free_opt(opt); hts_uninit(); #ifdef _WIN32 WSACleanup(); #endif /* That's all! */ return 0; }