2 * Generate devlist.h and classlist.h from the PCI ID file.
4 * (c) 1999--2002 Martin Mares <mj@ucw.cz>
10 #define MAX_NAME_SIZE 79
13 pq(FILE *f, const char *c)
20 if (*c == '?' && c[1] == '?') {
32 char line[1024], *c, *bra, vend[8];
39 devf = fopen("devlist.h", "w");
40 clsf = fopen("classlist.h", "w");
42 fprintf(stderr, "Cannot create output file!\n");
46 while (fgets(line, sizeof(line)-1, stdin)) {
48 if ((c = strchr(line, '\n')))
50 if (!line[0] || line[0] == '#')
53 if (line[0] == 'C' && strlen(line) > 4 && line[4] == ' ') {
60 else if (line[0] == '\t') {
65 if (strlen(line) > 5 && line[5] == ' ') {
69 if (vendor_len + strlen(c) + 1 > MAX_NAME_SIZE) {
70 /* Too long, try cutting off long description */
72 if (bra && bra > c && bra[-1] == ' ')
74 if (vendor_len + strlen(c) + 1 > MAX_NAME_SIZE) {
75 fprintf(stderr, "Line %d: Device name too long\n", lino);
76 fprintf(stderr, "%s\n", c);
80 fprintf(devf, "\tDEVICE(%s,%s,\"", vend, line+1);
86 if (strlen(line) > 3 && line[3] == ' ') {
90 fprintf(clsf, "CLASS(%s%s, \"%s\")\n", vend, line+1, c);
96 } else if (strlen(line) > 4 && line[4] == ' ') {
101 fputs("ENDVENDOR()\n\n", devf);
104 vendor_len = strlen(c);
105 if (vendor_len + 24 > MAX_NAME_SIZE) {
106 fprintf(stderr, "Line %d: Vendor name too long\n", lino);
109 fprintf(devf, "VENDOR(%s,\"", vend);
111 fputs("\")\n", devf);
115 fprintf(stderr, "Line %d: Syntax error in mode %d: %s\n", lino, mode, line);
119 fputs("ENDVENDOR()\n\
123 #undef ENDVENDOR\n", devf);
124 fputs("\n#undef CLASS\n", clsf);