comparison src/context.cpp @ 119:d9d2f8699621

uribl patch from Jeff Evans <jeffe@tricab.com>
author carl
date Sun, 12 Mar 2006 12:38:43 -0800
parents aa07452e641b
children c5cd1261394d
comparison
equal deleted inserted replaced
118:13fcb0c66763 119:d9d2f8699621
50 char *token_soft; 50 char *token_soft;
51 char *token_substitute; 51 char *token_substitute;
52 char *token_tld; 52 char *token_tld;
53 char *token_cctld; 53 char *token_cctld;
54 char *token_unknown; 54 char *token_unknown;
55 char *token_uribl;
55 char *token_verify; 56 char *token_verify;
56 char *token_white; 57 char *token_white;
57 58
58 char *token_myhostname; 59 char *token_myhostname;
59 #ifndef HOST_NAME_MAX 60 #ifndef HOST_NAME_MAX
484 verify_host = NULL; 485 verify_host = NULL;
485 env_from_default = (parent) ? token_inherit : token_unknown; 486 env_from_default = (parent) ? token_inherit : token_unknown;
486 content_filtering = (parent) ? parent->content_filtering : false; 487 content_filtering = (parent) ? parent->content_filtering : false;
487 content_suffix = NULL; 488 content_suffix = NULL;
488 content_message = NULL; 489 content_message = NULL;
490 uribl_suffix = NULL;
491 uribl_message = NULL;
489 host_limit = (parent) ? parent->host_limit : 0; 492 host_limit = (parent) ? parent->host_limit : 0;
490 host_limit_message = NULL; 493 host_limit_message = NULL;
491 host_random = (parent) ? parent->host_random : false; 494 host_random = (parent) ? parent->host_random : false;
492 tag_limit = (parent) ? parent->tag_limit : 0; 495 tag_limit = (parent) ? parent->tag_limit : 0;
493 tag_limit_message = NULL; 496 tag_limit_message = NULL;
613 if (!content_suffix && parent) return parent->get_content_suffix(); 616 if (!content_suffix && parent) return parent->get_content_suffix();
614 return content_suffix; 617 return content_suffix;
615 } 618 }
616 619
617 620
621 char* CONTEXT::get_uribl_suffix() {
622 if (!uribl_suffix && parent) return parent->get_uribl_suffix();
623 return uribl_suffix;
624 }
625
626
618 char* CONTEXT::get_content_message() { 627 char* CONTEXT::get_content_message() {
619 if (!content_message && parent) return parent->get_content_message(); 628 if (!content_message && parent) return parent->get_content_message();
620 return content_message; 629 return content_message;
630 }
631
632
633 char* CONTEXT::get_uribl_message() {
634 if (!uribl_message && parent) return parent->get_uribl_message();
635 return uribl_message;
621 } 636 }
622 637
623 638
624 string_set& CONTEXT::get_content_host_ignore() { 639 string_set& CONTEXT::get_content_host_ignore() {
625 if (content_host_ignore.empty() && parent) return parent->get_content_host_ignore(); 640 if (content_host_ignore.empty() && parent) return parent->get_content_host_ignore();
689 704
690 if (content_filtering) { 705 if (content_filtering) {
691 printf("%s content on { \n", indent, env_from_default); 706 printf("%s content on { \n", indent, env_from_default);
692 if (content_suffix) { 707 if (content_suffix) {
693 printf("%s filter %s \"%s\"; \n", indent, content_suffix, content_message); 708 printf("%s filter %s \"%s\"; \n", indent, content_suffix, content_message);
709 }
710 if (uribl_suffix) {
711 printf("%s uribl %s \"%s\"; \n", indent, uribl_suffix, uribl_message);
694 } 712 }
695 if (!content_host_ignore.empty()) { 713 if (!content_host_ignore.empty()) {
696 printf("%s ignore { \n", indent); 714 printf("%s ignore { \n", indent);
697 for (string_set::iterator i=content_host_ignore.begin(); i!=content_host_ignore.end(); i++) { 715 for (string_set::iterator i=content_host_ignore.begin(); i!=content_host_ignore.end(); i++) {
698 printf("%s %s; \n", indent, *i); 716 printf("%s %s; \n", indent, *i);
887 if (have == token_filter) { 905 if (have == token_filter) {
888 char *suffix = tok.next(); 906 char *suffix = tok.next();
889 char *messag = tok.next(); 907 char *messag = tok.next();
890 me.set_content_suffix(suffix); 908 me.set_content_suffix(suffix);
891 me.set_content_message(messag); 909 me.set_content_message(messag);
910 if (!tsa(tok, token_semi)) return false;
911 }
912 else if (have == token_uribl) {
913 char *suffix = tok.next();
914 char *messag = tok.next();
915 me.set_uribl_suffix(suffix);
916 me.set_uribl_message(messag);
892 if (!tsa(tok, token_semi)) return false; 917 if (!tsa(tok, token_semi)) return false;
893 } 918 }
894 else if (have == token_ignore) { 919 else if (have == token_ignore) {
895 if (!tsa(tok, token_lbrace)) return false; 920 if (!tsa(tok, token_lbrace)) return false;
896 while (true) { 921 while (true) {
1280 token_semi = register_string(";"); 1305 token_semi = register_string(";");
1281 token_soft = register_string("soft"); 1306 token_soft = register_string("soft");
1282 token_substitute = register_string("substitute"); 1307 token_substitute = register_string("substitute");
1283 token_tld = register_string("tld"); 1308 token_tld = register_string("tld");
1284 token_unknown = register_string("unknown"); 1309 token_unknown = register_string("unknown");
1310 token_uribl = register_string("uribl");
1285 token_verify = register_string("verify"); 1311 token_verify = register_string("verify");
1286 token_white = register_string("white"); 1312 token_white = register_string("white");
1287 1313
1288 if (gethostname(myhostname, HOST_NAME_MAX+1) != 0) { 1314 if (gethostname(myhostname, HOST_NAME_MAX+1) != 0) {
1289 strncpy(myhostname, "localhost", HOST_NAME_MAX+1); 1315 strncpy(myhostname, "localhost", HOST_NAME_MAX+1);