int CWinHTTrackApp::ExitInstance() { LANG_DELETE(); /* Uninitialize */ htsthread_wait(); hts_uninit(); return CWinApp::ExitInstance(); }
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; }
HTSEXT_API void htsthread_uninit(void) { htsthread_wait(); #if USE_BEGINTHREAD hts_mutexfree(&process_chain_mutex); #endif }
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; }
int main(int argc, char* argv[]) { int i; int ret = 0; int defaultPort = 0; printf("Initialzing the server..\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) { fprintf(stderr, "Winsock not found!\n"); return -1; } else if (LOBYTE(wsadata.wVersion) != 1 && HIBYTE(wsadata.wVersion) != 1) { fprintf(stderr, "WINSOCK.DLL does not support version 1.1\n"); WSACleanup(); return -1; } } #endif if (argc < 2 || (argc % 2) != 0) { fprintf(stderr, "** Warning: use the webhttrack frontend if available\n"); fprintf(stderr, "usage: %s [--port <port>] <path-to-html-root-dir> [key value [key value]..]\n", argv[0]); fprintf(stderr, "example: %s /usr/share/httrack/\n", argv[0]); return 1; } /* init and launch */ hts_init(); htslang_init(); /* set general keys */ #ifdef HTS_ETCPATH smallserver_setkey("ETCPATH", HTS_ETCPATH); #endif #ifdef HTS_BINPATH smallserver_setkey("BINPATH", HTS_BINPATH); #endif #ifdef HTS_LIBPATH smallserver_setkey("LIBPATH", HTS_LIBPATH); #endif #ifdef HTS_PREFIX smallserver_setkey("PREFIX", HTS_PREFIX); #endif #ifdef HTS_HTTRACKCNF smallserver_setkey("HTTRACKCNF", HTS_HTTRACKCNF); #endif #ifdef HTS_HTTRACKDIR smallserver_setkey("HTTRACKDIR", HTS_HTTRACKDIR); #endif #ifdef HTS_INET6 smallserver_setkey("INET6", "1"); #endif #ifdef HTS_USEOPENSSL smallserver_setkey("USEOPENSSL", "1"); #endif #ifdef HTS_DLOPEN smallserver_setkey("DLOPEN", "1"); #endif #ifdef HTS_USESWF smallserver_setkey("USESWF", "1"); #endif #ifdef HTS_USEZLIB smallserver_setkey("USEZLIB", "1"); #endif #ifdef _WIN32 smallserver_setkey("WIN32", "1"); #endif smallserver_setkey("HTTRACK_VERSION", HTTRACK_VERSION); smallserver_setkey("HTTRACK_VERSIONID", HTTRACK_VERSIONID); smallserver_setkey("HTTRACK_AFF_VERSION", HTTRACK_AFF_VERSION); { char tmp[32]; sprintf(tmp, "%d", -1); smallserver_setkey("HTS_PLATFORM", tmp); } smallserver_setkey("HTTRACK_WEB", HTTRACK_WEB); /* protected session-id */ { char buff[1024]; char digest[32 + 2]; srand((unsigned int)time(NULL)); sprintf(buff, "%d-%d", (int)time(NULL), (int)rand()); domd5mem(buff,strlen(buff),digest,1); smallserver_setkey("sid", digest); smallserver_setkey("_sid", digest); } /* set commandline keys */ for(i = 2 ; i < argc ; i += 2) { if (strcmp(argv[i], "--port") == 0) { if (sscanf(argv[i + 1], "%d", &defaultPort) != 1 || defaultPort < 0 || defaultPort >= 65535 ) { fprintf(stderr, "couldn't set the port number to %s\n", argv[i + 1]); return -1; } } else { smallserver_setkey(argv[i], argv[i + 1]); } } /* sigpipe */ #ifndef _WIN32 signal( SIGPIPE , htsweb_sig_brpipe ); // broken pipe (write into non-opened socket) #endif /* launch */ ret = help_server(argv[1], defaultPort); htsthread_wait(); hts_uninit(); #ifdef _WIN32 WSACleanup(); #endif return ret; }