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