CWinHTTrackApp::~CWinHTTrackApp() { DeleteTabs(); delete HtsHelper; HtsHelper=NULL; if (global_opt != NULL) { hts_free_opt(global_opt); global_opt = NULL; } }
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; }
void ht_uninit() { opt = NULL; hts_free_opt(opt); hts_uninit(); }
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; }
// modif options void Cinprogress::OnModifyOpt() { // maintab->m_option1.modify= maintab->m_option2.modify= maintab->m_option3.modify= maintab->m_option7.modify= maintab->m_option8.modify= maintab->m_option9.modify= maintab->m_option11.modify= maintab->m_option10.modify=1; // mode modification if (maintab->DoModal() == IDOK) { int n; LLint ln; float nf; httrackp *const opt = hts_create_opt(); assert(opt->size_httrackp == sizeof(httrackp)); opt->log = opt->errlog = NULL; // dévalider champs (non modifiés) opt->maxsite = -1; opt->maxfile_nonhtml = -1; opt->maxfile_html = -1; opt->maxsoc = -1; opt->nearlink = -1; opt->timeout = -1; opt->rateout = -1; opt->maxtime = -1; //opt->mms_maxtime = -1; opt->maxrate = -1; StringClear(opt->user_agent); opt->retry = -1; opt->hostcontrol = -1; opt->errpage = -1; opt->travel = -1; opt->external = -1; opt->delete_old=-1; opt->parseall=-1; opt->delete_old=-1; opt->travel=0; // NOTE: NE SERA PRIS EN COMPTE QUE LE BIT 8 if(maintab->m_option1.m_testall) opt->travel|=256; if(maintab->m_option1.m_parseall) opt->parseall=1; else opt->parseall=0; // near link,err page if (maintab->m_option1.m_link) opt->nearlink=1; else opt->nearlink=0; if (maintab->m_option2.m_errpage) opt->errpage=1; else opt->errpage=0; if (maintab->m_option2.m_external) opt->external=1; else opt->external=0; if (maintab->m_option2.m_nopurge) opt->delete_old=1; else opt->delete_old=0; // host control { int a=0; if (maintab->m_option4.m_remt) a+=1; if (maintab->m_option4.m_rems) a+=2; opt->hostcontrol=a; } // sockets if (strcmp(maintab->m_option4.m_connexion,"")!=0) { if (sscanf(maintab->m_option4.m_connexion,"%d",&n) == 1) opt->maxsoc = n; } // maxfile_nonhtml if (strcmp(maintab->m_option5.m_othermax,"")!=0) { if (sscanf(maintab->m_option5.m_othermax,LLintP,&ln) == 1) opt->maxfile_nonhtml = ln; } else opt->maxfile_nonhtml = -1; // maxfile_html if (strcmp(maintab->m_option5.m_maxhtml,"")!=0) { if (sscanf(maintab->m_option5.m_maxhtml,LLintP,&ln) == 1) opt->maxfile_html = ln; } else opt->maxfile_html = -1; // maxsite if (strcmp(maintab->m_option5.m_sizemax,"")!=0) { if (sscanf(maintab->m_option5.m_sizemax,LLintP,&ln) == 1) opt->maxsite = ln; } else opt->maxsite = -1; // fragment if (strcmp(maintab->m_option5.m_pausebytes,"")!=0) { if (sscanf(maintab->m_option5.m_pausebytes,LLintP,&ln) == 1) opt->fragment = ln; } else opt->fragment = -1; // timeout if (strcmp(maintab->m_option4.m_timeout,"")!=0) { if (sscanf(maintab->m_option4.m_timeout,"%d",&n) == 1) opt->timeout = n; } else opt->timeout = -1; // rateout if (strcmp(maintab->m_option4.m_rate,"")!=0) { if (sscanf(maintab->m_option4.m_rate,"%d",&n) == 1) opt->rateout = n; } else opt->rateout = -1; // maxtime if (strcmp(maintab->m_option5.m_maxtime,"")!=0) { if (sscanf(maintab->m_option5.m_maxtime,"%d",&n) == 1) opt->maxtime = n; } else opt->maxtime = -1; // maxrate if (strcmp(maintab->m_option5.m_maxrate,"")!=0) { if (sscanf(maintab->m_option5.m_maxrate,"%d",&n) == 1) opt->maxrate = n; } else opt->maxrate = -1; // max. connect if (strcmp(maintab->m_option5.m_maxconn,"")!=0) { if (sscanf(maintab->m_option5.m_maxconn,"%f",&nf) == 1) opt->maxconn = nf; } else opt->maxconn = -1; // retry if (strcmp(maintab->m_option4.m_retry,"")!=0) { if (sscanf(maintab->m_option4.m_retry,"%d",&n) == 1) opt->retry = n; } else opt->retry = -1; // user_agent if (strcmp(maintab->m_option6.m_user,"")!=0) { StringCopy(opt->user_agent, maintab->m_option6.m_user); } if (global_opt != NULL) { copy_htsopt(opt, global_opt); } hts_free_opt(opt); } maintab->m_option1.modify= maintab->m_option2.modify= maintab->m_option3.modify= maintab->m_option7.modify= maintab->m_option8.modify= maintab->m_option9.modify= maintab->m_option11.modify= maintab->m_option10.modify=0; }
static void back_launch_cmd( void* pP ) { char* cmd = (char*) pP; char** argv = (char**) malloct(1024 * sizeof(char*)); int argc = 0; int i = 0; int g = 0; // httrackp *opt; /* copy commandline */ if (commandReturnCmdl) free(commandReturnCmdl); commandReturnCmdl = strdup(cmd); /* split */ argv[0]="webhttrack"; argv[1]=cmd; argc++; i = 0; while(cmd[i]) { if (cmd[i] == '\t' || cmd[i] == '\r' || cmd[i] == '\n') { cmd[i] = ' '; } i++; } i = 0; while(cmd[i]) { if(cmd[i]=='\"') g=!g; if(cmd[i]==' ') { if(!g){ cmd[i]='\0'; argv[argc++]=cmd+i+1; } } i++; } /* init */ hts_init(); global_opt = opt = hts_create_opt(); /* run */ commandReturn = webhttrack_runmain(opt, argc, argv); if (commandReturn) { if (commandReturnMsg) free(commandReturnMsg); commandReturnMsg = strdup(hts_errmsg(opt)); } /* free */ global_opt = NULL; hts_free_opt(opt); hts_uninit(); /* okay */ commandRunning = 0; /* finished */ commandEnd = 1; /* free */ free(cmd); freet(argv); return ; }
/* * 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; }