From 318b3220d191011bb9132efd4dbd5e6fb467b4e7 Mon Sep 17 00:00:00 2001 From: epochqwert Date: Tue, 21 Apr 2015 13:41:40 -0500 Subject: made dcchelper a script instead of a c program. ipdist which gives shortest distance based on whob's output of lat and lon nc.* are minmal versions of a netcat like program written in Perl. rfc is a script for downloading and viewing RFCs tpb.sh is for pulling magnet links from tpb search results. cuturl got an upgrade to better handle scheme:?query_string type URLs. (URN? URI? fuck if I know.) --- src/bin/cuturl.c | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) (limited to 'src/bin/cuturl.c') diff --git a/src/bin/cuturl.c b/src/bin/cuturl.c index f8b02c7..d706fd3 100644 --- a/src/bin/cuturl.c +++ b/src/bin/cuturl.c @@ -175,17 +175,25 @@ int main(int argc,char *argv[]) { } if(domain) { - if(strchr(domain,']')) { + if(strchr(domain,']')) {//the end of an IPv6 address if(strchr(strchr(domain,']'),':')) { port=strchr(strchr(domain,']'),':'); - *port=0; - port++; + if(port[1] == '?') {//for magnet links + port=0; + } else { + *port=0; + port++; + } } } else { if(strchr(domain,':')) { port=strchr(domain,':'); - *port=0; - port++; + if(port[1] == '?') {//for magnet links + port=0; + } else { + *port=0; + port++; + } } } } @@ -198,23 +206,31 @@ int main(int argc,char *argv[]) { } } - if(!scheme && username) { + if(strchr(domain,':') && !strchr(domain,']')) {//for scheme:?query_string + scheme=domain; + *strchr(scheme,':')=0; + domain=0; + } + + if(!scheme && username) {//for mailto: scheme=username; username=password; password=0; } - if(!domain) { - fprintf(stderr,"how the fuck is this supposed to be a URL?\n"); - return 1; - } +// before deciding to also handle magnets +// if(!domain) { +// fprintf(stderr,"how the fuck is this supposed to be a URL?\n"); +// return 1; +// } + // printf("scheme://username:password@domain:port/path?query_string#fragment_id\n\n"); //let's set them to what'll get printed now... scheme=AorB(scheme,AorB(getenv("CUTURL_SCHEME"),"DEFAULT")); username=AorB(username,AorB(getenv("CUTURL_USERNAME"),"DEFAULT")); password=AorB(password,AorB(getenv("CUTURL_PASSWORD"),"DEFAULT")); - //domain=domain; doesn't change. heh. + domain=AorB(domain,AorB(getenv("CURURL_DOMAIN"),"DEFAULT")); serv=getservbyname(scheme,strcmp(scheme,"udp")?"tcp":"udp"); if(serv) snprintf(sport,sizeof(sport)-1,"%d",ntohs(serv->s_port)); port=AorB(port,AorB(getenv("CUTURL_PORT"),(serv?sport:"DEFAULT"))); -- cgit v1.2.3