diff options
author | epoch <epoch@hacking.allowed.org> | 2019-06-16 10:58:13 -0500 |
---|---|---|
committer | epoch <epoch@hacking.allowed.org> | 2019-06-16 10:58:13 -0500 |
commit | 8a8602011b11a4f53a96facd4d5dc0c0aed7b6a4 (patch) | |
tree | 439195b00aeddec9d214099cb4a52770d93cc38d /uriunescape.c | |
parent | 0eb5608223ed83a35734c86a99c57def93a9cfca (diff) | |
download | uritools-8a8602011b11a4f53a96facd4d5dc0c0aed7b6a4.tar.gz uritools-8a8602011b11a4f53a96facd4d5dc0c0aed7b6a4.zip |
added ability for uriunescape to read from stdin if there are no arguments
Diffstat (limited to 'uriunescape.c')
-rw-r--r-- | uriunescape.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/uriunescape.c b/uriunescape.c index aafc6ea..0a7ef5d 100644 --- a/uriunescape.c +++ b/uriunescape.c @@ -2,11 +2,21 @@ #include <unistd.h> int main(int argc,char *argv[]) { + int n; int len; - for(argv++,argc--;argc;argc--,argv++) { - len=uriunescape(*argv,*argv); - write(1,*argv,len); - if(argc-1) write(1," ",1); + char buf[4096]; + if(argc > 1) { + for(argv++,argc--;argc;argc--,argv++) { + len=uriunescape(*argv,*argv); + write(1,*argv,len); + if(argc-1) write(1," ",1); + } + } else { + while((n=read(0,buf,sizeof(buf)-1)) > 0) { + buf[n]=0; + len=uriunescape(buf,buf); + write(1,buf,len); + } } return 0; } |