2 * Generate devlist.h and classlist.h from the PCI ID file.
4 * (c) 1999--2000 Martin Mares <mj@suse.cz>
10 #define MAX_NAME_SIZE 79
13 pq(FILE *f
, const char *c
)
27 char line
[1024], *c
, *bra
, vend
[8];
34 devf
= fopen("devlist.h", "w");
35 clsf
= fopen("classlist.h", "w");
37 fprintf(stderr
, "Cannot create output file!\n");
41 while (fgets(line
, sizeof(line
)-1, stdin
)) {
43 if ((c
= strchr(line
, '\n')))
45 if (!line
[0] || line
[0] == '#')
48 if (line
[0] == 'C' && strlen(line
) > 4 && line
[4] == ' ') {
55 else if (line
[0] == '\t') {
60 if (strlen(line
) > 5 && line
[5] == ' ') {
64 if (vendor_len
+ strlen(c
) + 1 > MAX_NAME_SIZE
) {
65 /* Too long, try cutting off long description */
67 if (bra
&& bra
> c
&& bra
[-1] == ' ')
69 if (vendor_len
+ strlen(c
) + 1 > MAX_NAME_SIZE
) {
70 fprintf(stderr
, "Line %d: Device name too long\n", lino
);
74 fprintf(devf
, "\tDEVICE(%s,%s,\"", vend
, line
+1);
80 if (strlen(line
) > 3 && line
[3] == ' ') {
84 fprintf(clsf
, "CLASS(%s%s, \"%s\")\n", vend
, line
+1, c
);
90 } else if (strlen(line
) > 4 && line
[4] == ' ') {
95 fputs("ENDVENDOR()\n\n", devf
);
98 vendor_len
= strlen(c
);
99 if (vendor_len
+ 24 > MAX_NAME_SIZE
) {
100 fprintf(stderr
, "Line %d: Vendor name too long\n", lino
);
103 fprintf(devf
, "VENDOR(%s,\"", vend
);
105 fputs("\")\n", devf
);
109 fprintf(stderr
, "Line %d: Syntax error in mode %d: %s\n", lino
, mode
, line
);
113 fputs("ENDVENDOR()\n\
117 #undef ENDVENDOR\n", devf
);
118 fputs("\n#undef CLASS\n", clsf
);