diff --git a/lib/src/clixon_api_path_parse.h b/lib/src/clixon_api_path_parse.h index 67b3e47a..869980d6 100644 --- a/lib/src/clixon_api_path_parse.h +++ b/lib/src/clixon_api_path_parse.h @@ -39,13 +39,14 @@ /* * Types */ -struct clicon_api_path_yacc_arg{ +struct clixon_api_path_yacc { const char *ay_name; /* Name of syntax (for error string) */ int ay_linenum; /* Number of \n in parsed buffer */ char *ay_parse_string; /* original (copy of) parse string */ void *ay_lexbuf; /* internal parse buffer from lex */ clixon_path *ay_top; }; +typedef struct clixon_api_path_yacc clixon_api_path_yacc; /* * Variables @@ -55,11 +56,11 @@ extern char *clixon_api_path_parsetext; /* * Prototypes */ -int api_path_scan_init(struct clicon_api_path_yacc_arg *); -int api_path_scan_exit(struct clicon_api_path_yacc_arg *); +int api_path_scan_init(clixon_api_path_yacc *); +int api_path_scan_exit(clixon_api_path_yacc *); -int api_path_parse_init(struct clicon_api_path_yacc_arg *); -int api_path_parse_exit(struct clicon_api_path_yacc_arg *); +int api_path_parse_init(clixon_api_path_yacc *); +int api_path_parse_exit(clixon_api_path_yacc *); int clixon_api_path_parselex(void *); int clixon_api_path_parseparse(void *); diff --git a/lib/src/clixon_api_path_parse.l b/lib/src/clixon_api_path_parse.l index a9e8d78b..9f6113dc 100644 --- a/lib/src/clixon_api_path_parse.l +++ b/lib/src/clixon_api_path_parse.l @@ -79,7 +79,7 @@ #define YY_NO_INPUT /* typecast macro */ -#define _AY ((struct clicon_api_path_yacc_arg *)_ay) +#define _AY ((clixon_api_path_yacc *)_ay) #define MAXBUF 4*4*64*1024 @@ -124,7 +124,7 @@ identifier {namestart}{namechar}* /*! Initialize scanner. */ int -api_path_scan_init(struct clicon_api_path_yacc_arg *ay) +api_path_scan_init(clixon_api_path_yacc *ay) { BEGIN(INIT); ay->ay_lexbuf = yy_scan_string(ay->ay_parse_string); @@ -141,7 +141,7 @@ api_path_scan_init(struct clicon_api_path_yacc_arg *ay) * Even within Flex version 2.5 (this is assumed), freeing buffers is different. */ int -api_path_scan_exit(struct clicon_api_path_yacc_arg *ay) +api_path_scan_exit(clixon_api_path_yacc *ay) { yy_delete_buffer(ay->ay_lexbuf); clixon_api_path_parselex_destroy(); /* modern */ diff --git a/lib/src/clixon_api_path_parse.y b/lib/src/clixon_api_path_parse.y index 7e51cb82..5a453821 100644 --- a/lib/src/clixon_api_path_parse.y +++ b/lib/src/clixon_api_path_parse.y @@ -80,7 +80,7 @@ /* Here starts user C-code */ /* typecast macro */ -#define _AY ((struct clicon_api_path_yacc_arg *)_ay) +#define _AY ((clixon_api_path_yacc *)_ay) #define _YYERROR(msg) {clicon_err(OE_XML, 0, "YYERROR %s '%s' %d", (msg), clixon_api_path_parsetext, _AY->ay_linenum); YYERROR;} @@ -130,13 +130,13 @@ clixon_api_path_parseerror(void *_ay, } int -api_path_parse_init(struct clicon_api_path_yacc_arg *ay) +api_path_parse_init(clixon_api_path_yacc *ay) { return 0; } int -api_path_parse_exit(struct clicon_api_path_yacc_arg *ay) +api_path_parse_exit(clixon_api_path_yacc *ay) { return 0; } diff --git a/lib/src/clixon_instance_id_parse.h b/lib/src/clixon_instance_id_parse.h index 46d48a1f..f7ff59c2 100644 --- a/lib/src/clixon_instance_id_parse.h +++ b/lib/src/clixon_instance_id_parse.h @@ -39,7 +39,7 @@ /* * Types */ -struct clicon_instance_id_yacc_arg{ +struct clixon_instance_id_yacc { const char *iy_name; /* Name of syntax (for error string) */ int iy_linenum; /* Number of \n in parsed buffer */ char *iy_parse_string; /* original (copy of) parse string */ @@ -47,6 +47,7 @@ struct clicon_instance_id_yacc_arg{ clixon_path *iy_top; int iy_lex_state; /* lex return state */ }; +typedef struct clixon_instance_id_yacc clixon_instance_id_yacc; /* * Variables @@ -56,11 +57,11 @@ extern char *clixon_instance_id_parsetext; /* * Prototypes */ -int instance_id_scan_init(struct clicon_instance_id_yacc_arg *); -int instance_id_scan_exit(struct clicon_instance_id_yacc_arg *); +int instance_id_scan_init(clixon_instance_id_yacc *); +int instance_id_scan_exit(clixon_instance_id_yacc *); -int instance_id_parse_init(struct clicon_instance_id_yacc_arg *); -int instance_id_parse_exit(struct clicon_instance_id_yacc_arg *); +int instance_id_parse_init(clixon_instance_id_yacc *); +int instance_id_parse_exit(clixon_instance_id_yacc *); int clixon_instance_id_parselex(void *); int clixon_instance_id_parseparse(void *); diff --git a/lib/src/clixon_instance_id_parse.l b/lib/src/clixon_instance_id_parse.l index 6673deef..cb8e9afb 100644 --- a/lib/src/clixon_instance_id_parse.l +++ b/lib/src/clixon_instance_id_parse.l @@ -76,7 +76,7 @@ #define YY_NO_INPUT /* typecast macro */ -#define _IY ((struct clicon_instance_id_yacc_arg *)_iy) +#define _IY ((clixon_instance_id_yacc *)_iy) #define MAXBUF 4*4*64*1024 @@ -131,7 +131,7 @@ uint [1-9][0-9]* /*! Initialize scanner. */ int -instance_id_scan_init(struct clicon_instance_id_yacc_arg *iy) +instance_id_scan_init(clixon_instance_id_yacc *iy) { BEGIN(INIT); iy->iy_lexbuf = yy_scan_string(iy->iy_parse_string); @@ -148,7 +148,7 @@ instance_id_scan_init(struct clicon_instance_id_yacc_arg *iy) * Even within Flex version 2.5 (this is assumed), freeing buffers is different. */ int -instance_id_scan_exit(struct clicon_instance_id_yacc_arg *iy) +instance_id_scan_exit(clixon_instance_id_yacc *iy) { yy_delete_buffer(iy->iy_lexbuf); clixon_instance_id_parselex_destroy(); /* modern */ diff --git a/lib/src/clixon_instance_id_parse.y b/lib/src/clixon_instance_id_parse.y index 7bbd96c4..1bd33eab 100644 --- a/lib/src/clixon_instance_id_parse.y +++ b/lib/src/clixon_instance_id_parse.y @@ -88,7 +88,7 @@ /* Here starts user C-code */ /* typecast macro */ -#define _IY ((struct clicon_instance_id_yacc_arg *)_iy) +#define _IY ((clixon_instance_id_yacc *)_iy) #define _YYERROR(msg) {clicon_err(OE_XML, 0, "YYERROR %s '%s' %d", (msg), clixon_instance_id_parsetext, _IY->iy_linenum); YYERROR;} @@ -138,13 +138,13 @@ clixon_instance_id_parseerror(void *_iy, } int -instance_id_parse_init(struct clicon_instance_id_yacc_arg *iy) +instance_id_parse_init(clixon_instance_id_yacc *iy) { return 0; } int -instance_id_parse_exit(struct clicon_instance_id_yacc_arg *iy) +instance_id_parse_exit(clixon_instance_id_yacc *iy) { return 0; } diff --git a/lib/src/clixon_json_parse.h b/lib/src/clixon_json_parse.h index bbbc905b..e0a37b40 100644 --- a/lib/src/clixon_json_parse.h +++ b/lib/src/clixon_json_parse.h @@ -40,7 +40,7 @@ * Types */ -struct clixon_json_yacc_arg{ /* XXX: mostly unrelevant */ +struct clixon_json_yacc { int jy_linenum; /* Number of \n in parsed buffer */ char *jy_parse_string; /* original (copy of) parse string */ void *jy_lexbuf; /* internal parse buffer from lex */ @@ -49,7 +49,7 @@ struct clixon_json_yacc_arg{ /* XXX: mostly unrelevant */ cxobj **jy_xvec; /* Vector of created top-level nodes (to know which are created) */ size_t jy_xlen; /* Length of jy_xvec */ }; -typedef struct clixon_json_yacc_arg clixon_json_yacc; +typedef struct clixon_json_yacc clixon_json_yacc; /* * Variables diff --git a/lib/src/clixon_path.c b/lib/src/clixon_path.c index a24346c5..2033999c 100644 --- a/lib/src/clixon_path.c +++ b/lib/src/clixon_path.c @@ -119,8 +119,8 @@ static int api_path_parse(char *api_path, clixon_path **cplist) { - int retval = -1; - struct clicon_api_path_yacc_arg ay = {0,}; + int retval = -1; + clixon_api_path_yacc ay = {0,}; clicon_debug(1, "%s api_path:%s", __FUNCTION__, api_path); ay.ay_parse_string = api_path; @@ -164,8 +164,8 @@ static int instance_id_parse(char *path, clixon_path **cplist) { - int retval = -1; - struct clicon_instance_id_yacc_arg iy = {0,}; + int retval = -1; + clixon_instance_id_yacc iy = {0,}; clicon_debug(1, "%s path:%s", __FUNCTION__, path); iy.iy_parse_string = path; diff --git a/lib/src/clixon_xml.c b/lib/src/clixon_xml.c index 21b0912c..e3c437da 100644 --- a/lib/src/clixon_xml.c +++ b/lib/src/clixon_xml.c @@ -2033,7 +2033,7 @@ _xml_parse(const char *str, cxobj **xerr) { int retval = -1; - clixon_xml_yacc ya = {0,}; + clixon_xml_yacc xy = {0,}; cxobj *x; int ret; int failed = 0; /* yang assignment */ @@ -2046,24 +2046,24 @@ _xml_parse(const char *str, clicon_err(OE_XML, errno, "Unexpected NULL XML"); return -1; } - if ((ya.ya_parse_string = strdup(str)) == NULL){ + if ((xy.xy_parse_string = strdup(str)) == NULL){ clicon_err(OE_XML, errno, "strdup"); return -1; } - ya.ya_xtop = xt; - ya.ya_xparent = xt; - ya.ya_yspec = yspec; - if (clixon_xml_parsel_init(&ya) < 0) + xy.xy_xtop = xt; + xy.xy_xparent = xt; + xy.xy_yspec = yspec; + if (clixon_xml_parsel_init(&xy) < 0) goto done; - if (clixon_xml_parseparse(&ya) != 0) /* yacc returns 1 on error */ + if (clixon_xml_parseparse(&xy) != 0) /* yacc returns 1 on error */ goto done; /* Purge all top-level body objects */ x = NULL; while ((x = xml_find_type(xt, NULL, "body", CX_BODY)) != NULL) xml_purge(x); /* Traverse new objects */ - for (i = 0; i < ya.ya_xlen; i++) { - x = ya.ya_xvec[i]; + for (i = 0; i < xy.xy_xlen; i++) { + x = xy.xy_xvec[i]; /* Verify namespaces after parsing */ if (xml_apply0(x, CX_ELMNT, xml_localname_check, NULL) < 0) goto done; @@ -2108,11 +2108,11 @@ _xml_parse(const char *str, goto done; retval = (failed==0) ? 1 : 0; done: - clixon_xml_parsel_exit(&ya); - if (ya.ya_parse_string != NULL) - free(ya.ya_parse_string); - if (ya.ya_xvec) - free(ya.ya_xvec); + clixon_xml_parsel_exit(&xy); + if (xy.xy_parse_string != NULL) + free(xy.xy_parse_string); + if (xy.xy_xvec) + free(xy.xy_xvec); return retval; } diff --git a/lib/src/clixon_xml_parse.h b/lib/src/clixon_xml_parse.h index 7a8845f7..13cb5836 100644 --- a/lib/src/clixon_xml_parse.h +++ b/lib/src/clixon_xml_parse.h @@ -44,19 +44,19 @@ * Types */ /*! XML parser yacc handler struct */ -struct xml_parse_yacc_arg{ - char *ya_parse_string; /* original (copy of) parse string */ - int ya_linenum; /* Number of \n in parsed buffer */ - void *ya_lexbuf; /* internal parse buffer from lex */ - cxobj *ya_xtop; /* cxobj top element (fixed) */ - cxobj *ya_xelement; /* cxobj active element (changes with parse context) */ - cxobj *ya_xparent; /* cxobj parent element (changes with parse context) */ - yang_stmt *ya_yspec; /* If set, top-level yang-spec */ - int ya_lex_state; /* lex return state */ - cxobj **ya_xvec; /* Vector of created top-level nodes (to know which are created) */ - size_t ya_xlen; /* Length of ya_xvec */ +struct clixon_xml_parse_yacc { + char *xy_parse_string; /* original (copy of) parse string */ + int xy_linenum; /* Number of \n in parsed buffer */ + void *xy_lexbuf; /* internal parse buffer from lex */ + cxobj *xy_xtop; /* cxobj top element (fixed) */ + cxobj *xy_xelement; /* cxobj active element (changes with parse context) */ + cxobj *xy_xparent; /* cxobj parent element (changes with parse context) */ + yang_stmt *xy_yspec; /* If set, top-level yang-spec */ + int xy_lex_state; /* lex return state */ + cxobj **xy_xvec; /* Vector of created top-level nodes (to know which are created) */ + size_t xy_xlen; /* Length of xy_xvec */ }; -typedef struct xml_parse_yacc_arg clixon_xml_yacc; +typedef struct clixon_xml_parse_yacc clixon_xml_yacc; extern char *clixon_xml_parsetext; diff --git a/lib/src/clixon_xml_parse.l b/lib/src/clixon_xml_parse.l index 1d2b9b6b..3e156c72 100644 --- a/lib/src/clixon_xml_parse.l +++ b/lib/src/clixon_xml_parse.l @@ -61,14 +61,14 @@ #include "clixon_xml.h" #include "clixon_xml_parse.h" -/* Redefine main lex function so that you can send arguments to it: _ya is added to arg list */ -#define YY_DECL int clixon_xml_parselex(void *_ya) +/* Redefine main lex function so that you can send arguments to it: _xy is added to arg list */ +#define YY_DECL int clixon_xml_parselex(void *_xy) /* Dont use input function (use user-buffer) */ #define YY_NO_INPUT /* typecast macro */ -#define _YA ((clixon_xml_yacc *)_ya) +#define _XY ((clixon_xml_yacc *)_xy) #undef clixon_xml_parsewrap int clixon_xml_parsewrap(void) @@ -107,7 +107,7 @@ ncname {namestart}{namechar}* %% [ \t] ; -\n { _YA->ya_linenum++; } +\n { _XY->xy_linenum++; } \r {ncname} { clixon_xml_parselval.string = strdup(yytext); @@ -123,32 +123,32 @@ ncname {namestart}{namechar}* [/=] return *clixon_xml_parsetext; \< return *clixon_xml_parsetext; \> { BEGIN(STATEA); return *clixon_xml_parsetext; } -\" { _YA->ya_lex_state=START;BEGIN(STRDQ); return *clixon_xml_parsetext; } -\' { _YA->ya_lex_state=START;BEGIN(STRSQ); return *clixon_xml_parsetext; } +\" { _XY->xy_lex_state=START;BEGIN(STRDQ); return *clixon_xml_parsetext; } +\' { _XY->xy_lex_state=START;BEGIN(STRSQ); return *clixon_xml_parsetext; } . { clixon_xml_parselval.string = yytext; return CHARDATA; /* optimize? */} "<> { return MY_EOF; } "