summaryrefslogtreecommitdiff
path: root/cuturl.c
diff options
context:
space:
mode:
authorepoch <epoch@hacking.allowed.org>2018-04-06 01:59:00 -0500
committerepoch <epoch@hacking.allowed.org>2018-04-06 01:59:00 -0500
commit1a8c2a28998114d24567ae6b04ee54297b0d5a07 (patch)
tree9927ac096d6e7941c9a1fd4de69c34f1204591fc /cuturl.c
parentf3e950dd4a925df1ded6334249ca43ecca5d4685 (diff)
downloaduritools-1a8c2a28998114d24567ae6b04ee54297b0d5a07.tar.gz
uritools-1a8c2a28998114d24567ae6b04ee54297b0d5a07.zip
added whole URL ability to cuturl
Diffstat (limited to 'cuturl.c')
-rw-r--r--cuturl.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/cuturl.c b/cuturl.c
index 1fd20b2..f1cbf42 100644
--- a/cuturl.c
+++ b/cuturl.c
@@ -32,14 +32,16 @@
#define F_PATH 1<<5
#define F_QUERY_STRING 1<<6
#define F_FRAGMENT_ID 1<<7
+#define F_WHOLE_URL 1<<8
-char *long_opts[]={"scheme","username","password","domain","port","path","query_string","fragment_id",0};
-char *short_opts[]={"s","u","k","d","P","p","q","f"};
+char *long_opts[]={"scheme","username","password","domain","port","path","query_string","fragment_id","URL",0};
+char *short_opts[]={"s","u","k","d","P","p","q","f","U"};
int main(int argc,char *argv[]) {
+ char *url;
char *name[2];
char *line=0;
- char args[256];
+ short args[256];//this needs to be a short to make room for the F_WHOLE_URL
int i,j,c=0;
int size=1024;
int status;
@@ -118,6 +120,7 @@ int main(int argc,char *argv[]) {
for(i=0;line[i] && line[i] != '\n' && line[i] != '\r';i++);
line[i]=0;
+ url=strdup(line);
urlfromline(&u,line);
// printf("scheme://username:password@domain:port/path?query_string#fragment_id\n\n");
@@ -172,6 +175,7 @@ int main(int argc,char *argv[]) {
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,""));
+ if(args[i]&F_WHOLE_URL) printf("%s\n",url);
}
} else {
printf("scheme: %s\n",u.scheme);
@@ -182,8 +186,10 @@ int main(int argc,char *argv[]) {
printf("path: %s\n",u.path);
printf("query_string: %s\n",u.query_string);
printf("fragment_id: %s\n",u.fragment_id);
+ printf("whole_url: %s\n",url);
}
}
+ free(url);//this is definitely malloc()d
if(malloced) {
free(line);
malloced=0;