From a36652959e52e8c810b7d2d76a283b2ae9718d96 Mon Sep 17 00:00:00 2001 From: epochqwert Date: Thu, 23 Apr 2015 04:53:35 -0500 Subject: elapsedtime handles partial seconds better unescape now handles multiple lines from stdin clump can now have an optional argument to specify input separator cuturl can now take compressed short options. (like: cuturl -dPs) filemon... I don't remember. just reformatted it looks like. ipconvert. looks like I added explainations before output. normalpath now uses getenv("PWD") instead of getcwd() so you can pick what you want to be the base for relative paths. urcdump... nothing I guess. probably a space or something dumb. httpd... more environment variables set for CGIs --- src/bin/cuturl.c | 95 +++++++++++++++++++++++++++----------------------------- 1 file changed, 46 insertions(+), 49 deletions(-) (limited to 'src/bin/cuturl.c') diff --git a/src/bin/cuturl.c b/src/bin/cuturl.c index d706fd3..40b7766 100644 --- a/src/bin/cuturl.c +++ b/src/bin/cuturl.c @@ -2,9 +2,10 @@ #include #include #include + /* schemes are case sensitive but cononicals are lower case. - domain is case insensitive. return it lowercased. + domain is case insensitive. return it lowercased? port is optional and in decimal path scheme://username:password@domain:port/path?query_string#fragment_id @@ -14,23 +15,6 @@ scheme, username, password, port, path, query_string, fragment_id */ -/* -#define DEFAULT_SCHEME "http" -#define DEFAULT_USERNAME "anonymous" -#define DEFAULT_PASSWORD "anonymous" -#define DEFAULT_PORT "80" -#define DEFAULT_QUERY_STRING "" -#define DEFAULT_FRAGMENT_ID "" - -#define DEFAULT_SCHEME "DEFAULT" -#define DEFAULT_USERNAME "DEFAULT" -#define DEFAULT_PASSWORD "DEFAULT" -#define DEFAULT_PORT "DEFAULT" -#define DEFAULT_PATH "DEFAULT" -#define DEFAULT_QUERY_STRING "DEFAULT" -#define DEFAULT_FRAGMENT_ID "DEFAULT" -*/ - #define AorB(a,b) ((a)?(a):(b)) #define F_SCHEME 1<<0 @@ -46,7 +30,7 @@ char *long_opts[]={"scheme","username","password","domain","port","path","query_ char *short_opts[]={"s","u","k","d","P","p","q","f"}; int main(int argc,char *argv[]) { - char *line; + char *line=0; char *scheme=0; char *username=0; char *password=0; @@ -56,11 +40,11 @@ int main(int argc,char *argv[]) { char *query_string=0; char *fragment_id=0; char sport[10]; + char args[256]; struct servent *serv; - //exactly 8 parts! let's store that in a byte. - unsigned char flags=0; - int i; + int i,j,c=0; int size=1024; + char fixme=0; char using_stdin=1; char malloced=0; if(argc > 1) { @@ -74,6 +58,8 @@ int main(int argc,char *argv[]) { printf("To set default values use environment variables like: CUTURL_[OPTION]\n"); return 2; } + argc--; + argv++; } while(1) { scheme=0; @@ -84,24 +70,33 @@ int main(int argc,char *argv[]) { path=0; query_string=0; fragment_id=0; - if(!using_stdin) flags=0; - if(argc > 1) { - for(argc--,argv++;argc>0;argc--,argv++) { + if(!using_stdin) c=0; + if(argc >= 1) { + for(;argc>0;argc--,argv++) { for(i=0;long_opts[i];i++) { if(!strncmp(*argv,"--",2)) { if(!strcmp(*argv+2,long_opts[i])) { - flags|=(1<s_port)); port=AorB(port,AorB(getenv("CUTURL_PORT"),(serv?sport:"DEFAULT"))); - //port=AorB(port,AorB(getenv("CUTURL_PORT"),"DEFAULT")); - - path=AorB(path,AorB(getenv("CUTURL_PATH"),"DEFAULT")); query_string=AorB(query_string,AorB(getenv("CUTURL_QUERY_STRING"),"DEFAULT")); fragment_id=AorB(fragment_id,AorB(getenv("CUTURL_FRAGMENT_ID"),"DEFAULT")); - if(flags) { - if(flags&F_SCHEME) printf("%s\n",scheme); - if(flags&F_USERNAME) printf("%s\n",username); - if(flags&F_PASSWORD) printf("%s\n",password); - if(flags&F_DOMAIN) printf("%s\n",domain); - if(flags&F_PORT) printf("%s\n",port); - if(flags&F_PATH) printf("%s\n",path); - if(flags&F_QUERY_STRING) printf("%s\n",query_string); - if(flags&F_FRAGMENT_ID) printf("%s\n",fragment_id); + if(c) { + for(i=0;i