aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/urcdump.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/urcdump.c')
-rw-r--r--src/bin/urcdump.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/bin/urcdump.c b/src/bin/urcdump.c
index 8d19370..0fea8ed 100644
--- a/src/bin/urcdump.c
+++ b/src/bin/urcdump.c
@@ -7,7 +7,8 @@
int main(int argc,char *argv[]) {
int s;
struct sockaddr_in name;
- char *tmp;
+ //char *tmp;
+ int tmp;
char chunk[BS];
int off=0;
char buf[BS];
@@ -25,15 +26,34 @@ int main(int argc,char *argv[]) {
if(connect(s,(struct sockaddr *)&name,len) == -1) return -1;
while((len=read(s,buf,BS-1)) > 0) {
- memcpy(chunk+off,buf,len);
- off+=len;
- if(off > 26) {
+ for(tmp=0;tmp<len;tmp++) {
+ if(isprint(*(buf+tmp))) {
+ write(1,(buf+tmp),1);
+ } else {
+ write(1,"%",1);
+ write(1,"0123456789abcdef"+((buf[tmp])>>4&15),1);
+ write(1,"0123456789abcdef"+((buf[tmp])&15),1);
+ }
+ }
+/*
+ while(off > 26) {
if((tmp=memchr(chunk+26,'\n',off-26))) {
tmp++;
- write(1,chunk+26,tmp-chunk-26);
+//old write(1,chunk+26,tmp-chunk-26);
+//testing:
+ for(len=26;len<tmp-chunk-1;len++) {
+ if(isprint(*(chunk+len))) {
+ write(1,(chunk+len),1);
+ } else {
+ write(1,"%",1);
+ write(1,"0123456789abcdef"+((*chunk+len)>>4 & 15),1);
+ write(1,"0123456789abcdef"+((*chunk+len)&15),1);
+ }
+ }
memmove(chunk,tmp,tmp-chunk+1);
off-=(tmp-chunk);
}
}
+ */
}
}