chiark / gitweb /
make distcheck in scirpts/dist
[disorder] / clients / filename-bytes.c
1 /* Grotty program to print out the bytes making up filenames in some
2  * directory */
3
4 #include "common.h"
5
6 #include <dirent.h>
7 #include <ctype.h>
8
9 int main(int attribute((unused)) argc, char **argv) {
10   DIR *dp;
11   struct dirent *de;
12   int n;
13   
14   if(!(dp = opendir(argv[1]))) return -1;
15   while((de = readdir(dp))) {
16     for(n = 0; de->d_name[n]; ++n) {
17       printf("%02x", (unsigned char)de->d_name[n]);
18       if(n) putchar(' ');
19     }
20     putchar('\n');
21     for(n = 0; de->d_name[n]; ++n) {
22       if(isprint((unsigned char)de->d_name[n]))
23         printf(" %c", (unsigned char)de->d_name[n]);
24       else
25         printf("  ");
26       if(n) putchar(' ');
27     }
28     putchar('\n');
29   }
30   return 0;
31 }
32
33 /*
34 Local Variables:
35 c-basic-offset:2
36 comment-column:40
37 fill-column:79
38 indent-tabs-mode:nil
39 End:
40 */