[mw-devel] MW3 r1072 - trunk/src

arthur at sucs.org arthur at sucs.org
Thu Mar 12 18:25:38 GMT 2009


Author: arthur
Date: 2009-03-12 18:25:37 +0000 (Thu, 12 Mar 2009)
New Revision: 1072

Modified:
   trunk/src/log.c
Log:
some extra regex matches, refs #38


Modified: trunk/src/log.c
===================================================================
--- trunk/src/log.c	2009-03-12 16:45:55 UTC (rev 1071)
+++ trunk/src/log.c	2009-03-12 18:25:37 UTC (rev 1072)
@@ -59,18 +59,22 @@
 	char *	regex;	/* the pattern */
 	int   	regflags; /* compile flags */
 	regex_t	*patt; /* compiled version */
-	enum { END=0, URL, FLAG, IGNORE } type;
+	enum { END=0, URL, FLAG, IGNORE, NOLOG } type;
 	uint32_t flags;
 };
 
 #define URLFLAG_NSFW	0x0001
 
 struct uripatt urilist[] = {
-	{"^http:", 		REG_ICASE, NULL, URL,    0},
-	{"^https:", 		REG_ICASE, NULL, URL,    0},
+	{"^http://$", 		REG_ICASE, NULL, IGNORE, 0},
+	{"^https://$", 		REG_ICASE, NULL, IGNORE, 0},
+	{"^http://", 		REG_ICASE, NULL, URL,    0},
+	{"^https://", 		REG_ICASE, NULL, URL,    0},
 	{"^www\\.", 		REG_ICASE, NULL, URL,    0},
+	{"^[[:alpha:].]+\\.(com|org|net|gov|(co|org|net|gov)\\.uk)", 	REG_ICASE|REG_EXTENDED, NULL, URL,    0},
 	{"nsfw", 		REG_ICASE, NULL, FLAG,   URLFLAG_NSFW},
-	{"^-log", 		REG_ICASE, NULL, IGNORE, 0},
+	{"^-log", 		REG_ICASE, NULL, NOLOG, 0},
+	{"^(-log)$", 		REG_ICASE, NULL, NOLOG, 0},
 	{ NULL, 0, NULL, END, 0 }
 };
 
@@ -106,6 +110,10 @@
 			}
 			/* compare the pattern and store a hit */
 			if (regexec(u->patt, token, 0, NULL, 0) == 0) {
+				if (u->type == IGNORE) {
+					/* skip this word */
+					break;
+				}
 				if (u->type == URL) {
 					/* found a url */
 					/*printf("Found url: '%s'\n", token); */
@@ -115,7 +123,7 @@
 					/* printf("Found flag: '%s' -> %x\n", token, u->flags); */
 					flags |= u->flags;
 				}
-				if (u->type == IGNORE) {
+				if (u->type == NOLOG) {
 					/* ignore whole line */
 					/* printf("IGNORE LINE '%s'\n", token); */
 					free(text);
@@ -217,6 +225,9 @@
 	snprintf(path,sizeof(path), "http://feeds.delicious.com/v2/json/urlinfo/%s", md);
 	curl_easy_setopt(c, CURLOPT_URL, path);
 	curl_easy_setopt(c, CURLOPT_NOPROGRESS, 1);
+	curl_easy_setopt(c, CURLOPT_AUTOREFERER, 1);
+	curl_easy_setopt(c, CURLOPT_FOLLOWLOCATION, 1);
+	curl_easy_setopt(c, CURLOPT_MAXREDIRS, 5);
 	curl_easy_setopt(c, CURLOPT_WRITEFUNCTION, urldata);
 	curl_easy_setopt(c, CURLOPT_WRITEDATA, &deli);
 	curl_easy_perform(c);





More information about the mw-devel mailing list