6 #include <netatalk/endian.h>
9 int main(int argc, char **argv)
11 unsigned char name[255 + 1], buf[CODEPAGE_FILE_HEADER_SIZE];
12 unsigned char quantum, rules;
17 fprintf(stderr, "%s <codepage>\n", *argv);
21 if ((fp = fopen(argv[1], "r")) == NULL) {
22 fprintf(stderr, "%s: can't open file.\n", *argv);
26 if (fread(buf, CODEPAGE_FILE_HEADER_SIZE, 1, fp) != 1) {
27 fprintf(stderr, "%s: can't get header.\n", *argv);
32 memcpy(&id, buf, sizeof(id));
34 if (id != CODEPAGE_FILE_ID) {
35 fprintf(stderr, "%s: wrong file type.\n", *argv);
40 if (*(buf + 2) != CODEPAGE_FILE_VERSION) {
41 fprintf(stderr, "%s: wrong file version.\n", *argv);
48 /* quantum and rules */
52 fread(name, id, 1, fp);
53 if (name[id - 1] != '\0') /* name isn't null-padded */
55 printf("codepage: %s [", name);
57 /* move to the data */
58 memcpy(&id, buf + 6, sizeof(id));
60 fseek(fp, id, SEEK_SET);
63 memcpy(&id, buf + 8, sizeof(id));
65 printf("size=%d]\n", id);
66 printf("---------\n");
68 while (fread(buf, 1 + 2*quantum, 1, fp) == 1) {
69 printf("0x%02x: 0x%02X 0x%02X\n", buf[0], buf[1], buf[1 + quantum]);