uconfig.c
来自「网络爬虫程序」· C语言 代码 · 共 1,533 行 · 第 1/3 页
C
1,533 行
int xget_cfg_values_lim(void){ struct tm ftm; char *p = NULL; bool_t b; struct stat estat; LOCK_GCFG; GET_HTML_TAGS; GET_PATH(gui_cfg.subdir_label, p); if(p && !((stat(p, &estat) >= 0) && S_ISDIR(estat.st_mode))) { _free(p); xprintf(0, gettext("Bad parameter - Working subdirectory")); _MT_CFGSTAMP; UNLOCK_GCFG; return -1; } else { _free(cfg.subdir); if(p) cfg.subdir = get_abs_file_path_oss(p); _free(p); } GET_BOOL(gui_cfg.ftp_html, cfg.ftp_html); GET_BOOL(gui_cfg.leaves_sw, cfg.condition.dont_leave_site); GET_BOOL(gui_cfg.leaved_sw, cfg.condition.dont_leave_dir); GET_BOOL(gui_cfg.dont_leave_site_dir, cfg.condition.dont_leave_site_dir); GET_BOOL(gui_cfg.singlepage, cfg.singlepage); GET_BOOL(gui_cfg.limit_inlines, cfg.condition.limit_inlines); GET_BOOL(gui_cfg.cgi_sw, cfg.condition.cgi); GET_BOOL(gui_cfg.ftpd_sw, cfg.condition.ftpdir); GET_BOOL(gui_cfg.allow_ports, cfg.condition.allow_ports); GET_BOOL(gui_cfg.hosts_sw, cfg.condition.allow_site); GET_BOOL(gui_cfg.domain_sw, cfg.condition.allow_domain); GET_BOOL(gui_cfg.mime_sw, cfg.condition.allow_mime); GET_BOOL(gui_cfg.prefix_sw, cfg.condition.allow_prefix); GET_BOOL(gui_cfg.sufix_sw, cfg.condition.allow_sufix); GET_BOOL(gui_cfg.robots_sw, cfg.condition.allow_robots); GET_NUMLIST(gui_cfg.ports, cfg.condition.ports); GET_PAT(gui_cfg.pattern_label, cfg.condition.pattern); GET_PAT(gui_cfg.skip_pattern, cfg.condition.skip_pattern); GET_PAT(gui_cfg.url_pattern_label, cfg.condition.url_pattern); GET_PAT(gui_cfg.skip_url_pattern, cfg.condition.skip_url_pattern);#ifdef HAVE_REGEX GET_REPAT(gui_cfg.rpattern, cfg.condition.rpattern); GET_REPAT(gui_cfg.skip_rpattern, cfg.condition.rskip_pattern); GET_REPAT(gui_cfg.url_rpattern, cfg.condition.rurl_pattern); GET_REPAT(gui_cfg.url_skip_rpattern, cfg.condition.rskip_url_pattern); GET_REPAT(gui_cfg.aip, cfg.condition.aip); GET_REPAT(gui_cfg.skipip, cfg.condition.skipip);#endif GET_STR(gui_cfg.en_uexit, cfg.condition.uexit); GET_STR(gui_cfg.follow_cmd, cfg.condition.follow_cmd); GET_LIST(gui_cfg.hosts_list, cfg.condition.sites); GET_LIST(gui_cfg.amimelist, cfg.condition.mime); GET_LIST(gui_cfg.domain_list, cfg.condition.domains); GET_NUM(gui_cfg.maxlev_label, cfg.condition.max_levels); GET_NUM(gui_cfg.leave_level, cfg.condition.leave_level); GET_NUM(gui_cfg.site_level, cfg.condition.site_level); GET_NUM(gui_cfg.maxdoc_label, cfg.condition.max_documents); GET_NUM(gui_cfg.maxsize_label, cfg.condition.max_size); GET_NUM(gui_cfg.min_size, cfg.condition.min_size); GET_LIST(gui_cfg.sufixlist, cfg.condition.sufix); GET_LIST(gui_cfg.prefixlist, cfg.condition.dir_prefix); GET_DOUBLE(gui_cfg.max_time, cfg.max_time); GET_BOOL(gui_cfg.btime_sw, b); if(b) { GET_DATE(gui_cfg.btime_cal, ftm); ftm.tm_sec = 0; ftm.tm_isdst = -1; GET_NUM(gui_cfg.btime_h_entry, ftm.tm_hour); GET_NUM(gui_cfg.btime_min_entry, ftm.tm_min); cfg.condition.btime = mktime(&ftm); } else cfg.condition.btime = (time_t) 0; GET_BOOL(gui_cfg.etime_sw, b); if(b) { GET_DATE(gui_cfg.etime_cal, ftm); ftm.tm_sec = 0; ftm.tm_isdst = -1; GET_NUM(gui_cfg.etime_h_entry, ftm.tm_hour); GET_NUM(gui_cfg.etime_min_entry, ftm.tm_min); cfg.condition.etime = mktime(&ftm); } else cfg.condition.etime = (time_t) 0; _MT_CFGSTAMP; UNLOCK_GCFG; return 0;}int xget_cfg_values_comm(void){ char *tp, *p = NULL; struct stat estat; dllist *ptr; LOCK_GCFG; GET_PATH(gui_cfg.cdir_label, p); if(p && !((stat(p, &estat) >= 0) && S_ISDIR(estat.st_mode))) { xprintf(0, gettext("Bad parameter - Cache directory")); _MT_CFGSTAMP; UNLOCK_GCFG; return -1; } else { _free(cfg.cache_dir); if(p) cfg.cache_dir = get_abs_file_path_oss(p); _free(p); } GET_PATH(gui_cfg.info_dir, cfg.info_dir);#ifdef HAVE_BDB_18x GET_PATH(gui_cfg.ns_cache_dir, cfg.ns_cache_dir); GET_PATH(gui_cfg.moz_cache_dir, cfg.moz_cache_dir);#endif p = cfg.cookie_file; GET_S_PATH(gui_cfg.en_cookie_file, cfg.cookie_file); if(!((cfg.cookie_file && p && !strcmp(p, cfg.cookie_file)) || !cfg.cookie_file)) { cookie_read_file(cfg.cookie_file); } _free(p); GET_STR(gui_cfg.default_prefix, cfg.default_prefix); GET_BOOL(gui_cfg.check_size, cfg.check_size); GET_BOOL(gui_cfg.store_index, cfg.store_index); GET_BOOL(gui_cfg.unique_doc, cfg.unique_doc); GET_BOOL(gui_cfg.del_after, cfg.del_after); GET_BOOL(gui_cfg.preserve_perm, cfg.preserve_perm); GET_BOOL(gui_cfg.preserve_links, cfg.preserve_links); GET_BOOL(gui_cfg.retrieve_slink, cfg.retrieve_slink); GET_BOOL(gui_cfg.ftp_list, cfg.ftp_list); GET_BOOL(gui_cfg.fix_wuftpd, cfg.fix_wuftpd); GET_BOOL(gui_cfg.use_http11, cfg.use_http11); GETFTPHS_LIST(gui_cfg.ftp_login_hs, cfg.ftp_login_hs); GET_STR(gui_cfg.index_name, cfg.index_name); GET_STR(gui_cfg.store_name, cfg.store_name); GET_BOOL(gui_cfg.sw_cookie_send, cfg.send_cookies); GET_BOOL(gui_cfg.sw_cookie_recv, cfg.recv_cookies); GET_BOOL(gui_cfg.sw_cookie_update, cfg.update_cookies); GET_BOOL(gui_cfg.cookie_check_domain, cfg.cookie_check_domain); GET_BOOL(gui_cfg.ptime, cfg.preserve_time); GET_BOOL(gui_cfg.cache_sw, cfg.cache); GET_BOOL(gui_cfg.oldrm_sw, cfg.remove_old); GET_BOOL(gui_cfg.ftp_sw, cfg.condition.ftp); GET_BOOL(gui_cfg.http_sw, cfg.condition.http);#ifdef USE_SSL GET_BOOL(gui_cfg.https_sw, cfg.condition.https); GET_BOOL(gui_cfg.ftps_sw, cfg.condition.ftps);#endif GET_BOOL(gui_cfg.gopher_sw, cfg.condition.gopher); GET_BOOL(gui_cfg.gopher_httpgw, cfg.gopher_via_http); GET_BOOL(gui_cfg.ftp_httpgw, cfg.ftp_via_http); GET_BOOL(gui_cfg.ftp_dirtyp, cfg.ftp_dirtyp); GET_BOOL(gui_cfg.freget_sw, cfg.freget); GET_BOOL(gui_cfg.noreloc_sw, cfg.rewrite_links); GET_BOOL(gui_cfg.all_to_local, cfg.all_to_local); GET_BOOL(gui_cfg.all_to_remote, cfg.all_to_remote); GET_BOOL(gui_cfg.sel_to_local, cfg.sel_to_local); GET_BOOL(gui_cfg.post_update, cfg.post_update); GET_BOOL(gui_cfg.enable_js, cfg.enable_js); GET_BOOL(gui_cfg.auto_referer, cfg.auto_referer); GET_BOOL(gui_cfg.referer, cfg.referer); GET_BOOL(gui_cfg.enable_info, cfg.enable_info); GET_BOOL(gui_cfg.enc_sw, cfg.use_enc); GET_BOOL(gui_cfg.auth_reuse_nonce, cfg.auth_reuse_nonce); GET_BOOL(gui_cfg.auth_reuse_proxy_nonce, cfg.auth_reuse_proxy_nonce); GET_BOOL(gui_cfg.send_if_range, cfg.send_if_range); GET_BOOL(gui_cfg.show_time, cfg.show_time); GET_ENUM(gui_cfg.http_auth_scheme, cfg.auth_scheme); GET_ENUM(gui_cfg.http_proxy_auth_scheme, cfg.proxy_auth_scheme);#ifdef ENABLE_NTLM GET_STR(gui_cfg.auth_ntlm_domain, cfg.auth_ntlm_domain); GET_STR(gui_cfg.auth_proxy_ntlm_domain, cfg.auth_proxy_ntlm_domain);#endif GET_C_EXTRAS; GET_SSL_VER;#ifdef WITH_TREE GET_STR(gui_cfg.browser_label, cfg.browser);#endif GET_STR(gui_cfg.remind_cmd, cfg.remind_cmd); GET_STR(gui_cfg.post_cmd, cfg.post_cmd); GET_STR(gui_cfg.identity, cfg.identity); GET_STR(gui_cfg.ftp_proxyh_label, cfg.ftp_proxy); GET_NUM(gui_cfg.ftp_proxyp_label, cfg.ftp_proxy_port); GET_STR(gui_cfg.gopher_proxyh_label, cfg.gopher_proxy); GET_NUM(gui_cfg.gopher_proxyp_label, cfg.gopher_proxy_port); GET_BOOL(gui_cfg.read_css, cfg.read_css);#ifdef USE_SSL GET_STR(gui_cfg.ssl_proxyh_label, cfg.ssl_proxy); GET_NUM(gui_cfg.ssl_proxyp_label, cfg.ssl_proxy_port); GET_STR(gui_cfg.ssl_cert_passwd_en, cfg.ssl_cert_passwd); GET_STR(gui_cfg.ssl_cipher_list, cfg.ssl_cipher_list); GET_BOOL(gui_cfg.unique_sslid, cfg.unique_sslid);#ifdef USE_SSL_IMPL_OPENSSL GET_PATH(gui_cfg.ssl_cert_file_en, cfg.ssl_cert_file); GET_PATH(gui_cfg.ssl_key_file_en, cfg.ssl_key_file);#ifdef HAVE_RAND_EGD GET_PATH(gui_cfg.egd_socket, cfg.egd_socket);#endif#endif#ifdef USE_SSL_IMPL_NSS GET_PATH(gui_cfg.nss_cert_dir, cfg.nss_cert_dir); GET_BOOL(gui_cfg.nss_accept_unknown_cert, cfg.nss_accept_unknown_cert); GET_BOOL(gui_cfg.nss_domestic_policy, cfg.nss_domestic_policy);#endif#endif GET_STR(gui_cfg.local_ip, cfg.local_ip); memset(&cfg.local_ip_addr, '\0', sizeof(cfg.local_ip_addr)); if(cfg.local_ip && net_host_to_in_addr(cfg.local_ip, &cfg.local_ip_addr)) { xherror(cfg.local_ip); } GET_S_STR(gui_cfg.http_headers, tp); p = tp; while(cfg.http_headers) { httphdr_free((httphdr *) cfg.http_headers->data); cfg.http_headers = dllist_remove_entry(cfg.http_headers, cfg.http_headers); } if(p && *p) { while((p = get_1qstr(p))) { httphdr *hdr = httphdr_parse(p); if(hdr) cfg.http_headers = dllist_append(cfg.http_headers, (dllist_t) hdr); else xprintf(0, "Bad HTTP headers entry - %s\n", p); p = NULL; } } _free(tp); GET_STR(gui_cfg.ftp_list_options, cfg.ftp_list_options); GET_NUM(gui_cfg.en_cookie_max, cfg.cookies_max); GET_NUM(gui_cfg.base_level_label, cfg.base_level); GET_DOUBLE(gui_cfg.timeout_label, cfg.ctimeout); GET_NUM(gui_cfg.retry_label, cfg.nretry); GET_NUM(gui_cfg.redir_label, cfg.nredir); GET_NUM(gui_cfg.reget_label, cfg.nreget); GET_NUM(gui_cfg.sleep_label, cfg.sleep); GET_BOOL(gui_cfg.rsleep, cfg.rsleep); GET_NUM(gui_cfg.xloglen_label, cfg.xlogsize); GET_NUM(gui_cfg.bufsize, cfg.bufsize);#ifdef HAVE_MT GET_NUM(gui_cfg.nthr, cfg.nthr);#endif#ifdef HAVE_FSTATFS GET_NUM(gui_cfg.fs_quota, cfg.fs_quota);#endif GET_NUM(gui_cfg.file_quota, cfg.file_quota); GET_NUM(gui_cfg.trans_quota, cfg.trans_quota); GET_DOUBLE(gui_cfg.maxrate, cfg.maxrate); GET_DOUBLE(gui_cfg.minrate, cfg.minrate); GET_PATH(gui_cfg.slog_label, cfg.short_logfile); GET_BOOL(gui_cfg.gen_logname, cfg.gen_logname); GET_PATH(gui_cfg.log_label, cfg.logfile); log_start(cfg.logfile); GET_STR(gui_cfg.auth_label, cfg.name_auth); GET_STR(gui_cfg.pass_label, cfg.passwd_auth); GET_STR(gui_cfg.proxy_auth_label, cfg.http_proxy_user); GET_STR(gui_cfg.proxy_pass_label, cfg.http_proxy_pass); GET_STR(gui_cfg.ftp_proxy_user, cfg.ftp_proxy_user); GET_STR(gui_cfg.ftp_proxy_pass, cfg.ftp_proxy_pass); GET_BOOL(gui_cfg.send_from, cfg.send_from); GET_STR(gui_cfg.from_label, cfg.from); GET_NUM(gui_cfg.rollback_label, cfg.rollback); GET_NUM(gui_cfg.ddays_label, cfg.ddays); GET_NUM(gui_cfg.hash_size, cfg.hash_size); dlhash_resize(cfg.url_hash_tbl, cfg.hash_size); dlhash_resize(cfg.fn_hash_tbl, cfg.hash_size); GET_LIST(gui_cfg.alanglist, cfg.accept_lang); GET_LIST(gui_cfg.acharset_list, cfg.accept_chars); GET_LIST(gui_cfg.cookie_domain_list, cfg.cookies_disabled_domains); GET_STR(gui_cfg.tr_del_chr, cfg.tr_del_chr); GET_STR(gui_cfg.tr_str_s1, cfg.tr_str_s1); GET_STR(gui_cfg.tr_str_s2, cfg.tr_str_s2); GET_STR(gui_cfg.tr_chr_s1, cfg.tr_chr_s1); GET_STR(gui_cfg.tr_chr_s2, cfg.tr_chr_s2); GET_COMBO_IDX(gui_cfg.scheduling_strategie, cfg.scheduling_strategie); GET_PAT(gui_cfg.dont_touch_url_pattern, cfg.dont_touch_url_pattern);#ifdef HAVE_REGEX GET_REPAT(gui_cfg.dont_touch_url_rpattern, cfg.dont_touch_url_rpattern); GET_REPAT(gui_cfg.dont_touch_tag_rpattern, cfg.dont_touch_tag_rpattern); GET_BOOL(gui_cfg.remove_adv, cfg.remove_adv); ptr = cfg.advert_res; while(ptr) { re_free((re_entry *) ptr->data); ptr = dllist_remove_entry(ptr, ptr); } cfg.advert_res = NULL; GET_DLLIST(gui_cfg.advert_res, ptr); while(ptr) { re_entry *ree; ree = re_make((char *) ptr->data); if(ree) cfg.advert_res = dllist_append(cfg.advert_res, (dllist_t) ree); if(ptr->data) free((char *)ptr->data); ptr = dllist_remove_entry(ptr, ptr); } ptr = cfg.js_patterns; while(ptr) { re_free((re_entry *) ptr->data); ptr = dllist_remove_entry(ptr, ptr); } cfg.advert_res = NULL; GET_DLLIST(gui_cfg.js_patterns, ptr); while(ptr) { re_entry *ree; ree = re_make((char *) ptr->data); if(ree) cfg.js_patterns = dllist_append(cfg.js_patterns, (dllist_t) ree); if(ptr->data) free((char *)ptr->data); ptr = dllist_remove_entry(ptr, ptr); }#endif#ifdef GTK_FACE { int i; while(cfg.lfnames) { lfname_free((lfname *) cfg.lfnames->data); cfg.lfnames = dllist_remove_entry(cfg.lfnames, cfg.lfnames); } for(i = 0; i < GTK_CLIST(gui_cfg.rules_list)->rows; i++) { lfname *lfn; lfname_type tp; char *ld[3]; gtk_clist_get_text(GTK_CLIST(gui_cfg.rules_list), i, 0, &ld[0]); gtk_clist_get_text(GTK_CLIST(gui_cfg.rules_list), i, 1, &ld[1]); gtk_clist_get_text(GTK_CLIST(gui_cfg.rules_list), i, 2, &ld[2]);#ifdef HAVE_REGEX tp = (*ld[0] == 'F') ? LFNAME_FNMATCH : LFNAME_REGEX;#else tp = LFNAME_FNMATCH;#endif if((lfn = lfname_new(tp, ld[1], ld[2]))) cfg.lfnames = dllist_append(cfg.lfnames, (dllist_t) lfn); else { _MT_CFGSTAMP; UNLOCK_GCFG; return -1; } } }#endif GET_URLLIST(gui_cfg.url_list, cfg.request); GET_URLLIST(gui_cfg.formdata_list, cfg.formdata); GET_PROXYLIST(gui_cfg.http_proxy_list, cfg.http_proxy); GET_JST(gui_cfg.js_transform, cfg.js_transform); _MT_CFGSTAMP; UNLOCK_GCFG; return 0;}#endif /* I_FACE */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?