Revision: 14755
Author: adrian.chadd
Date: Tue Aug 10 09:25:30 2010
Log:
* make debugging optional; disable by default
* fix rule hit/miss to actually work!
* add in refresh-if-mtime-changed.
http://code.google.com/p/lusca-cache/source/detail?r=14755
Modified:
/branches/LUSCA_HEAD/helpers/external_acl/regex/regex.c
=======================================
--- /branches/LUSCA_HEAD/helpers/external_acl/regex/regex.c Tue Aug 10
06:09:05 2010
+++ /branches/LUSCA_HEAD/helpers/external_acl/regex/regex.c Tue Aug 10
09:25:30 2010
@@ -21,6 +21,8 @@
#define MAXLINE 8192
#define RELOAD_TIME 5
+static int debug = 0;
+
struct _regex_entry {
int linenum;
const char *entry;
@@ -79,6 +81,7 @@
r->linenum = linenum;
r->re_flags = re_flags;
+ if (debug) fprintf(stderr, "compiling: '%s'\n", entry);
i = regcomp(&r->re, entry, re_flags);
if (i) { /* error condition */
perror("regcomp"); /* XXX should output i instead */
@@ -172,9 +175,10 @@
int r, i;
for (i = 0; i < re_list.count; i++) {
+ if (debug) fprintf(stderr, "checking '%s' against '%s'\n", url,
re_list.r[i].entry);
r = regexec(&re_list.r[i].re, url, 0, NULL, 0);
if (r == 0) { /* Success */
- return r;
+ return i;
}
}
return 0;
@@ -213,7 +217,7 @@
while (!feof(stdin)) {
if (time(NULL) - ts > RELOAD_TIME) {
- fprintf(stderr, "re-check\n");
+ if (debug) fprintf(stderr, "re-check\n");
ts = time(NULL);
/* re-stat the file */
if (stat(fn, &sb) < 0) {
@@ -227,11 +231,12 @@
if (! fgets(buf, HELPERBUFSZ, stdin))
break;
trim_trailing_crlf(buf);
- fprintf(stderr, "read: %s\n", buf);
+ if (debug) fprintf(stderr, "read: %s\n", buf);
/* XXX should break out JUST the URL here! */
+ /* XXX and the URL should be unescaped and normalised properly
*/
r = re_lookup(buf);
if (r > 0) {
- fprintf(stderr, "HIT: line %d; rule %s\n",
+ if (debug) fprintf(stderr, "HIT: line %d; rule %s\n",
re_list.r[r].linenum, re_list.r[r].entry);
printf("OK\n");
} else {
--
You received this message because you are subscribed to the Google Groups
"lusca-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/lusca-commit?hl=en.