summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorepochqwert <epoch@hacking.allowed.org>2015-12-30 04:37:22 -0600
committerepochqwert <epoch@hacking.allowed.org>2015-12-30 04:37:22 -0600
commit1db8f7d916874f22c15df3121e3ec5ba5f7e7310 (patch)
tree128be6565fb3b598cc6828e85876f19fe7196234
parent4f05827c8b10d07cd9bc04424922a4dba4f728ab (diff)
downloaduritools-1db8f7d916874f22c15df3121e3ec5ba5f7e7310.tar.gz
uritools-1db8f7d916874f22c15df3121e3ec5ba5f7e7310.zip
enabled magic by default in cuturl.
made cuturl print empty string instead of trying to print nulls. matchurl was matching multiple times for things it shouldn't have and not cleaing out the url struct. Makefile now uses -Wall
-rw-r--r--Makefile4
-rw-r--r--cuturl.c18
-rw-r--r--matchurl.c19
3 files changed, 22 insertions, 19 deletions
diff --git a/Makefile b/Makefile
index 7257526..8c8e858 100644
--- a/Makefile
+++ b/Makefile
@@ -3,8 +3,8 @@ PREFIX=/usr/local
CC=gcc
all:
- $(CC) -o matchurl matchurl.c url.c
- $(CC) -o cuturl cuturl.c url.c
+ $(CC) -Wall -o matchurl matchurl.c url.c
+ $(CC) -Wall -o cuturl cuturl.c url.c
clean:
rm -f matchurl
diff --git a/cuturl.c b/cuturl.c
index 95d96ad..b2e7f84 100644
--- a/cuturl.c
+++ b/cuturl.c
@@ -8,6 +8,8 @@
#include "url.h"
+#define MAGIC
+
/*
schemes are case sensitive but cononicals are lower case.
domain is case insensitive. return it lowercased?
@@ -161,14 +163,14 @@ int main(int argc,char *argv[]) {
} else {
if(c) {
for(i=0;i<c;i++) {
- if(args[i]&F_SCHEME) printf("%s\n",u.scheme);
- if(args[i]&F_USERNAME) printf("%s\n",u.username);
- if(args[i]&F_PASSWORD) printf("%s\n",u.password);
- if(args[i]&F_DOMAIN) printf("%s\n",u.domain);
- if(args[i]&F_PORT) printf("%s\n",u.port);
- if(args[i]&F_PATH) printf("%s\n",u.path);
- if(args[i]&F_QUERY_STRING) printf("%s\n",u.query_string);
- if(args[i]&F_FRAGMENT_ID) printf("%s\n",u.fragment_id);
+ if(args[i]&F_SCHEME) printf("%s\n",AorB(u.scheme,""));
+ if(args[i]&F_USERNAME) printf("%s\n",AorB(u.username,""));
+ if(args[i]&F_PASSWORD) printf("%s\n",AorB(u.password,""));
+ if(args[i]&F_DOMAIN) printf("%s\n",AorB(u.domain,""));
+ if(args[i]&F_PORT) printf("%s\n",AorB(u.port,""));
+ if(args[i]&F_PATH) printf("%s\n",AorB(u.path,""));
+ if(args[i]&F_QUERY_STRING) printf("%s\n",AorB(u.query_string,""));
+ if(args[i]&F_FRAGMENT_ID) printf("%s\n",AorB(u.fragment_id,""));
}
} else {
printf("scheme: %s\n",u.scheme);
diff --git a/matchurl.c b/matchurl.c
index 1b9b88b..9029616 100644
--- a/matchurl.c
+++ b/matchurl.c
@@ -22,22 +22,23 @@ int main(int argc,char *argv[]) {
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<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);
- case 'u': if(u.username && !strcmp(u.username,argv[i+1])) printf("%s\n",copy);
- case 'k': if(u.password && !strcmp(u.password,argv[i+1])) printf("%s\n",copy);
- case 'd': if(u.domain && !strcmp(u.domain,argv[i+1])) printf("%s\n",copy);
+ 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 '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);
- case 'P': if(u.port && !strcmp(u.port,argv[i+1])) printf("%s\n",copy);
- case 'p': if(u.path && !strcmp(u.path,argv[i+1])) printf("%s\n",copy);
- case 'q': if(u.query_string && !strcmp(u.query_string,argv[i+1])) printf("%s\n",copy);
- case 'f': if(u.fragment_id && !strcmp(u.fragment_id,argv[i+1])) printf("%s\n",copy);
+ printf("D: %s\n",copy);
break;
default:
printf("unknown url part letter! '%c'\n",argv[i][0]);