5 * This work is licensed under the terms of 3-clause BSD license.
6 * See COPYING file in the top-level directory.
13 #include "my_assert.h"
17 #include "protoparse.h"
19 int main(int argc, char *argv[])
21 const struct parsed_proto *pp;
34 for (arg = 1; arg < argc; arg++) {
35 if (IS(argv[arg], "-n"))
41 if (argc != arg + 2) {
42 printf("usage:\n%s [-n] <.h> <.def>\n", argv[0]);
47 fhdr = fopen(hdrfn, "r");
48 my_assert_not(fhdr, NULL);
50 fout = fopen(argv[arg++], "w");
51 my_assert_not(fout, NULL);
53 p = strrchr(hdrfn, '.');
54 my_assert_not(p, NULL);
55 p2 = strrchr(hdrfn, '/');
59 my_assert((unsigned int)l < 256, 1);
60 memcpy(basename, p2, l);
63 snprintf(fmt, sizeof(fmt), "%s_%%d", basename);
65 fprintf(fout, "LIBRARY %s\n", basename);
66 fprintf(fout, "EXPORTS\n");
68 while (fgets(line, sizeof(line), fhdr))
74 if (IS_START(p, "//"))
78 while (p != NULL && *p != 0) {
79 p = next_word(word, sizeof(word), p);
80 ret = sscanf(word, fmt, &ord);
85 printf("scan for '%s' failed for '%s'\n", fmt, line);
89 snprintf(word, sizeof(word), fmt, ord);
90 pp = proto_parse(fhdr, word, 0);
94 fprintf(fout, " %s", word);
96 fprintf(fout, "@%-2d", pp->argc_stack * 4);
99 fprintf(fout, " @%d", ord);
101 fprintf(fout, " NONAME");
110 // vim:ts=2:shiftwidth=2:expandtab