summaryrefslogtreecommitdiff
path: root/urijoin.c
diff options
context:
space:
mode:
authorepoch <epoch@hacking.allowed.org>2019-04-22 23:34:14 -0500
committerepoch <epoch@hacking.allowed.org>2019-04-22 23:34:14 -0500
commitcf96b590cf27a4b58fc744a983839b31efc445ca (patch)
tree576a9e328d2fe13bf68ca3ca3965012346dec513 /urijoin.c
parent97c0e839fea71df6caefca601fdc34469fd7b2b5 (diff)
downloaduritools-cf96b590cf27a4b58fc744a983839b31efc445ca.tar.gz
uritools-cf96b590cf27a4b58fc744a983839b31efc445ca.zip
rewrote urijoin.c
Diffstat (limited to 'urijoin.c')
-rw-r--r--urijoin.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/urijoin.c b/urijoin.c
new file mode 100644
index 0000000..569f575
--- /dev/null
+++ b/urijoin.c
@@ -0,0 +1,36 @@
+#define _XOPEN_SOURCE 500
+#include <string.h>
+#include <stdio.h>
+#include "uri.h"
+
+int main(int argc,char *argv[]) {
+ struct uri *u=malloc(sizeof(struct uri));
+ int i;
+ char key[1024];//fuck if I know
+ char *value;
+ memset(u,0,sizeof(struct uri));
+ char *parts[]={"scheme:","username:","password:","domain:","port:","path:","query_string:","fragment_id:"};
+ while(fgets(key,sizeof(key),stdin)) {
+ if(strchr(key,'\n')) *strchr(key,'\n')=0;
+ if((value=strchr(key,' '))) {
+ *value=0;
+ value++;
+// fprintf(stderr,"read: %s %s\n",key,value);
+ for(i=0;i<8;i++) {
+ if(!strcmp(key,parts[i])) {
+ if(u->A[i]) free(u->A[i]);
+ u->A[i]=strdup(value);
+ break;
+ }
+ }
+ if(i==8) {
+ fprintf(stderr,"urijoin: unknown uri portion: '%s'\n",key);
+ //return 1;//bail early instead of pretending it makes sense.
+ }
+ } else {
+ fprintf(stderr,"urijoin: malformed line. missing a space: '%s'\n",key);
+ }
+ }
+ printf("%s\n",linefromuri(u));
+ return 0;
+}