summaryrefslogtreecommitdiff
path: root/matchurl.c
diff options
context:
space:
mode:
authorepochqwert <epoch@hacking.allowed.org>2016-05-28 09:40:08 +0000
committerepochqwert <epoch@hacking.allowed.org>2016-05-28 09:40:08 +0000
commit6bfda18041dffeac373ad799b22b0aceaaf6039d (patch)
tree118dfbec6ea6187c3e07d7e154ac0e2f16022696 /matchurl.c
parent88579ab91621abc3a9a6f31c132de50510aca777 (diff)
downloaduritools-6bfda18041dffeac373ad799b22b0aceaaf6039d.tar.gz
uritools-6bfda18041dffeac373ad799b22b0aceaaf6039d.zip
fuck if I know. I'm tired. moved the magic stuff to url.c.
Diffstat (limited to 'matchurl.c')
-rw-r--r--matchurl.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/matchurl.c b/matchurl.c
index 396f829..9be390f 100644
--- a/matchurl.c
+++ b/matchurl.c
@@ -7,6 +7,7 @@
int main(int argc,char *argv[]) {
int i;
+ int ret=1;
struct url u;
char *line=malloc(LINE_LENGTH);
char copy[LINE_LENGTH];
@@ -28,24 +29,25 @@ int main(int argc,char *argv[]) {
for(i=1;i<argc;i+=2) {
if(argv[i][0] == '-') argv[i]++;
switch(argv[i][0]) {
- case 's': if(u.scheme && !strcmp(u.scheme,argv[i+1])) printf("%s\n",copy); break;
- case 'u': if(u.username && !strcmp(u.username,argv[i+1])) printf("%s\n",copy); break;
- case 'k': if(u.password && !strcmp(u.password,argv[i+1])) printf("%s\n",copy); break;
- case 'd': if(u.domain && !strcmp(u.domain,argv[i+1])) printf("%s\n",copy); break;
- case 'P': if(u.port && !strcmp(u.port,argv[i+1])) printf("%s\n",copy); break;
- case 'p': if(u.path && !strcmp(u.path,argv[i+1])) printf("%s\n",copy); break;
- case 'q': if(u.query_string && !strcmp(u.query_string,argv[i+1])) printf("%s\n",copy); break;
- case 'f': if(u.fragment_id && !strcmp(u.fragment_id,argv[i+1])) printf("%s\n",copy); break;
+ case 's': if(u.scheme && !strcmp(u.scheme,argv[i+1])) {printf("%s\n",copy); ret=0;} break;
+ case 'u': if(u.username && !strcmp(u.username,argv[i+1])) {printf("%s\n",copy); ret=0;} break;
+ case 'k': if(u.password && !strcmp(u.password,argv[i+1])) {printf("%s\n",copy); ret=0;} break;
+ case 'd': if(u.domain && !strcmp(u.domain,argv[i+1])) {printf("%s\n",copy); ret=0;} break;
+ case 'P': if(u.port && !strcmp(u.port,argv[i+1])) {printf("%s\n",copy); ret=0;} break;
+ case 'p': if(u.path && !strcmp(u.path,argv[i+1])) {printf("%s\n",copy); ret=0;} break;
+ case 'q': if(u.query_string && !strcmp(u.query_string,argv[i+1])) {printf("%s\n",copy); ret=0;} break;
+ case 'f': if(u.fragment_id && !strcmp(u.fragment_id,argv[i+1])) {printf("%s\n",copy); ret=0;} break;
case 'D':
if(u.domain && strlen(u.domain) >= 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 0;
+ return ret;
}
}
}
- return 0;
+ return ret;
}