8 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
9 #define IS(w, y) !strcmp(w, y)
10 #define IS_START(w, y) !strncmp(w, y, strlen(y))
12 #include "protoparse.h"
14 int main(int argc, char *argv[])
16 const struct parsed_proto *pp;
29 for (arg = 1; arg < argc; arg++) {
30 if (IS(argv[arg], "-n"))
36 if (argc != arg + 2) {
37 printf("usage:\n%s [-n] <.h> <.def>\n", argv[0]);
42 fhdr = fopen(hdrfn, "r");
43 my_assert_not(fhdr, NULL);
45 fout = fopen(argv[arg++], "w");
46 my_assert_not(fout, NULL);
48 p = strrchr(hdrfn, '.');
49 my_assert_not(p, NULL);
50 p2 = strrchr(hdrfn, '/');
54 my_assert((unsigned int)l < 256, 1);
55 memcpy(basename, p2, l);
58 snprintf(fmt, sizeof(fmt), "%s_%%d", basename);
60 fprintf(fout, "LIBRARY %s\n", basename);
61 fprintf(fout, "EXPORTS\n");
63 while (fgets(line, sizeof(line), fhdr))
73 while (p != NULL && *p != 0) {
74 p = next_word(word, sizeof(word), p);
75 ret = sscanf(word, fmt, &ord);
80 printf("scan for '%s' failed for '%s'\n", fmt, line);
84 snprintf(word, sizeof(word), fmt, ord);
85 pp = proto_parse(fhdr, word, 0);
89 fprintf(fout, " %s", word);
91 fprintf(fout, "@%-2d", pp->argc_stack * 4);
94 fprintf(fout, " @%d", ord);
96 fprintf(fout, " NONAME");
105 // vim:ts=2:shiftwidth=2:expandtab