X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=vppapigen%2Fnode.c;h=fa7146ae497c7fcb9e6d3f2c41c5e0da3a588ec3;hb=2fdaece0876465d6980ac6922099502a84e1e029;hp=ab8adc568c6dfe4fc1ac542681eac48145a0dfcb;hpb=1642e3903d5467baf88531c96c733c285418b953;p=vpp.git diff --git a/vppapigen/node.c b/vppapigen/node.c index ab8adc568c6..fa7146ae497 100644 --- a/vppapigen/node.c +++ b/vppapigen/node.c @@ -1034,7 +1034,7 @@ char *fixup_input_filename(void) if (*cp == '/') cp++; - strcpy (tmpbuf, cp); + strncpy (tmpbuf, cp, sizeof(tmpbuf)-1); cp = tmpbuf; @@ -1324,21 +1324,48 @@ void add_msg_ids(YYSTYPE a1) } } -void generate_python (YYSTYPE a1, FILE *fp) +void generate_python_msg_definitions(YYSTYPE a1, FILE *fp) { - node_t *np = (node_t *)a1; - node_vft_t *vftp; - fprintf (fp, "vppapidef = [\n"); - /* Walk the top-level node-list */ - while (np) { - if (np->type == NODE_DEFINE && !(np->flags & NODE_FLAG_TYPEONLY)) { - /* Yeah, this is pedantic */ - vftp = the_vft[np->type]; - vftp->generate(np, PYTHON_PASS, fp); + node_t *np = (node_t *)a1; + node_vft_t *vftp; + fprintf (fp, "messages = [\n"); + /* Walk the top-level node-list */ + while (np) { + if (np->type == NODE_DEFINE && !(np->flags & NODE_FLAG_TYPEONLY)) { + /* Yeah, this is pedantic */ + vftp = the_vft[np->type]; + vftp->generate(np, PYTHON_PASS, fp); + } + np = np->peer; + } + fprintf (fp, "\n]\n"); +} + +void generate_python_typeonly_definitions(YYSTYPE a1, FILE *fp) +{ + node_t *np = (node_t *)a1; + node_vft_t *vftp; + fprintf (fp, "types = [\n"); + /* Walk the top-level node-list */ + while (np) { + if (np->type == NODE_DEFINE && (np->flags & NODE_FLAG_TYPEONLY)) { + vftp = the_vft[np->type]; + vftp->generate(np, PYTHON_PASS, fp); + } + np = np->peer; } - np = np->peer; - } - fprintf (fp, "\n]\n"); + fprintf (fp, "\n]\n"); +} + +void generate_python(YYSTYPE a1, FILE *fp) +{ + generate_python_typeonly_definitions(a1, fp); + generate_python_msg_definitions(a1, fp); + + /* + * API CRC signature + */ + fprintf (fp, "vl_api_version = 0x%08x\n\n", (unsigned int)input_crc); } void generate(YYSTYPE a1)