diff options
Diffstat (limited to 'matchurl.c')
-rw-r--r-- | matchurl.c | 22 |
1 files changed, 12 insertions, 10 deletions
@@ -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; } |