9 char hex[] = "0123456789abcdef";
10 char Hex[] = "0123456789ABCDEF";
18 if((p = strchr(Hex, c)) != 0)
20 if((p = strchr(hex, c)) != 0)
29 fprint(2, "Usage: %s [ -d ] [ file ]\n", argv0);
34 main(int argc, char *argv[])
47 if(open(*argv, OREAD) < 0)
52 Binit(&bin, 0, OREAD);
53 Binit(&bout, 1, OWRITE);
56 while((c = Bgetc(&bin)) >= 0){
60 if((c1 = Bgetc(&bin)) < 0)
62 if((x1 = hexdigit(c1)) < 0){
67 if((c2 = Bgetc(&bin)) < 0)
69 if((x2 = hexdigit(c2)) < 0){
80 while((c = Bgetc(&bin)) >= 0){
81 if(strchr("/$-_@.!*'(),", c)
90 Bputc(&bout, Hex[c>>4]);
91 Bputc(&bout, Hex[c&15]);