From 6f402e2d2f052972886712f60d592684c8671982 Mon Sep 17 00:00:00 2001 From: epoch Date: Sat, 20 Apr 2019 05:32:27 -0500 Subject: rebased on an old copy of this repo. renamed everything. rewrote the uri parser. added uricmp. wew. --- matchurl.c | 69 -------------------------------------------------------------- 1 file changed, 69 deletions(-) delete mode 100644 matchurl.c (limited to 'matchurl.c') diff --git a/matchurl.c b/matchurl.c deleted file mode 100644 index 47a2a20..0000000 --- a/matchurl.c +++ /dev/null @@ -1,69 +0,0 @@ -#include -#include -#include -#include "url.h" - -#define LINE_LENGTH 1024 - -int match(char negate,char *part,char *arg) { - if(negate) { - if(part == 0) return 1;//we found that the part isn't here! - } else { - if(part) { - if(!strcmp(part,arg)) return 1; - } - } - return 0; -} - -int main(int argc,char *argv[]) { - int i; - int ret=1; - struct url u; - char negate=0; - char *line=malloc(LINE_LENGTH); - char copy[LINE_LENGTH]; - if(argc < 2) { - printf("usage: matchurl [-][n][s|u|k|d|D|P|p|q|f] [string]\n"); - printf("scheme://username:password@domain:port/path?query_string#fragment_id\n"); - printf("s://u:k@d:P/p?q#f\n"); - printf("The D flag is special. it matches its argument against the last bytes of the input url's domain.\n"); - printf("This allows matching of subdomains, like `echo epoch.ano | matchurl -D ano` would match.\n"); - printf("the 'n' flag can be put before any of the other flags to check for a missing.\n"); - return 1; - } - while(fgets(line,LINE_LENGTH-1,stdin)) { - if(strchr(line,'\r')) *strchr(line,'\r')=0; - if(strchr(line,'\n')) *strchr(line,'\n')=0; - strcpy(copy,line); - memset(&u,0,sizeof(u)); - urlfromline(&u,line); - //use the character in argv[1] to match stdin against argv[2]. if match print whole line. - for(i=1;i= strlen(argv[i+1]) && !strncmp(u.domain+strlen(u.domain)-strlen(argv[i+1]),argv[i+1],strlen(argv[i+1]))) - printf("%s\n",copy); - ret=0; - break; - default: - printf("unknown url part letter! '%c'\n",argv[i][0]); - return ret; - } - } - } - return ret; -} - -- cgit v1.2.3