diff options
author | Epoch Qwert <epoch@53flpnlls43fcguy.onion> | 2014-10-13 20:54:28 -0500 |
---|---|---|
committer | Epoch Qwert <epoch@53flpnlls43fcguy.onion> | 2014-10-13 20:54:28 -0500 |
commit | 1852f2d7d63c39d0fd97a2774d1bd16bf53ec67d (patch) | |
tree | 69bc1a71b839857e6b841862b74aa3c0b56b860c | |
download | misc-1852f2d7d63c39d0fd97a2774d1bd16bf53ec67d.tar.gz misc-1852f2d7d63c39d0fd97a2774d1bd16bf53ec67d.zip |
initial commit. collected some tools I had laying around.
-rwxr-xr-x | nocompile/XuntilY | 18 | ||||
-rwxr-xr-x | rebuild.sh | 10 | ||||
-rw-r--r-- | src/dcchelper.c | 20 | ||||
-rw-r--r-- | src/gethostbyname.c | 16 | ||||
-rw-r--r-- | src/pad.c | 32 |
5 files changed, 96 insertions, 0 deletions
diff --git a/nocompile/XuntilY b/nocompile/XuntilY new file mode 100755 index 0000000..f6cc672 --- /dev/null +++ b/nocompile/XuntilY @@ -0,0 +1,18 @@ +#!/usr/pkg/bin/perl +$r=$ARGV[0]; +$s=$ARGV[1]; +$m=0; +$count=$ARGV[2]?$ARGV[2]:1; +for(;$l=<stdin> and $count > 0;) { + if($m == 0) { + if($l =~ $r) { + $m=1; + print $l; + next; + }} + if($m == 1) { + print $l; + if($l =~ $s) { + $m=0; + $count--; +}}} diff --git a/rebuild.sh b/rebuild.sh new file mode 100755 index 0000000..84f7cff --- /dev/null +++ b/rebuild.sh @@ -0,0 +1,10 @@ +#!/bin/sh +for i in src/*.c;do + out=$(basename $i | cut -d. -f1) + gcc -o bin/$out $i + cp bin/* /usr/local/bin/ +done +for i in nocompile/*;do + out=$(basename $i) + cp $i /usr/local/bin/$out +done diff --git a/src/dcchelper.c b/src/dcchelper.c new file mode 100644 index 0000000..bf8f28b --- /dev/null +++ b/src/dcchelper.c @@ -0,0 +1,20 @@ +#include <stdio.h> + +int main(int argc,char *argv[]) { + char *wanip; + if(argc < 2) { + return printf("usage: %s [IP]\n",argv[0]); + } + if(!strncmp(argv[1],"127.",4)) { + wanip="127.0.0.1"; + } + else if(!strncmp(argv[1],"1.",2)) { + wanip="1.41.41.1"; + } + else if(!strncmp(argv[1],"192.168.0.",10)) { + wanip="192.168.0.2"; + } else { + wanip="98.159.69.172"; + } + return printf("%u\n",htonl(inet_addr(wanip))); +} diff --git a/src/gethostbyname.c b/src/gethostbyname.c new file mode 100644 index 0000000..646bf0a --- /dev/null +++ b/src/gethostbyname.c @@ -0,0 +1,16 @@ +#include <stdio.h> +#include <netdb.h> + +int main(int argc,char *argv[]) { + int i; + if(argc < 2) return 1; + struct hostent *he=gethostbyname(argv[1]); + for(i=0;he->h_addr_list[i];i++) { + printf("%u.%u.%u.%u\n", + (unsigned char)he->h_addr_list[i][0], + (unsigned char)he->h_addr_list[i][1], + (unsigned char)he->h_addr_list[i][2], + (unsigned char)he->h_addr_list[i][3]); + } + return 0; +} diff --git a/src/pad.c b/src/pad.c new file mode 100644 index 0000000..2f2ea13 --- /dev/null +++ b/src/pad.c @@ -0,0 +1,32 @@ +#include <stdio.h> +#include <string.h> + +int main(int argc,char *argv[]) { + short in; + int i=0; + int width=argc>1?atoi(argv[1]):80; + char with=argc>2?argv[2][0]:' '; + char *line=argc>3?argv[3]:0; + if(width <= 0) width=80; + if(!line) { + while((in=fgetc(stdin)) != -1) { + if(in == '\n') { + for(;i%width || i == 0;i++) { + putchar(with); + } + i=-1; + } + i++; + putchar(in); + } + } else { + i=strlen(line); + } + if(i != 0 || line) { + if(line) fputs(line,stdout); + for(;i%width || i == 0;i++) { + putchar(with); + } + } + return 0; +} |