2 * Generate devlist.h from the Zorro ID file.
4 * (c) 2000 Geert Uytterhoeven <geert@linux-m68k.org>
6 * Based on the PCI version:
8 * (c) 1999--2000 Martin Mares <mj@ucw.cz>
14 #define MAX_NAME_SIZE 63
17 pq(FILE *f, const char *c)
31 char line[1024], *c, *bra, manuf[8];
38 devf = fopen("devlist.h", "w");
40 fprintf(stderr, "Cannot create output file!\n");
44 while (fgets(line, sizeof(line)-1, stdin)) {
46 if ((c = strchr(line, '\n')))
48 if (!line[0] || line[0] == '#')
50 if (line[0] == '\t') {
53 if (strlen(line) > 5 && line[5] == ' ') {
57 if (manuf_len + strlen(c) + 1 > MAX_NAME_SIZE) {
58 /* Too long, try cutting off long description */
60 if (bra && bra > c && bra[-1] == ' ')
62 if (manuf_len + strlen(c) + 1 > MAX_NAME_SIZE) {
63 fprintf(stderr, "Line %d: Product name too long\n", lino);
67 fprintf(devf, "\tPRODUCT(%s,%s,\"", manuf, line+1);
75 } else if (strlen(line) > 4 && line[4] == ' ') {
80 fputs("ENDMANUF()\n\n", devf);
83 manuf_len = strlen(c);
84 if (manuf_len + 24 > MAX_NAME_SIZE) {
85 fprintf(stderr, "Line %d: manufacturer name too long\n", lino);
88 fprintf(devf, "MANUF(%s,\"", manuf);
94 fprintf(stderr, "Line %d: Syntax error in mode %d: %s\n", lino, mode, line);
102 #undef ENDMANUF\n", devf);