aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorepochqwert <epoch@hacking.allowed.org>2015-04-21 13:41:40 -0500
committerepochqwert <epoch@hacking.allowed.org>2015-04-21 13:41:40 -0500
commit318b3220d191011bb9132efd4dbd5e6fb467b4e7 (patch)
tree1b0e7a29d15f79743c8559652432658423046a38 /src
parent4bdfc44f4681ef322378e614a409d5acc4d6586c (diff)
downloadmisc-318b3220d191011bb9132efd4dbd5e6fb467b4e7.tar.gz
misc-318b3220d191011bb9132efd4dbd5e6fb467b4e7.zip
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.)
Diffstat (limited to 'src')
-rw-r--r--src/bin/cuturl.c38
1 files changed, 27 insertions, 11 deletions
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")));