r109096 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109095‎ | r109096 | r109097 >
Date:00:59, 17 January 2012
Author:rfaulk
Status:deferred
Tags:sopa 
Comment:
additional filter for custom traffic requests.
Modified paths:
  • /trunk/udplog/filters/SOPA-filter.c (added) (history)

Diff [purge]

Index: trunk/udplog/filters/SOPA-filter.c
@@ -0,0 +1,59 @@
 2+
 3+#include <stdio.h>
 4+#include <string.h>
 5+
 6+char * urls[] = {
 7+ "en.wikipedia.org/wiki/Special:CongressLookup?zip=",
 8+};
 9+
 10+main() {
 11+ char line[65534];
 12+ char *t = 0;
 13+
 14+ int i = 0;
 15+
 16+ //calculate these up-front.
 17+ int filtercount = sizeof(urls)/sizeof(*urls);
 18+ int url_length[filtercount];
 19+ for (i=0; i<filtercount; ++i){
 20+ url_length[i] = strlen(urls[i]);
 21+ }
 22+
 23+ while (!feof(stdin)) {
 24+ char *r;
 25+ r=fgets(line, 65534, stdin);
 26+
 27+ int pos=0;
 28+ t = line;
 29+
 30+ while(pos++<7) {
 31+ if (!t)
 32+ continue;
 33+ t = strstr(t, " ");
 34+ if (!t)
 35+ continue;
 36+ t++;
 37+ }
 38+ if (!t)
 39+ continue;
 40+
 41+ t = strstr(t, "://");
 42+ if (!t)
 43+ continue;
 44+ t += 3;
 45+
 46+ int found = 0;
 47+ for (i = 0; i < filtercount; ++i) {
 48+ if (strncmp(t, urls[i], url_length[i]) == 0) {
 49+ found = 1;
 50+ break;
 51+ }
 52+ }
 53+ if (found) {
 54+ printf("%s", line);
 55+ }
 56+
 57+ }
 58+
 59+}
 60+
Property changes on: trunk/udplog/filters/SOPA-filter.c
___________________________________________________________________
Added: svn:eol-style
161 + native

Status & tagging log