diff src/context.cpp @ 117:aa07452e641b

uribl patch from Jeff Evans <jeffe@tricab.com>
author carl
date Sun, 12 Mar 2006 10:15:39 -0800
parents 6ac7ba4a8312
children d9d2f8699621
line wrap: on
line diff
--- a/src/context.cpp	Sun Jan 08 10:27:24 2006 -0800
+++ b/src/context.cpp	Sun Mar 12 10:15:39 2006 -0800
@@ -50,6 +50,7 @@
 char *token_soft;
 char *token_substitute;
 char *token_tld;
+char *token_cctld;
 char *token_unknown;
 char *token_verify;
 char *token_white;
@@ -445,12 +446,12 @@
 
 CONTEXTP CONFIG::find_context(char *to) {
 	context_map::iterator i = env_to.find(to);
-	if (i != env_to.end()) return (*i).second;		// found user@domain.tld key
+	if (i != env_to.end()) return (*i).second;		// found user@domain key
 	char *x = strchr(to, '@');
 	if (x) {
 		x++;
 		i = env_to.find(x);
-		if (i != env_to.end()) return (*i).second;	// found domain.tld key
+		if (i != env_to.end()) return (*i).second;	// found domain key
 		char y = *x;
 		*x = '\0';
 		i = env_to.find(to);
@@ -553,13 +554,13 @@
 char *CONTEXT::find_from(char *from) {
 	char *rc = token_inherit;
 	string_map::iterator i = env_from.find(from);
-	if (i != env_from.end()) rc = (*i).second;	// found user@domain.tld key
+	if (i != env_from.end()) rc = (*i).second;	// found user@domain key
 	else {
 		char *x = strchr(from, '@');
 		if (x) {
 			x++;
 			i = env_from.find(x);
-			if (i != env_from.end()) rc = (*i).second;	// found domain.tld key
+			if (i != env_from.end()) rc = (*i).second;	// found domain key
 			else {
 				char y = *x;
 				*x = '\0';
@@ -577,12 +578,12 @@
 
 CONTEXTP CONTEXT::find_context(char *from) {
 	context_map::iterator i = env_from_context.find(from);
-	if (i != env_from_context.end()) return (*i).second;		// found user@domain.tld key
+	if (i != env_from_context.end()) return (*i).second;		// found user@domain key
 	char *x = strchr(from, '@');
 	if (x) {
 		x++;
 		i = env_from_context.find(x);
-		if (i != env_from_context.end()) return (*i).second;	// found domain.tld key
+		if (i != env_from_context.end()) return (*i).second;	// found domain key
 		char y = *x;
 		*x = '\0';
 		i = env_from_context.find(from);
@@ -626,6 +627,11 @@
 }
 
 
+string_set& CONTEXT::get_content_cctlds() {
+	if (content_cctlds.empty() && parent) return parent->get_content_cctlds();
+	return content_cctlds;
+}
+
 string_set& CONTEXT::get_content_tlds() {
 	if (content_tlds.empty() && parent) return parent->get_content_tlds();
 	return content_tlds;
@@ -693,6 +699,14 @@
 			}
 			printf("%s         }; \n", indent);
 		}
+		if (!content_cctlds.empty()) {
+			printf("%s         cctld { \n", indent);
+			printf("%s             ", indent);
+			for (string_set::iterator i=content_cctlds.begin(); i!=content_cctlds.end(); i++) {
+				printf("%s; ", *i);
+			}
+			printf("\n%s         }; \n", indent);
+		}
 		if (!content_tlds.empty()) {
 			printf("%s         tld { \n", indent);
 			printf("%s             ", indent);
@@ -887,6 +901,16 @@
 			}
 			if (!tsa(tok, token_semi)) return false;
 		}
+		else if (have == token_cctld) {
+			if (!tsa(tok, token_lbrace)) return false;
+			while (true) {
+				char *have = tok.next();
+				if (!have) break;
+				if (have == token_rbrace) break;  // done
+				me.add_cctld(have);
+			}
+			if (!tsa(tok, token_semi)) return false;
+		}
 		else if (have == token_tld) {
 			if (!tsa(tok, token_lbrace)) return false;
 			while (true) {
@@ -1228,6 +1252,7 @@
 //
 void token_init() {
 	token_black 	 = register_string("black");
+	token_cctld 	 = register_string("cctld");
 	token_content	 = register_string("content");
 	token_context	 = register_string("context");
 	token_dccfrom	 = register_string("dcc_from");