1 // SPDX-License-Identifier: GPL-2.0
3 * Generate devlist.h from the Zorro ID file.
7 * Based on the PCI version:
15 #define MAX_NAME_SIZE 63
18 pq(FILE *f, const char *c)
32 char line[1024], *c, *bra, manuf[8];
39 devf = fopen("devlist.h", "w");
41 fprintf(stderr, "Cannot create output file!\n");
45 while (fgets(line, sizeof(line)-1, stdin)) {
47 if ((c = strchr(line, '\n')))
49 if (!line[0] || line[0] == '#')
51 if (line[0] == '\t') {
54 if (strlen(line) > 5 && line[5] == ' ') {
58 if (manuf_len + strlen(c) + 1 > MAX_NAME_SIZE) {
59 /* Too long, try cutting off long description */
61 if (bra && bra > c && bra[-1] == ' ')
63 if (manuf_len + strlen(c) + 1 > MAX_NAME_SIZE) {
64 fprintf(stderr, "Line %d: Product name too long\n", lino);
68 fprintf(devf, "\tPRODUCT(%s,%s,\"", manuf, line+1);
76 } else if (strlen(line) > 4 && line[4] == ' ') {
81 fputs("ENDMANUF()\n\n", devf);
84 manuf_len = strlen(c);
85 if (manuf_len + 24 > MAX_NAME_SIZE) {
86 fprintf(stderr, "Line %d: manufacturer name too long\n", lino);
89 fprintf(devf, "MANUF(%s,\"", manuf);
95 fprintf(stderr, "Line %d: Syntax error in mode %d: %s\n", lino, mode, line);
103 #undef ENDMANUF\n", devf);