diff --git a/hawk/lib/err.c b/hawk/lib/err.c index 2acd1715..eccfb86c 100644 --- a/hawk/lib/err.c +++ b/hawk/lib/err.c @@ -44,8 +44,8 @@ const hawk_ooch_t* hawk_dflerrstr (hawk_t* awk, hawk_errnum_t errnum) HAWK_T("system busy"), HAWK_T("operation not allowed"), HAWK_T("not supported"), - HAWK_T("'${0}' not found"), - HAWK_T("'${0}' already exists"), + HAWK_T("not found"), + HAWK_T("already exists"), HAWK_T("I/O error"), HAWK_T("buffer full"), HAWK_T("encoding conversion error"), @@ -75,23 +75,23 @@ const hawk_ooch_t* hawk_dflerrstr (hawk_t* awk, hawk_errnum_t errnum) HAWK_T("comment not closed properly"), HAWK_T("string or regular expression not closed"), HAWK_T("invalid mbs character"), - HAWK_T("left brace expected in place of '${0}'"), - HAWK_T("left parenthesis expected in place of '${0}'"), - HAWK_T("right parenthesis expected in place of '${0}'"), - HAWK_T("right bracket expected in place of '${0}'"), - HAWK_T("comma expected in place of '${0}'"), - HAWK_T("semicolon expected in place of '${0}'"), - HAWK_T("colon expected in place of '${0}'"), + HAWK_T("left brace expected"), + HAWK_T("left parenthesis expected"), + HAWK_T("right parenthesis expected"), + HAWK_T("right bracket expected"), + HAWK_T("comma expected"), + HAWK_T("semicolon expected"), + HAWK_T("colon expected"), HAWK_T("integer literal expected"), HAWK_T("statement not ending with a semicolon"), - HAWK_T("keyword 'in' expected in place of '${0}'"), + HAWK_T("keyword 'in' expected"), HAWK_T("right-hand side of 'in' not a variable"), HAWK_T("expression not recognized"), HAWK_T("keyword 'function' expected"), - HAWK_T("keyword 'while' expected in place of '${0}'"), + HAWK_T("keyword 'while' expected"), HAWK_T("invalid assignment statement"), - HAWK_T("identifier expected in place of '${0}'"), + HAWK_T("identifier expected"), HAWK_T("not a valid function name"), HAWK_T("BEGIN not followed by left bracket on the same line"), HAWK_T("END not followed by left bracket on the same line"), @@ -113,7 +113,7 @@ const hawk_ooch_t* hawk_dflerrstr (hawk_t* awk, hawk_errnum_t errnum) HAWK_T("too many local variables"), HAWK_T("too many parameters"), HAWK_T("too many segments"), - HAWK_T("segment '${0}' too long"), + HAWK_T("segment too long"), HAWK_T("bad argument"), HAWK_T("no argument provided"), HAWK_T("'break' outside a loop"), @@ -126,7 +126,7 @@ const hawk_ooch_t* hawk_dflerrstr (hawk_t* awk, hawk_errnum_t errnum) HAWK_T("illegal operand for increment/decrement operator"), HAWK_T("'@include' not followed by a string"), HAWK_T("include level too deep"), - HAWK_T("'${0}' not recognized"), + HAWK_T("word after @ not recognized"), HAWK_T("@ not followed by a valid word"), HAWK_T("stack error"), @@ -189,11 +189,6 @@ hawk_errstr_t hawk_geterrstr (hawk_t* hawk) return hawk->errstr; } -void hawk_seterrstr (hawk_t* hawk, hawk_errstr_t errstr) -{ - hawk->errstr = errstr; -} - /* ------------------------------------------------------------------------- */ const hawk_loc_t* hawk_geterrloc (hawk_t* hawk) @@ -353,23 +348,6 @@ void hawk_seterrufmt (hawk_t* hawk, const hawk_loc_t* errloc, hawk_errnum_t errn hawk->_gem.errloc = (errloc? *errloc: _nullloc); } -void hawk_seterror (hawk_t* hawk, hawk_errnum_t errnum, const hawk_oocs_t* errarg, const hawk_loc_t* errloc) -{ -/* TODO: remove awk_rtx_seterror() and substitute hawk_rtx_seterrfmt()/seterrbfmt()/seterrufmt() */ - const hawk_ooch_t* errfmt; - - hawk->_gem.errnum = errnum; - - errfmt = hawk_geterrstr(hawk)(hawk, errnum); - HAWK_ASSERT (errfmt != HAWK_NULL); -/* TODO: this change is buggy... copying won't process arguments... - hawk_strxfncpy (hawk->_gem.errmsg, HAWK_COUNTOF(hawk->_gem.errmsg), errfmt, errarg); -*/ - hawk_copy_oocstr(hawk->_gem.errmsg, HAWK_COUNTOF(hawk->_gem.errmsg), errfmt); -/* TODO: remove awk_rtx_seterror() and substitute hawk_rtx_seterrfmt()/seterrbfmt()/seterrufmt() */ - hawk->_gem.errloc = (errloc? *errloc: _nullloc); -} - /* ------------------------------------------------------------------------- */ const hawk_loc_t* hawk_rtx_geterrloc (hawk_rtx_t* rtx) diff --git a/hawk/lib/hawk-cmn.h b/hawk/lib/hawk-cmn.h index acaedde6..2eb43139 100644 --- a/hawk/lib/hawk-cmn.h +++ b/hawk/lib/hawk-cmn.h @@ -805,23 +805,23 @@ enum hawk_errnum_t HAWK_ECMTNC, /**< comment not closed properly */ HAWK_ESTRNC, /**< string or regular expression not closed */ HAWK_EMBSCHR, /**< invalid mbs character */ - HAWK_ELBRACE, /**< left brace expected in place of '${0}' */ - HAWK_ELPAREN, /**< left parenthesis expected in place of '${0}' */ - HAWK_ERPAREN, /**< right parenthesis expected in place of '${0}' */ - HAWK_ERBRACK, /**< right bracket expected in place of '${0}' */ - HAWK_ECOMMA, /**< comma expected in place of '${0}' */ - HAWK_ESCOLON, /**< semicolon expected in place of '${0}' */ - HAWK_ECOLON, /**< colon expected in place of '${0}' */ + HAWK_ELBRACE, /**< left brace expected */ + HAWK_ELPAREN, /**< left parenthesis expected */ + HAWK_ERPAREN, /**< right parenthesis expected */ + HAWK_ERBRACK, /**< right bracket expected */ + HAWK_ECOMMA, /**< comma expected */ + HAWK_ESCOLON, /**< semicolon expected */ + HAWK_ECOLON, /**< colon expected */ HAWK_EINTLIT, /**< integer literal expected */ HAWK_ESTMEND, /**< statement not ending with a semicolon */ HAWK_EKWIN, /**< keyword 'in' expected */ HAWK_ENOTVAR, /**< right-hand side of 'in' not a variable */ HAWK_EEXPRNR, /**< expression not recognized */ - HAWK_EKWFNC, /**< keyword 'function' expected in place of '${0}' */ - HAWK_EKWWHL, /**< keyword 'while' expected in place of '${0}' */ + HAWK_EKWFNC, /**< keyword 'function' expected */ + HAWK_EKWWHL, /**< keyword 'while' expected */ HAWK_EASSIGN, /**< assignment statement expected */ - HAWK_EIDENT, /**< identifier expected in place of '${0}' */ + HAWK_EIDENT, /**< identifier expected */ HAWK_EFUNNAM, /**< not a valid function name */ HAWK_EBLKBEG, /**< BEGIN not followed by left bracket on the same line */ HAWK_EBLKEND, /**< END not followed by left bracket on the same line */ @@ -843,7 +843,7 @@ enum hawk_errnum_t HAWK_ELCLTM, /**< too many local variables */ HAWK_EPARTM, /**< too many parameters */ HAWK_ESEGTM, /**< too many segments */ - HAWK_ESEGTL, /**< segment '${0}' too long */ + HAWK_ESEGTL, /**< segment too long */ HAWK_EBADARG, /**< bad argument */ HAWK_ENOARG, /**< no argument */ HAWK_EBREAK, /**< 'break' outside a loop */ @@ -856,7 +856,7 @@ enum hawk_errnum_t HAWK_EINCDECOPR,/**< illegal operand for incr/decr operator */ HAWK_EINCLSTR, /**< 'include' not followed by a string */ HAWK_EINCLTD, /**< include level too deep */ - HAWK_EXKWNR, /**< @word '${0}' not recognized */ + HAWK_EXKWNR, /**< word after @ not recognized */ HAWK_EXKWEM, /**< @ not followed by a valid word */ /* run time error */ diff --git a/hawk/lib/hawk.h b/hawk/lib/hawk.h index 2cad3e35..48c8e75c 100644 --- a/hawk/lib/hawk.h +++ b/hawk/lib/hawk.h @@ -1501,35 +1501,6 @@ HAWK_EXPORT hawk_errstr_t hawk_geterrstr ( hawk_t* awk /**< awk */ ); -/** - * The hawk_seterrstr() sets an error string getter that is called to - * compose an error message when its retrieval is requested. - * - * Here is an example of changing the formatting string for the #HAWK_SED_ECMDNR - * error. - * \code - * hawk_errstr_t orgerrstr; - * - * const hawk_ooch_t* myerrstr (hawk_t* awk, hawk_errnum_t num) - * { - * if (num == HAWK_SED_ECMDNR) return HAWK_T("unrecognized command ${0}"); - * return orgerrstr (awk, num); - * } - * int main () - * { - * hawk_t* awk; - * ... - * orgerrstr = hawk_geterrstr (awk); - * hawk_seterrstr (awk, myerrstr); - * ... - * } - * \endcode - */ -HAWK_EXPORT void hawk_seterrstr ( - hawk_t* awk, /**< awk */ - hawk_errstr_t errstr /**< error string getter */ -); - /** * The hawk_geterrnum() function returns the number of the last error * occurred. @@ -1647,16 +1618,6 @@ HAWK_EXPORT void hawk_geterror ( hawk_loc_t* errloc /**< error location */ ); -/** - * The hawk_seterror() function sets error information. - */ -HAWK_EXPORT void hawk_seterror ( - hawk_t* awk, /**< awk */ - hawk_errnum_t errnum, /**< error number */ - const hawk_oocs_t* errarg, /**< argument array for formatting an error message */ - const hawk_loc_t* errloc /**< error location */ -); - /** * The hawk_getopt() function gets the value of an option * specified by \a id into the buffer pointed to by \a value. diff --git a/hawk/lib/mod-math.c b/hawk/lib/mod-math.c index f0f5d84c..c1ee75b3 100644 --- a/hawk/lib/mod-math.c +++ b/hawk/lib/mod-math.c @@ -639,7 +639,6 @@ static fnctab_t fnctab[] = static int query (hawk_mod_t* mod, hawk_t* awk, const hawk_ooch_t* name, hawk_mod_sym_t* sym) { - hawk_oocs_t ea; int left, right, mid, n; left = 0; right = HAWK_COUNTOF(fnctab) - 1; @@ -677,9 +676,7 @@ static int query (hawk_mod_t* mod, hawk_t* awk, const hawk_ooch_t* name, hawk_mo } #endif - ea.ptr = (hawk_ooch_t*)name; - ea.len = hawk_count_oocstr(name); - hawk_seterror (awk, HAWK_ENOENT, &ea, HAWK_NULL); + hawk_seterrfmt (awk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js' not found"), name); return -1; } diff --git a/hawk/lib/mod-str.c b/hawk/lib/mod-str.c index 31bdc97a..5c59187a 100644 --- a/hawk/lib/mod-str.c +++ b/hawk/lib/mod-str.c @@ -593,7 +593,6 @@ static inttab_t inttab[] = static int query (hawk_mod_t* mod, hawk_t* awk, const hawk_ooch_t* name, hawk_mod_sym_t* sym) { - hawk_oocs_t ea; int left, right, mid, n; left = 0; right = HAWK_COUNTOF(fnctab) - 1; @@ -629,9 +628,7 @@ static int query (hawk_mod_t* mod, hawk_t* awk, const hawk_ooch_t* name, hawk_mo } } - ea.ptr = (hawk_ooch_t*)name; - ea.len = hawk_count_oocstr(name); - hawk_seterror (awk, HAWK_ENOENT, &ea, HAWK_NULL); + hawk_seterrfmt (awk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js' not found"), name); return -1; } diff --git a/hawk/lib/mod-sys.c b/hawk/lib/mod-sys.c index 75ba23e8..3d984c3e 100644 --- a/hawk/lib/mod-sys.c +++ b/hawk/lib/mod-sys.c @@ -2727,7 +2727,6 @@ static inttab_t inttab[] = static int query (hawk_mod_t* mod, hawk_t* awk, const hawk_ooch_t* name, hawk_mod_sym_t* sym) { - hawk_oocs_t ea; int left, right, mid, n; left = 0; right = HAWK_COUNTOF(fnctab) - 1; @@ -2763,9 +2762,7 @@ static int query (hawk_mod_t* mod, hawk_t* awk, const hawk_ooch_t* name, hawk_mo } } - ea.ptr = (hawk_ooch_t*)name; - ea.len = hawk_count_oocstr(name); - hawk_seterror (awk, HAWK_ENOENT, &ea, HAWK_NULL); + hawk_seterrfmt (awk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js' not found"), name); return -1; } diff --git a/hawk/lib/parse.c b/hawk/lib/parse.c index 0be66eed..f097fdc9 100644 --- a/hawk/lib/parse.c +++ b/hawk/lib/parse.c @@ -42,6 +42,30 @@ # define HAWK_DEFAULT_MODPOSTFIX "" #endif + +#define FMT_EBADVAR HAWK_T("'%.*js' not a valid variable name") +#define FMT_ECOMMA HAWK_T("comma expected in place of '%.*js'") +#define FMT_ECOLON HAWK_T("colon expected in place of '%.*js'") +#define FMT_EDUPLCL HAWK_T("duplicate local variable name - %.*js") +#define FMT_EFUNNF HAWK_T("function '%.*js' not defined") +#define FMT_EIDENT HAWK_T("identifier expected in place of '%.*js'") +#define FMT_EINTLIT HAWK_T("integer literal expected in place of '%.*js'") +#define FMT_EIONMNL HAWK_T("invalid I/O name of length %zu containing '\\0'") +#define FMT_EKWFNC HAWK_T("keyword 'function' expected in place of '%.*js'") +#define FMT_EKWIN HAWK_T("keyword 'in' expected in place of '%.*js'") +#define FMT_EKWWHL HAWK_T("keyword 'while' expected in place of '%.*js'") +#define FMT_ELBRACE HAWK_T("left brace expected in place of '%.*js'") +#define FMT_ELPAREN HAWK_T("left parenthesis expected in place of '%.*js'") +#define FMT_ENOENT_GBL_HS HAWK_T("no such global variable - %.*hs") +#define FMT_ENOENT_GBL_LS HAWK_T("no such global variable - %.*ls") +#define FMT_ERBRACK HAWK_T("right bracket expected in place of '%.*js'") +#define FMT_ERPAREN HAWK_T("right parenthesis expected in place of '%.*js'") +#define FMT_ESCOLON HAWK_T("semicolon expected in place of '%.*js'") +#define FMT_ESEGTL HAWK_T("segment '%.*js' too long") +#define FMT_EUNDEF HAWK_T("undefined identifier '%.*js'") +#define FMT_EXKWNR HAWK_T("'%.*js' not recognized") + + enum tok_t { TOK_EOF, @@ -410,9 +434,6 @@ static global_t gtab[] = #define MATCH_TERMINATOR(awk) \ (MATCH_TERMINATOR_NORMAL(awk) || MATCH_TERMINATOR_RBRACE(awk)) -#define SETERR_TOK(awk,code) \ - hawk_seterror (awk, code, HAWK_OOECS_OOCS((awk)->tok.name), &(awk)->tok.loc) - #define ADJERR_LOC(hawk,l) do { (hawk)->_gem.errloc = *(l); } while (0) static HAWK_INLINE int is_plain_var (hawk_nde_t* nde) @@ -556,7 +577,7 @@ static int parse (hawk_t* awk) /* see parse_fncall() for what is * stored into awk->tree.funs */ nde = (hawk_nde_t*)HAWK_HTB_VPTR(p); - hawk_seterrfmt (awk, &nde->loc, HAWK_EFUNNF, HAWK_T("function '%.*js' not defined"), HAWK_HTB_KLEN(p), HAWK_HTB_KPTR(p)); + hawk_seterrfmt (awk, &nde->loc, HAWK_EFUNNF, FMT_EFUNNF, HAWK_HTB_KLEN(p), HAWK_HTB_KPTR(p)); goto oops; } @@ -793,7 +814,7 @@ static int begin_include (hawk_t* awk, int once) { /* a '\0' character included in the include file name. * we don't support such a file name */ - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EIONMNL, HAWK_T("invalid I/O name of length %zu containing '\\0'"), HAWK_OOECS_LEN(awk->tok.name)); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EIONMNL, FMT_EIONMNL, HAWK_OOECS_LEN(awk->tok.name)); return -1; } @@ -984,7 +1005,7 @@ static int parse_progunit (hawk_t* awk) if (get_token(awk) <= -1) return -1; if (!MATCH(awk, TOK_INT)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EINTLIT, HAWK_T("integer literal expected in place of '%.*js'"), HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EINTLIT, FMT_EINTLIT, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); return -1; } @@ -1013,7 +1034,7 @@ static int parse_progunit (hawk_t* awk) { if (!(awk->opt.trait & HAWK_PABLOCK)) /* pattern action block not allowed */ { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EKWFNC, HAWK_T("keyword 'function' expected in place of '%.*js'"), HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EKWFNC, FMT_EKWFNC, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); return -1; } @@ -1030,7 +1051,7 @@ static int parse_progunit (hawk_t* awk) if (!MATCH(awk, TOK_LBRACE)) { - SETERR_TOK (awk, HAWK_ELBRACE); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ELBRACE, FMT_ELBRACE, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); return -1; } @@ -1044,7 +1065,7 @@ static int parse_progunit (hawk_t* awk) { if (!(awk->opt.trait & HAWK_PABLOCK)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EKWFNC, HAWK_T("keyword 'function' expected in place of '%.*js'"), HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EKWFNC, FMT_EKWFNC, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); return -1; } @@ -1061,7 +1082,7 @@ static int parse_progunit (hawk_t* awk) if (!MATCH(awk, TOK_LBRACE)) { - SETERR_TOK (awk, HAWK_ELBRACE); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ELBRACE, FMT_ELBRACE, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); return -1; } @@ -1076,7 +1097,7 @@ static int parse_progunit (hawk_t* awk) /* patternless block */ if (!(awk->opt.trait & HAWK_PABLOCK)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EKWFNC, HAWK_T("keyword 'function' expected in place of '%.*js'"), HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EKWFNC, FMT_EKWFNC, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); return -1; } @@ -1102,7 +1123,7 @@ static int parse_progunit (hawk_t* awk) if (!(awk->opt.trait & HAWK_PABLOCK)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EKWFNC, HAWK_T("keyword 'function' expected in place of '%.*js'"), HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EKWFNC, FMT_EKWFNC, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); return -1; } @@ -1176,7 +1197,7 @@ static int parse_progunit (hawk_t* awk) if (!MATCH(awk,TOK_LBRACE)) { hawk_clrpt (awk, ptn); - SETERR_TOK (awk, HAWK_ELBRACE); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ELBRACE, FMT_ELBRACE, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); return -1; } @@ -1253,7 +1274,7 @@ static hawk_nde_t* parse_function (hawk_t* awk) if (!MATCH(awk,TOK_LPAREN)) { /* a function name is not followed by a left parenthesis */ - SETERR_TOK (awk, HAWK_ELPAREN); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ELPAREN, FMT_ELPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); goto oops; } @@ -1338,7 +1359,7 @@ static hawk_nde_t* parse_function (hawk_t* awk) if (!MATCH(awk,TOK_COMMA)) { - SETERR_TOK (awk, HAWK_ECOMMA); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ECOMMA, FMT_ECOMMA, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); goto oops; } @@ -1364,7 +1385,7 @@ static hawk_nde_t* parse_function (hawk_t* awk) /* check if the function body starts with a left brace */ if (!MATCH(awk,TOK_LBRACE)) { - SETERR_TOK (awk, HAWK_ELBRACE); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ELBRACE, FMT_ELBRACE, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); goto oops; } if (get_token(awk) <= -1) goto oops; @@ -1992,7 +2013,7 @@ int hawk_delgblwithbcstr (hawk_t* hawk, const hawk_bch_t* name) n = hawk_arr_search(hawk->parse.gbls, HAWK_NUM_STATIC_GBLS, ncs.ptr, ncs.len); if (n == HAWK_ARR_NIL) { - hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("no such global variable - %.*hs"), ncs.len, ncs.ptr); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, FMT_ENOENT_GBL_HS, ncs.len, ncs.ptr); return -1; } #else @@ -2001,7 +2022,7 @@ int hawk_delgblwithbcstr (hawk_t* hawk, const hawk_bch_t* name) n = hawk_arr_search(hawk->parse.gbls, HAWK_NUM_STATIC_GBLS, wcs.ptr, wcs.len); if (n == HAWK_ARR_NIL) { - hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("no such global variable - %.*ls"), wcs.len, wcs.ptr); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, FMT_ENOENT_GBL_LS, wcs.len, wcs.ptr); hawk_freemem (hawk, wcs.ptr); return -1; } @@ -2045,7 +2066,7 @@ int hawk_delgblwithucstr (hawk_t* hawk, const hawk_uch_t* name) n = hawk_arr_search(hawk->parse.gbls, HAWK_NUM_STATIC_GBLS, mbs.ptr, mbs.len); if (n == HAWK_ARR_NIL) { - hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("no such global variable - %.*hs"), mbs.len, mbs.ptr); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, FMT_ENOENT_GBL_HS, mbs.len, mbs.ptr); hawk_freemem (hawk, mbs.ptr); return -1; } @@ -2054,7 +2075,7 @@ int hawk_delgblwithucstr (hawk_t* hawk, const hawk_uch_t* name) n = hawk_arr_search(hawk->parse.gbls, HAWK_NUM_STATIC_GBLS, ncs.ptr, ncs.len); if (n == HAWK_ARR_NIL) { - hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("no such global variable - %.*ls"), ncs.len, ncs.ptr); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, FMT_ENOENT_GBL_LS, ncs.len, ncs.ptr); return -1; } #endif @@ -2087,7 +2108,7 @@ int hawk_findgblwithbcstr (hawk_t* hawk, const hawk_bch_t* name) n = hawk_arr_search(hawk->parse.gbls, HAWK_NUM_STATIC_GBLS, ncs.ptr, ncs.len); if (n == HAWK_ARR_NIL) { - hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("no such global variable - %.*hs"), ncs.len, ncs.ptr); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, FMT_ENOENT_GBL_HS, ncs.len, ncs.ptr); return -1; } #else @@ -2096,7 +2117,7 @@ int hawk_findgblwithbcstr (hawk_t* hawk, const hawk_bch_t* name) n = hawk_arr_search(hawk->parse.gbls, HAWK_NUM_STATIC_GBLS, wcs.ptr, wcs.len); if (n == HAWK_ARR_NIL) { - hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("no such global variable - %.*ls"), wcs.len, wcs.ptr); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, FMT_ENOENT_GBL_LS, wcs.len, wcs.ptr); hawk_freemem (hawk, wcs.ptr); return -1; } @@ -2121,7 +2142,7 @@ int hawk_findgblwithucstr (hawk_t* hawk, const hawk_uch_t* name) n = hawk_arr_search(hawk->parse.gbls, HAWK_NUM_STATIC_GBLS, mbs.ptr, mbs.len); if (n == HAWK_ARR_NIL) { - hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("no such global variable - %.*hs"), mbs.len, mbs.ptr); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, FMT_ENOENT_GBL_HS, mbs.len, mbs.ptr); hawk_freemem (hawk, mbs.ptr); return -1; } @@ -2130,7 +2151,7 @@ int hawk_findgblwithucstr (hawk_t* hawk, const hawk_uch_t* name) n = hawk_arr_search(hawk->parse.gbls, HAWK_NUM_STATIC_GBLS, ncs.ptr, ncs.len); if (n == HAWK_ARR_NIL) { - hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("no such global variable - %.*ls"), ncs.len, ncs.ptr); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, FMT_ENOENT_GBL_LS, ncs.len, ncs.ptr); return -1; } #endif @@ -2153,7 +2174,7 @@ static hawk_t* collect_globals (hawk_t* awk) { if (!MATCH(awk,TOK_IDENT)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EBADVAR, HAWK_T("'%.*js' not a valid variable name"), HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EBADVAR, FMT_EBADVAR, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); return HAWK_NULL; } @@ -2177,7 +2198,7 @@ static hawk_t* collect_globals (hawk_t* awk) if (!MATCH(awk,TOK_COMMA)) { - SETERR_TOK (awk, HAWK_ECOMMA); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ECOMMA, FMT_ECOMMA, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); return HAWK_NULL; } @@ -2208,7 +2229,7 @@ static hawk_t* collect_locals (hawk_t* awk, hawk_oow_t nlcls, int istop) if (!MATCH(awk,TOK_IDENT)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EBADVAR, HAWK_T("'%.*js' not a valid variable name"), HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EBADVAR, FMT_EBADVAR, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); return HAWK_NULL; } @@ -2252,7 +2273,7 @@ static hawk_t* collect_locals (hawk_t* awk, hawk_oow_t nlcls, int istop) n = hawk_arr_search(awk->parse.lcls, nlcls, lcl.ptr, lcl.len); if (n != HAWK_ARR_NIL) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EDUPLCL, HAWK_T("duplicate local variable name - %.*js"), lcl.len, lcl.ptr); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EDUPLCL, FMT_EDUPLCL, lcl.len, lcl.ptr); return HAWK_NULL; } @@ -2263,7 +2284,7 @@ static hawk_t* collect_locals (hawk_t* awk, hawk_oow_t nlcls, int istop) if (n < awk->tree.ngbls_base) { /* it is a conflict only if it is one of a static global variable */ - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EDUPLCL, HAWK_T("duplicate local variable name - %.*js"), lcl.len, lcl.ptr); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EDUPLCL, FMT_EDUPLCL, lcl.len, lcl.ptr); return HAWK_NULL; } } @@ -2297,7 +2318,7 @@ static hawk_t* collect_locals (hawk_t* awk, hawk_oow_t nlcls, int istop) if (!MATCH(awk,TOK_COMMA)) { - SETERR_TOK (awk, HAWK_ECOMMA); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ECOMMA, FMT_ECOMMA, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); return HAWK_NULL; } @@ -2321,7 +2342,7 @@ static hawk_nde_t* parse_if (hawk_t* awk, const hawk_loc_t* xloc) if (!MATCH(awk,TOK_LPAREN)) { - SETERR_TOK (awk, HAWK_ELPAREN); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ELPAREN, FMT_ELPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); return HAWK_NULL; } if (get_token(awk) <= -1) return HAWK_NULL; @@ -2332,7 +2353,7 @@ static hawk_nde_t* parse_if (hawk_t* awk, const hawk_loc_t* xloc) if (!MATCH(awk,TOK_RPAREN)) { - SETERR_TOK (awk, HAWK_ERPAREN); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ERPAREN, FMT_ERPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); goto oops; } @@ -2395,7 +2416,7 @@ static hawk_nde_t* parse_while (hawk_t* awk, const hawk_loc_t* xloc) if (!MATCH(awk,TOK_LPAREN)) { - SETERR_TOK (awk, HAWK_ELPAREN); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ELPAREN, FMT_ELPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); goto oops; } if (get_token(awk) <= -1) goto oops; @@ -2406,7 +2427,7 @@ static hawk_nde_t* parse_while (hawk_t* awk, const hawk_loc_t* xloc) if (!MATCH(awk,TOK_RPAREN)) { - SETERR_TOK (awk, HAWK_ERPAREN); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ERPAREN, FMT_ERPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); goto oops; } @@ -2446,7 +2467,7 @@ static hawk_nde_t* parse_for (hawk_t* awk, const hawk_loc_t* xloc) if (!MATCH(awk,TOK_LPAREN)) { - SETERR_TOK (awk, HAWK_ELPAREN); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ELPAREN, FMT_ELPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); return HAWK_NULL; } if (get_token(awk) <= -1) return HAWK_NULL; @@ -2470,7 +2491,7 @@ static hawk_nde_t* parse_for (hawk_t* awk, const hawk_loc_t* xloc) if (!MATCH(awk,TOK_RPAREN)) { - SETERR_TOK (awk, HAWK_ERPAREN); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ERPAREN, FMT_ERPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); goto oops; } @@ -2498,7 +2519,7 @@ static hawk_nde_t* parse_for (hawk_t* awk, const hawk_loc_t* xloc) if (!MATCH(awk,TOK_SEMICOLON)) { - SETERR_TOK (awk, HAWK_ESCOLON); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ESCOLON, FMT_ESCOLON, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); goto oops; } } @@ -2518,7 +2539,7 @@ static hawk_nde_t* parse_for (hawk_t* awk, const hawk_loc_t* xloc) if (!MATCH(awk,TOK_SEMICOLON)) { - SETERR_TOK (awk, HAWK_ESCOLON); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ESCOLON, FMT_ESCOLON, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); goto oops; } } @@ -2542,7 +2563,7 @@ static hawk_nde_t* parse_for (hawk_t* awk, const hawk_loc_t* xloc) if (!MATCH(awk,TOK_RPAREN)) { - SETERR_TOK (awk, HAWK_ERPAREN); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ERPAREN, FMT_ERPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); goto oops; } } @@ -2597,7 +2618,7 @@ static hawk_nde_t* parse_dowhile (hawk_t* awk, const hawk_loc_t* xloc) if (!MATCH(awk,TOK_WHILE)) { - SETERR_TOK (awk, HAWK_EKWWHL); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EKWWHL, FMT_EKWWHL, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); goto oops; } @@ -2605,7 +2626,7 @@ static hawk_nde_t* parse_dowhile (hawk_t* awk, const hawk_loc_t* xloc) if (!MATCH(awk,TOK_LPAREN)) { - SETERR_TOK (awk, HAWK_ELPAREN); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ELPAREN, FMT_ELPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); goto oops; } @@ -2617,7 +2638,7 @@ static hawk_nde_t* parse_dowhile (hawk_t* awk, const hawk_loc_t* xloc) if (!MATCH(awk,TOK_RPAREN)) { - SETERR_TOK (awk, HAWK_ERPAREN); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ERPAREN, FMT_ERPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); goto oops; } @@ -2852,7 +2873,7 @@ static hawk_nde_t* parse_delete (hawk_t* awk, const hawk_loc_t* xloc) if (!MATCH(awk,TOK_IDENT)) { - SETERR_TOK (awk, HAWK_EIDENT); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EIDENT, FMT_EIDENT, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); goto oops; } @@ -2871,7 +2892,7 @@ static hawk_nde_t* parse_delete (hawk_t* awk, const hawk_loc_t* xloc) { if (!MATCH(awk,TOK_RPAREN)) { - SETERR_TOK (awk, HAWK_ERPAREN); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ERPAREN, FMT_ERPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); goto oops; } @@ -3362,7 +3383,7 @@ static hawk_nde_t* parse_expr_basic (hawk_t* awk, const hawk_loc_t* xloc) } eloc = awk->tok.loc; - n1 = parse_expr_withdc (awk, &eloc); + n1 = parse_expr_withdc(awk, &eloc); if (n1 == HAWK_NULL) { hawk_clrpt (awk, nde); @@ -3373,7 +3394,7 @@ static hawk_nde_t* parse_expr_basic (hawk_t* awk, const hawk_loc_t* xloc) { hawk_clrpt (awk, nde); hawk_clrpt (awk, n1); - SETERR_TOK (awk, HAWK_ECOLON); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ECOLON, FMT_ECOLON, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); return HAWK_NULL; } if (get_token(awk) <= -1) @@ -3384,7 +3405,7 @@ static hawk_nde_t* parse_expr_basic (hawk_t* awk, const hawk_loc_t* xloc) } eloc = awk->tok.loc; - n2 = parse_expr_withdc (awk, &eloc); + n2 = parse_expr_withdc(awk, &eloc); if (n2 == HAWK_NULL) { hawk_clrpt (awk, nde); @@ -4764,7 +4785,7 @@ static hawk_nde_t* parse_primary_lparen (hawk_t* awk, const hawk_loc_t* xloc) /* check for the closing parenthesis */ if (!MATCH(awk,TOK_RPAREN)) { - SETERR_TOK (awk, HAWK_ERPAREN); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ERPAREN, FMT_ERPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); goto oops; } @@ -4786,7 +4807,7 @@ static hawk_nde_t* parse_primary_lparen (hawk_t* awk, const hawk_loc_t* xloc) { if (!(awk->opt.trait & HAWK_TOLERANT) && !MATCH(awk,TOK_IN)) { - SETERR_TOK (awk, HAWK_EKWIN); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EKWIN, FMT_EKWIN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); goto oops; } } @@ -5151,7 +5172,7 @@ static int dup_ident_and_get_next (hawk_t* awk, const hawk_loc_t* xloc, hawk_ooc * TOK_XGLOBAL to TOK_XRESET are excuded from the check for that reason. */ if (!MATCH(awk, TOK_IDENT) && !(MATCH_RANGE(awk, TOK_BEGIN, TOK_GETLINE))) { - SETERR_TOK (awk, HAWK_EIDENT); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EIDENT, FMT_EIDENT, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); goto oops; } @@ -5231,7 +5252,7 @@ static hawk_nde_t* parse_primary_ident_noseg (hawk_t* awk, const hawk_loc_t* xlo else { /* an intrinsic function should be in the form of the function call */ - SETERR_TOK (awk, HAWK_ELPAREN); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ELPAREN, FMT_ELPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); } } /* now we know that name is a normal identifier. */ @@ -5367,7 +5388,7 @@ static hawk_nde_t* parse_primary_ident_noseg (hawk_t* awk, const hawk_loc_t* xlo else { /* undefined variable */ - hawk_seterrfmt (awk, xloc, HAWK_EUNDEF, HAWK_T("undefined identifier '%.*js'"), name->len, name->ptr); + hawk_seterrfmt (awk, xloc, HAWK_EUNDEF, FMT_EUNDEF, name->len, name->ptr); } } } @@ -5396,7 +5417,7 @@ static hawk_nde_t* parse_primary_ident_segs (hawk_t* awk, const hawk_loc_t* xloc case HAWK_MOD_FNC: if ((awk->opt.trait & sym.u.fnc.trait) != sym.u.fnc.trait) { - hawk_seterrfmt (awk, xloc, HAWK_EUNDEF, HAWK_T("undefined identifier '%.*js'"), full->len, full->ptr); + hawk_seterrfmt (awk, xloc, HAWK_EUNDEF, FMT_EUNDEF, full->len, full->ptr); break; } @@ -5411,7 +5432,7 @@ static hawk_nde_t* parse_primary_ident_segs (hawk_t* awk, const hawk_loc_t* xloc } else { - SETERR_TOK (awk, HAWK_ELPAREN); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ELPAREN, FMT_ELPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); } break; @@ -5427,7 +5448,7 @@ static hawk_nde_t* parse_primary_ident_segs (hawk_t* awk, const hawk_loc_t* xloc default: /* TODO: support MOD_VAR */ - hawk_seterrfmt (awk, xloc, HAWK_EUNDEF, HAWK_T("undefined identifier '%.*js'"), full->len, full->ptr); + hawk_seterrfmt (awk, xloc, HAWK_EUNDEF, FMT_EUNDEF, full->len, full->ptr); break; } } @@ -5538,7 +5559,7 @@ static hawk_nde_t* parse_hashidx (hawk_t* awk, const hawk_oocs_t* name, const ha if (!MATCH(awk,TOK_RBRACK)) { hawk_clrpt (awk, idx); - SETERR_TOK (awk, HAWK_ERBRACK); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ERBRACK, FMT_ERBRACK, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); return HAWK_NULL; } @@ -5629,7 +5650,7 @@ static hawk_nde_t* parse_hashidx (hawk_t* awk, const hawk_oocs_t* name, const ha } /* undefined variable */ - hawk_seterrfmt (awk, xloc, HAWK_EUNDEF, HAWK_T("undefined identifier '%.*js'"), name->len, name->ptr); + hawk_seterrfmt (awk, xloc, HAWK_EUNDEF, FMT_EUNDEF, name->len, name->ptr); exit_func: hawk_clrpt (awk, idx); @@ -5680,7 +5701,7 @@ static hawk_nde_t* parse_fncall (hawk_t* awk, const hawk_oocs_t* name, hawk_fnc_ if (!MATCH(awk,TOK_COMMA)) { - SETERR_TOK (awk, HAWK_ECOMMA); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ECOMMA, FMT_ECOMMA, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); goto oops; } @@ -6458,7 +6479,7 @@ retry: type = classify_ident(awk, HAWK_OOECS_OOCS(tok->name)); if (type == TOK_IDENT) { - SETERR_TOK (awk, HAWK_EXKWNR); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EXKWNR, FMT_EXKWNR, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); return -1; } SET_TOKEN_TYPE (awk, tok, type); @@ -6542,9 +6563,8 @@ retry: if (skip_semicolon_after_include && !(awk->opt.trait & HAWK_NEWLINE)) { - /* semiclon has not been skipped yet and the - * newline option is not set. */ - hawk_seterror (awk, HAWK_ESCOLON, HAWK_OOECS_OOCS(tok->name), &tok->loc); + /* semiclon has not been skipped yet and the newline option is not set. */ + hawk_seterrfmt (awk, &tok->loc, HAWK_ESCOLON, FMT_ESCOLON, HAWK_OOECS_LEN(tok->name), HAWK_OOECS_PTR(tok->name)); return -1; } @@ -6989,7 +7009,6 @@ static hawk_mod_t* query_module (hawk_t* awk, const hawk_oocs_t segs[], int nseg { hawk_rbt_pair_t* pair; hawk_mod_data_t* mdp; - hawk_oocs_t ea; int n; HAWK_ASSERT (nsegs == 2); @@ -7019,9 +7038,7 @@ static hawk_mod_t* query_module (hawk_t* awk, const hawk_oocs_t segs[], int nseg if (segs[0].len > HAWK_COUNTOF(buf) - 15) { /* module name too long */ - ea.ptr = segs[0].ptr; - ea.len = segs[0].len; - hawk_seterror (awk, HAWK_ESEGTL, &ea, HAWK_NULL); + hawk_seterrfmt (awk, HAWK_NULL, HAWK_ESEGTL, FMT_ESEGTL, segs[0].len, segs[0].ptr); return HAWK_NULL; } @@ -7040,10 +7057,7 @@ static hawk_mod_t* query_module (hawk_t* awk, const hawk_oocs_t segs[], int nseg /*if (n >= HAWK_COUNTOF(static_modtab)) { - - ea.ptr = segs[0].ptr; - ea.len = segs[0].len; - hawk_seterror (awk, HAWK_ENOENT, &ea, HAWK_NULL); + hawk_seterrfmt (awk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%.*js' not found"), segs[0].len, segs[0].ptr); return HAWK_NULL; }*/ diff --git a/hawk/mod/mod-mysql.c b/hawk/mod/mod-mysql.c index 33abaf24..bb17e0ad 100644 --- a/hawk/mod/mod-mysql.c +++ b/hawk/mod/mod-mysql.c @@ -27,15 +27,15 @@ #include "mod-mysql.h" #include #include "../cmn/mem-prv.h" -#include -#include +#include +#include #if !defined(MYSQL_OPT_RECONNECT) # define DUMMY_OPT_RECONNECT 31231 /* randomly chosen */ #endif #define __IMAP_NODE_T_DATA MYSQL* mysql; int connect_ever_attempted; -#define __IMAP_LIST_T_DATA int errnum; qse_char_t errmsg[256]; +#define __IMAP_LIST_T_DATA int errnum; hawk_ooch_t errmsg[256]; #define __IMAP_LIST_T sql_list_t #define __IMAP_NODE_T sql_node_t #define __MAKE_IMAP_NODE __new_sql_node @@ -64,37 +64,37 @@ struct rtx_data_t }; typedef struct rtx_data_t rtx_data_t; -static sql_node_t* new_sql_node (qse_awk_rtx_t* rtx, sql_list_t* sql_list) +static sql_node_t* new_sql_node (hawk_rtx_t* rtx, sql_list_t* sql_list) { sql_node_t* sql_node; sql_node = __new_sql_node(rtx, sql_list); - if (!sql_node) return QSE_NULL; + if (!sql_node) return HAWK_NULL; - sql_node->mysql = mysql_init(QSE_NULL); + sql_node->mysql = mysql_init(HAWK_NULL); if (!sql_node->mysql) { - qse_awk_rtx_seterrfmt (rtx, QSE_AWK_ENOMEM, QSE_NULL, QSE_T("unable to allocate a mysql object")); - return QSE_NULL; + hawk_rtx_seterrfmt (rtx, HAWK_ENOMEM, HAWK_NULL, HAWK_T("unable to allocate a mysql object")); + return HAWK_NULL; } return sql_node; } -static void free_sql_node (qse_awk_rtx_t* rtx, sql_list_t* sql_list, sql_node_t* sql_node) +static void free_sql_node (hawk_rtx_t* rtx, sql_list_t* sql_list, sql_node_t* sql_node) { mysql_close (sql_node->mysql); - sql_node->mysql = QSE_NULL; + sql_node->mysql = HAWK_NULL; __free_sql_node (rtx, sql_list, sql_node); } -static res_node_t* new_res_node (qse_awk_rtx_t* rtx, res_list_t* res_list, MYSQL_RES* res) +static res_node_t* new_res_node (hawk_rtx_t* rtx, res_list_t* res_list, MYSQL_RES* res) { res_node_t* res_node; res_node = __new_res_node(rtx, res_list); - if (!res_node) return QSE_NULL; + if (!res_node) return HAWK_NULL; res_node->res = res; res_node->num_fields = mysql_num_fields(res); @@ -102,181 +102,181 @@ static res_node_t* new_res_node (qse_awk_rtx_t* rtx, res_list_t* res_list, MYSQL return res_node; } -static void free_res_node (qse_awk_rtx_t* rtx, res_list_t* res_list, res_node_t* res_node) +static void free_res_node (hawk_rtx_t* rtx, res_list_t* res_list, res_node_t* res_node) { mysql_free_result (res_node->res); - res_node->res = QSE_NULL; + res_node->res = HAWK_NULL; __free_res_node (rtx, res_list, res_node); } /* ------------------------------------------------------------------------ */ -static QSE_INLINE sql_list_t* rtx_to_sql_list (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static HAWK_INLINE sql_list_t* rtx_to_sql_list (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { - qse_rbt_pair_t* pair; + hawk_rbt_pair_t* pair; rtx_data_t* data; - pair = qse_rbt_search((qse_rbt_t*)fi->mod->ctx, &rtx, QSE_SIZEOF(rtx)); - QSE_ASSERT (pair != QSE_NULL); - data = (rtx_data_t*)QSE_RBT_VPTR(pair); + pair = hawk_rbt_search((hawk_rbt_t*)fi->mod->ctx, &rtx, HAWK_SIZEOF(rtx)); + HAWK_ASSERT (pair != HAWK_NULL); + data = (rtx_data_t*)HAWK_RBT_VPTR(pair); return &data->sql_list; } -static QSE_INLINE sql_node_t* get_sql_list_node (sql_list_t* sql_list, qse_awk_int_t id) +static HAWK_INLINE sql_node_t* get_sql_list_node (sql_list_t* sql_list, hawk_int_t id) { - if (id < 0 || id >= sql_list->map.high || !sql_list->map.tab[id]) return QSE_NULL; + if (id < 0 || id >= sql_list->map.high || !sql_list->map.tab[id]) return HAWK_NULL; return sql_list->map.tab[id]; } -static QSE_INLINE res_list_t* rtx_to_res_list (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static HAWK_INLINE res_list_t* rtx_to_res_list (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { - qse_rbt_pair_t* pair; + hawk_rbt_pair_t* pair; rtx_data_t* data; - pair = qse_rbt_search((qse_rbt_t*)fi->mod->ctx, &rtx, QSE_SIZEOF(rtx)); - QSE_ASSERT (pair != QSE_NULL); - data = (rtx_data_t*)QSE_RBT_VPTR(pair); + pair = hawk_rbt_search((hawk_rbt_t*)fi->mod->ctx, &rtx, HAWK_SIZEOF(rtx)); + HAWK_ASSERT (pair != HAWK_NULL); + data = (rtx_data_t*)HAWK_RBT_VPTR(pair); return &data->res_list; } -static QSE_INLINE res_node_t* get_res_list_node (res_list_t* res_list, qse_awk_int_t id) +static HAWK_INLINE res_node_t* get_res_list_node (res_list_t* res_list, hawk_int_t id) { - if (id < 0 || id >= res_list->map.high || !res_list->map.tab[id]) return QSE_NULL; + if (id < 0 || id >= res_list->map.high || !res_list->map.tab[id]) return HAWK_NULL; return res_list->map.tab[id]; } /* ------------------------------------------------------------------------ */ -static void set_error_on_sql_list (qse_awk_rtx_t* rtx, sql_list_t* sql_list, const qse_char_t* errfmt, ...) +static void set_error_on_sql_list (hawk_rtx_t* rtx, sql_list_t* sql_list, const hawk_ooch_t* errfmt, ...) { if (errfmt) { va_list ap; va_start (ap, errfmt); - qse_strxvfmt (sql_list->errmsg, QSE_COUNTOF(sql_list->errmsg), errfmt, ap); + hawk_strxvfmt (sql_list->errmsg, HAWK_COUNTOF(sql_list->errmsg), errfmt, ap); va_end (ap); } else { - qse_strxcpy (sql_list->errmsg, QSE_COUNTOF(sql_list->errmsg), qse_awk_rtx_geterrmsg(rtx)); + hawk_strxcpy (sql_list->errmsg, HAWK_COUNTOF(sql_list->errmsg), hawk_rtx_geterrmsg(rtx)); } } -static int fnc_errmsg (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_errmsg (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { sql_list_t* sql_list; - qse_awk_val_t* retv; + hawk_val_t* retv; sql_list = rtx_to_sql_list(rtx, fi); - retv = qse_awk_rtx_makestrvalwithstr(rtx, sql_list->errmsg); + retv = hawk_rtx_makestrvalwithstr(rtx, sql_list->errmsg); if (!retv) return -1; - qse_awk_rtx_setretval (rtx, retv); + hawk_rtx_setretval (rtx, retv); return 0; } /* ------------------------------------------------------------------------ */ -static sql_node_t* get_sql_list_node_with_arg (qse_awk_rtx_t* rtx, sql_list_t* sql_list, qse_awk_val_t* arg) +static sql_node_t* get_sql_list_node_with_arg (hawk_rtx_t* rtx, sql_list_t* sql_list, hawk_val_t* arg) { - qse_awk_int_t id; + hawk_int_t id; sql_node_t* sql_node; - if (qse_awk_rtx_valtoint(rtx, arg, &id) <= -1) + if (hawk_rtx_valtoint(rtx, arg, &id) <= -1) { - set_error_on_sql_list (rtx, sql_list, QSE_T("illegal instance id")); - return QSE_NULL; + set_error_on_sql_list (rtx, sql_list, HAWK_T("illegal instance id")); + return HAWK_NULL; } else if (!(sql_node = get_sql_list_node(sql_list, id))) { - set_error_on_sql_list (rtx, sql_list, QSE_T("invalid instance id - %zd"), (qse_size_t)id); - return QSE_NULL; + set_error_on_sql_list (rtx, sql_list, HAWK_T("invalid instance id - %zd"), (hawk_size_t)id); + return HAWK_NULL; } return sql_node; } -static res_node_t* get_res_list_node_with_arg (qse_awk_rtx_t* rtx, sql_list_t* sql_list, res_list_t* res_list, qse_awk_val_t* arg) +static res_node_t* get_res_list_node_with_arg (hawk_rtx_t* rtx, sql_list_t* sql_list, res_list_t* res_list, hawk_val_t* arg) { - qse_awk_int_t id; + hawk_int_t id; res_node_t* res_node; - if (qse_awk_rtx_valtoint(rtx, arg, &id) <= -1) + if (hawk_rtx_valtoint(rtx, arg, &id) <= -1) { - set_error_on_sql_list (rtx, sql_list, QSE_T("illegal result id")); - return QSE_NULL; + set_error_on_sql_list (rtx, sql_list, HAWK_T("illegal result id")); + return HAWK_NULL; } else if (!(res_node = get_res_list_node(res_list, id))) { - set_error_on_sql_list (rtx, sql_list, QSE_T("invalid result id - %zd"), (qse_size_t)id); - return QSE_NULL; + set_error_on_sql_list (rtx, sql_list, HAWK_T("invalid result id - %zd"), (hawk_size_t)id); + return HAWK_NULL; } return res_node; } /* ------------------------------------------------------------------------ */ -static int fnc_open (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_open (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { sql_list_t* sql_list; - sql_node_t* sql_node = QSE_NULL; - qse_awk_int_t ret = -1; - qse_awk_val_t* retv; + sql_node_t* sql_node = HAWK_NULL; + hawk_int_t ret = -1; + hawk_val_t* retv; sql_list = rtx_to_sql_list(rtx, fi); sql_node = new_sql_node(rtx, sql_list); if (sql_node) ret = sql_node->id; - else set_error_on_sql_list (rtx, sql_list, QSE_NULL); + else set_error_on_sql_list (rtx, sql_list, HAWK_NULL); /* ret may not be a statically managed number. * error checking is required */ - retv = qse_awk_rtx_makeintval(rtx, ret); - if (retv == QSE_NULL) + retv = hawk_rtx_makeintval(rtx, ret); + if (retv == HAWK_NULL) { if (sql_node) free_sql_node (rtx, sql_list, sql_node); return -1; } - qse_awk_rtx_setretval (rtx, retv); + hawk_rtx_setretval (rtx, retv); return 0; } -static int fnc_close (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_close (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { sql_list_t* sql_list; sql_node_t* sql_node; int ret = -1; sql_list = rtx_to_sql_list(rtx, fi); - sql_node = get_sql_list_node_with_arg(rtx, sql_list, qse_awk_rtx_getarg(rtx, 0)); + sql_node = get_sql_list_node_with_arg(rtx, sql_list, hawk_rtx_getarg(rtx, 0)); if (sql_node) { free_sql_node (rtx, sql_list, sql_node); ret = 0; } - qse_awk_rtx_setretval (rtx, qse_awk_rtx_makeintval(rtx, ret)); + hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, ret)); return 0; } #if 0 -static int fnc_get_option (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_get_option (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { sql_list_t* sql_list; sql_node_t* sql_node; int ret = -1, take_rtx_err = 0; sql_list = rtx_to_sql_list(rtx, fi); - sql_node = get_sql_list_node_with_arg(rtx, sql_list, qse_awk_rtx_getarg(rtx, 0)); + sql_node = get_sql_list_node_with_arg(rtx, sql_list, hawk_rtx_getarg(rtx, 0)); if (sql_node) { - qse_awk_int_t id, tv; + hawk_int_t id, tv; union { unsigned int ui; int b; } v; - if (qse_awk_rtx_valtoint(rtx, qse_awk_rtx_getarg(rtx, 1), &id) <= -1) + if (hawk_rtx_valtoint(rtx, hawk_rtx_getarg(rtx, 1), &id) <= -1) { take_rtx_err = 1; goto oops; @@ -290,15 +290,15 @@ static int fnc_get_option (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) /* unsigned int * */ if (mysql_get_option(sql_node->mysql, id, &v.ui) != 0) { - set_error_on_sql_list (rtx, sql_list, QSE_T("%hs"), mysql_errstr(sql_node->mysql)); + set_error_on_sql_list (rtx, sql_list, HAWK_T("%hs"), mysql_errstr(sql_node->mysql)); goto done; } - retv = qse_awk_rtx_makeintval(rtx, v.ui); - if (qse_awk_rtx_setrefval(rtx, (qse_awk_val_ref_t*)qse_awk_rtx_getarg(rtx, 2), retv) <= -1) + retv = hawk_rtx_makeintval(rtx, v.ui); + if (hawk_rtx_setrefval(rtx, (hawk_val_ref_t*)hawk_rtx_getarg(rtx, 2), retv) <= -1) { - qse_awk_rtx_refupval(rtx, retv); - qse_awk_rtx_refdownval(rtx, retv); + hawk_rtx_refupval(rtx, retv); + hawk_rtx_refdownval(rtx, retv); goto oops; } break; @@ -308,33 +308,33 @@ static int fnc_get_option (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) /* bool * */ if (mysql_get_option(sql_node->mysql, id, &v.b) != 0) { - set_error_on_sql_list (rtx, sql_list, QSE_T("%hs"), mysql_errstr(sql_node->mysql)); + set_error_on_sql_list (rtx, sql_list, HAWK_T("%hs"), mysql_errstr(sql_node->mysql)); goto done; } - retv = qse_awk_rtx_makeintval(rtx, v.b); + retv = hawk_rtx_makeintval(rtx, v.b); if (!retv) goto oops; - if (qse_awk_rtx_setrefval(rtx, (qse_awk_val_ref_t*)qse_awk_rtx_getarg(rtx, 2), retv) <= -1) + if (hawk_rtx_setrefval(rtx, (hawk_val_ref_t*)hawk_rtx_getarg(rtx, 2), retv) <= -1) { - qse_awk_rtx_refupval(rtx, retv); - qse_awk_rtx_refdownval(rtx, retv); + hawk_rtx_refupval(rtx, retv); + hawk_rtx_refdownval(rtx, retv); goto oops; } break; #else /* the system without MYSQL_OPT_RECONNECT available. return 1 all the time */ - if (qse_awk_rtx_setrefval(rtx, (qse_awk_val_ref_t*)qse_awk_rtx_getarg(rtx, 2), qse_awk_rtx_makeintval(rtx, 1)) <= -1) + if (hawk_rtx_setrefval(rtx, (hawk_val_ref_t*)hawk_rtx_getarg(rtx, 2), hawk_rtx_makeintval(rtx, 1)) <= -1) { - qse_awk_rtx_refupval(rtx, retv); - qse_awk_rtx_refdownval(rtx, retv); + hawk_rtx_refupval(rtx, retv); + hawk_rtx_refdownval(rtx, retv); goto oops; } break; #endif default: - set_error_on_sql_list (rtx, sql_list, QSE_T("unsupported option id - %zd"), (qse_size_t)id); + set_error_on_sql_list (rtx, sql_list, HAWK_T("unsupported option id - %zd"), (hawk_size_t)id); goto done; } @@ -342,27 +342,27 @@ static int fnc_get_option (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) } done: - if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, QSE_NULL); - qse_awk_rtx_setretval (rtx, qse_awk_rtx_makeintval(rtx, ret)); + if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL); + hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, ret)); return 0; oops: - if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, QSE_NULL); + if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL); return -1; } #endif -static int fnc_set_option (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_set_option (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { sql_list_t* sql_list; sql_node_t* sql_node; int ret = -1, take_rtx_err = 0; sql_list = rtx_to_sql_list(rtx, fi); - sql_node = get_sql_list_node_with_arg(rtx, sql_list, qse_awk_rtx_getarg(rtx, 0)); + sql_node = get_sql_list_node_with_arg(rtx, sql_list, hawk_rtx_getarg(rtx, 0)); if (sql_node) { - qse_awk_int_t id, tv; + hawk_int_t id, tv; void* vptr; union { @@ -370,7 +370,7 @@ static int fnc_set_option (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) int b; } v; - if (qse_awk_rtx_valtoint(rtx, qse_awk_rtx_getarg(rtx, 1), &id) <= -1) + if (hawk_rtx_valtoint(rtx, hawk_rtx_getarg(rtx, 1), &id) <= -1) { take_rtx_err = 1; goto oops; @@ -384,7 +384,7 @@ static int fnc_set_option (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) case MYSQL_OPT_READ_TIMEOUT: case MYSQL_OPT_WRITE_TIMEOUT: /* unsigned int * */ - if (qse_awk_rtx_valtoint(rtx, qse_awk_rtx_getarg(rtx, 2), &tv) <= -1) + if (hawk_rtx_valtoint(rtx, hawk_rtx_getarg(rtx, 2), &tv) <= -1) { take_rtx_err = 1; goto oops; @@ -397,7 +397,7 @@ static int fnc_set_option (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) #if defined(MYSQL_OPT_RECONNECT) case MYSQL_OPT_RECONNECT: /* bool * */ - if (qse_awk_rtx_valtoint(rtx, qse_awk_rtx_getarg(rtx, 2), &tv) <= -1) + if (hawk_rtx_valtoint(rtx, hawk_rtx_getarg(rtx, 2), &tv) <= -1) { take_rtx_err = 1; goto oops; @@ -413,13 +413,13 @@ static int fnc_set_option (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) #endif default: - set_error_on_sql_list (rtx, sql_list, QSE_T("unsupported option id - %zd"), (qse_size_t)id); + set_error_on_sql_list (rtx, sql_list, HAWK_T("unsupported option id - %zd"), (hawk_size_t)id); goto done; } if (mysql_options(sql_node->mysql, id, vptr) != 0) { - set_error_on_sql_list (rtx, sql_list, QSE_T("%hs"), mysql_error(sql_node->mysql)); + set_error_on_sql_list (rtx, sql_list, HAWK_T("%hs"), mysql_error(sql_node->mysql)); goto done; } @@ -427,44 +427,44 @@ static int fnc_set_option (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) } done: - if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, QSE_NULL); - qse_awk_rtx_setretval (rtx, qse_awk_rtx_makeintval(rtx, ret)); + if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL); + hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, ret)); return 0; oops: - if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, QSE_NULL); + if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL); return -1; } -static int fnc_connect (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_connect (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { sql_list_t* sql_list; sql_node_t* sql_node; int ret = -1, take_rtx_err = 0; - qse_awk_val_t* a1, * a2, * a3, * a4, * a6; - qse_mchar_t* host = QSE_NULL; - qse_mchar_t* user = QSE_NULL; - qse_mchar_t* pass = QSE_NULL; - qse_mchar_t* db = QSE_NULL; - qse_awk_int_t port = 0; - qse_mchar_t* usck = QSE_NULL; + hawk_val_t* a1, * a2, * a3, * a4, * a6; + hawk_mchar_t* host = HAWK_NULL; + hawk_mchar_t* user = HAWK_NULL; + hawk_mchar_t* pass = HAWK_NULL; + hawk_mchar_t* db = HAWK_NULL; + hawk_int_t port = 0; + hawk_mchar_t* usck = HAWK_NULL; sql_list = rtx_to_sql_list(rtx, fi); - sql_node = get_sql_list_node_with_arg(rtx, sql_list, qse_awk_rtx_getarg(rtx, 0)); + sql_node = get_sql_list_node_with_arg(rtx, sql_list, hawk_rtx_getarg(rtx, 0)); if (sql_node) { - qse_size_t nargs; + hawk_size_t nargs; - nargs = qse_awk_rtx_getnargs(rtx); + nargs = hawk_rtx_getnargs(rtx); - a1 = qse_awk_rtx_getarg(rtx, 1); - a2 = qse_awk_rtx_getarg(rtx, 2); - a3 = qse_awk_rtx_getarg(rtx, 3); + a1 = hawk_rtx_getarg(rtx, 1); + a2 = hawk_rtx_getarg(rtx, 2); + a3 = hawk_rtx_getarg(rtx, 3); - if (!(host = qse_awk_rtx_getvalmbs(rtx, a1, QSE_NULL)) || - !(user = qse_awk_rtx_getvalmbs(rtx, a2, QSE_NULL)) || - !(pass = qse_awk_rtx_getvalmbs(rtx, a3, QSE_NULL))) + if (!(host = hawk_rtx_getvalmbs(rtx, a1, HAWK_NULL)) || + !(user = hawk_rtx_getvalmbs(rtx, a2, HAWK_NULL)) || + !(pass = hawk_rtx_getvalmbs(rtx, a3, HAWK_NULL))) { arg_fail: take_rtx_err = 1; @@ -473,20 +473,20 @@ static int fnc_connect (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) if (nargs >= 5) { - a4 = qse_awk_rtx_getarg(rtx, 4); - if (!(db = qse_awk_rtx_getvalmbs(rtx, a4, QSE_NULL))) goto arg_fail; - if (nargs >= 6 && qse_awk_rtx_valtoint(rtx, qse_awk_rtx_getarg(rtx, 5), &port) <= -1) goto arg_fail; + a4 = hawk_rtx_getarg(rtx, 4); + if (!(db = hawk_rtx_getvalmbs(rtx, a4, HAWK_NULL))) goto arg_fail; + if (nargs >= 6 && hawk_rtx_valtoint(rtx, hawk_rtx_getarg(rtx, 5), &port) <= -1) goto arg_fail; if (nargs >= 7) { - a6 = qse_awk_rtx_getarg(rtx, 6); - if (!(usck = qse_awk_rtx_getvalmbs(rtx, a6, QSE_NULL))) goto arg_fail; + a6 = hawk_rtx_getarg(rtx, 6); + if (!(usck = hawk_rtx_getvalmbs(rtx, a6, HAWK_NULL))) goto arg_fail; } } if (!mysql_real_connect(sql_node->mysql, host, user, pass, db, port, usck, 0)) { - set_error_on_sql_list (rtx, sql_list, QSE_T("%hs"), mysql_error(sql_node->mysql)); + set_error_on_sql_list (rtx, sql_list, HAWK_T("%hs"), mysql_error(sql_node->mysql)); sql_node->connect_ever_attempted = 1; /* doesn't matter if mysql_real_connect() failed */ goto done; } @@ -496,14 +496,14 @@ static int fnc_connect (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) } done: - if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, QSE_NULL); - if (usck) qse_awk_rtx_freevalmbs (rtx, a6, usck); - if (db) qse_awk_rtx_freevalmbs (rtx, a4, db); - if (pass) qse_awk_rtx_freevalmbs (rtx, a3, pass); - if (user) qse_awk_rtx_freevalmbs (rtx, a2, user); - if (host) qse_awk_rtx_freevalmbs (rtx, a1, host); + if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL); + if (usck) hawk_rtx_freevalmbs (rtx, a6, usck); + if (db) hawk_rtx_freevalmbs (rtx, a4, db); + if (pass) hawk_rtx_freevalmbs (rtx, a3, pass); + if (user) hawk_rtx_freevalmbs (rtx, a2, user); + if (host) hawk_rtx_freevalmbs (rtx, a1, host); - qse_awk_rtx_setretval (rtx, qse_awk_rtx_makeintval(rtx, ret)); + hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, ret)); return 0; } @@ -511,26 +511,26 @@ done: do { \ if (!(sql_node)->connect_ever_attempted) \ { \ - set_error_on_sql_list (rtx, sql_list, QSE_T("not connected")); \ + set_error_on_sql_list (rtx, sql_list, HAWK_T("not connected")); \ goto done; \ } \ } while(0) -static int fnc_ping (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_ping (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { sql_list_t* sql_list; sql_node_t* sql_node; int ret = -1, take_rtx_err = 0; sql_list = rtx_to_sql_list(rtx, fi); - sql_node = get_sql_list_node_with_arg(rtx, sql_list, qse_awk_rtx_getarg(rtx, 0)); + sql_node = get_sql_list_node_with_arg(rtx, sql_list, hawk_rtx_getarg(rtx, 0)); if (sql_node) { ENSURE_CONNECT_EVER_ATTEMPTED(rtx, sql_list, sql_node); if (mysql_ping(sql_node->mysql) != 0) { - set_error_on_sql_list (rtx, sql_list, QSE_T("%hs"), mysql_error(sql_node->mysql)); + set_error_on_sql_list (rtx, sql_list, HAWK_T("%hs"), mysql_error(sql_node->mysql)); goto done; } @@ -538,36 +538,36 @@ static int fnc_ping (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) } done: - if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, QSE_NULL); - qse_awk_rtx_setretval (rtx, qse_awk_rtx_makeintval(rtx, ret)); + if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL); + hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, ret)); return 0; oops: - if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, QSE_NULL); + if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL); return -1; } -static int fnc_select_db (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_select_db (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { sql_list_t* sql_list; sql_node_t* sql_node; - qse_awk_val_t* a1; - qse_mchar_t* db = QSE_NULL; + hawk_val_t* a1; + hawk_mchar_t* db = HAWK_NULL; int ret = -1, take_rtx_err = 0; sql_list = rtx_to_sql_list(rtx, fi); - sql_node = get_sql_list_node_with_arg(rtx, sql_list, qse_awk_rtx_getarg(rtx, 0)); + sql_node = get_sql_list_node_with_arg(rtx, sql_list, hawk_rtx_getarg(rtx, 0)); if (sql_node) { - a1 = qse_awk_rtx_getarg(rtx, 1); + a1 = hawk_rtx_getarg(rtx, 1); - if (!(db = qse_awk_rtx_getvalmbs(rtx, a1, QSE_NULL))) { take_rtx_err = 1; goto oops; } + if (!(db = hawk_rtx_getvalmbs(rtx, a1, HAWK_NULL))) { take_rtx_err = 1; goto oops; } ENSURE_CONNECT_EVER_ATTEMPTED(rtx, sql_list, sql_node); if (mysql_select_db(sql_node->mysql, db) != 0) { - set_error_on_sql_list (rtx, sql_list, QSE_T("%hs"), mysql_error(sql_node->mysql)); + set_error_on_sql_list (rtx, sql_list, HAWK_T("%hs"), mysql_error(sql_node->mysql)); goto done; } @@ -575,36 +575,36 @@ static int fnc_select_db (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) } done: - if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, QSE_NULL); - if (db) qse_awk_rtx_freevalmbs (rtx, a1, db); - qse_awk_rtx_setretval (rtx, qse_awk_rtx_makeintval(rtx, ret)); + if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL); + if (db) hawk_rtx_freevalmbs (rtx, a1, db); + hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, ret)); return 0; oops: - if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, QSE_NULL); + if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL); return -1; } -static int fnc_autocommit (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_autocommit (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { sql_list_t* sql_list; sql_node_t* sql_node; int ret = -1, take_rtx_err = 0; sql_list = rtx_to_sql_list(rtx, fi); - sql_node = get_sql_list_node_with_arg(rtx, sql_list, qse_awk_rtx_getarg(rtx, 0)); + sql_node = get_sql_list_node_with_arg(rtx, sql_list, hawk_rtx_getarg(rtx, 0)); if (sql_node) { int v; - v = qse_awk_rtx_valtobool(rtx, qse_awk_rtx_getarg(rtx, 1)); + v = hawk_rtx_valtobool(rtx, hawk_rtx_getarg(rtx, 1)); ENSURE_CONNECT_EVER_ATTEMPTED(rtx, sql_list, sql_node); if (mysql_autocommit(sql_node->mysql, v) != 0) { - set_error_on_sql_list (rtx, sql_list, QSE_T("%hs"), mysql_error(sql_node->mysql)); + set_error_on_sql_list (rtx, sql_list, HAWK_T("%hs"), mysql_error(sql_node->mysql)); goto done; } @@ -612,34 +612,34 @@ static int fnc_autocommit (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) } done: - if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, QSE_NULL); - qse_awk_rtx_setretval (rtx, qse_awk_rtx_makeintval(rtx, ret)); + if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL); + hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, ret)); return 0; oops: - if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, QSE_NULL); + if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL); return -1; } -static int fnc_commit (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_commit (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { sql_list_t* sql_list; sql_node_t* sql_node; int ret = -1, take_rtx_err = 0; sql_list = rtx_to_sql_list(rtx, fi); - sql_node = get_sql_list_node_with_arg(rtx, sql_list, qse_awk_rtx_getarg(rtx, 0)); + sql_node = get_sql_list_node_with_arg(rtx, sql_list, hawk_rtx_getarg(rtx, 0)); if (sql_node) { int v; - v = qse_awk_rtx_valtobool(rtx, qse_awk_rtx_getarg(rtx, 1)); + v = hawk_rtx_valtobool(rtx, hawk_rtx_getarg(rtx, 1)); ENSURE_CONNECT_EVER_ATTEMPTED(rtx, sql_list, sql_node); if (mysql_commit(sql_node->mysql) != 0) { - set_error_on_sql_list (rtx, sql_list, QSE_T("%hs"), mysql_error(sql_node->mysql)); + set_error_on_sql_list (rtx, sql_list, HAWK_T("%hs"), mysql_error(sql_node->mysql)); goto done; } @@ -647,34 +647,34 @@ static int fnc_commit (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) } done: - if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, QSE_NULL); - qse_awk_rtx_setretval (rtx, qse_awk_rtx_makeintval(rtx, ret)); + if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL); + hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, ret)); return 0; oops: - if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, QSE_NULL); + if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL); return -1; } -static int fnc_rollback (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_rollback (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { sql_list_t* sql_list; sql_node_t* sql_node; int ret = -1, take_rtx_err = 0; sql_list = rtx_to_sql_list(rtx, fi); - sql_node = get_sql_list_node_with_arg(rtx, sql_list, qse_awk_rtx_getarg(rtx, 0)); + sql_node = get_sql_list_node_with_arg(rtx, sql_list, hawk_rtx_getarg(rtx, 0)); if (sql_node) { int v; - v = qse_awk_rtx_valtobool(rtx, qse_awk_rtx_getarg(rtx, 1)); + v = hawk_rtx_valtobool(rtx, hawk_rtx_getarg(rtx, 1)); ENSURE_CONNECT_EVER_ATTEMPTED(rtx, sql_list, sql_node); if (mysql_rollback(sql_node->mysql) != 0) { - set_error_on_sql_list (rtx, sql_list, QSE_T("%hs"), mysql_error(sql_node->mysql)); + set_error_on_sql_list (rtx, sql_list, HAWK_T("%hs"), mysql_error(sql_node->mysql)); goto done; } @@ -682,48 +682,48 @@ static int fnc_rollback (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) } done: - if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, QSE_NULL); - qse_awk_rtx_setretval (rtx, qse_awk_rtx_makeintval(rtx, ret)); + if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL); + hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, ret)); return 0; oops: - if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, QSE_NULL); + if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL); return -1; } -static int fnc_affected_rows (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_affected_rows (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { sql_list_t* sql_list; sql_node_t* sql_node; int ret = -1, take_rtx_err = 0; sql_list = rtx_to_sql_list(rtx, fi); - sql_node = get_sql_list_node_with_arg(rtx, sql_list, qse_awk_rtx_getarg(rtx, 0)); + sql_node = get_sql_list_node_with_arg(rtx, sql_list, hawk_rtx_getarg(rtx, 0)); if (sql_node) { my_ulonglong nrows; - qse_awk_val_t* vrows; + hawk_val_t* vrows; ENSURE_CONNECT_EVER_ATTEMPTED(rtx, sql_list, sql_node); nrows = mysql_affected_rows(sql_node->mysql); if (nrows == (my_ulonglong)-1) { - set_error_on_sql_list (rtx, sql_list, QSE_T("%hs"), mysql_error(sql_node->mysql)); + set_error_on_sql_list (rtx, sql_list, HAWK_T("%hs"), mysql_error(sql_node->mysql)); goto done; } - vrows = qse_awk_rtx_makeintval(rtx, nrows); + vrows = hawk_rtx_makeintval(rtx, nrows); if (!vrows) { take_rtx_err = 1; goto oops; } - if (qse_awk_rtx_setrefval(rtx, (qse_awk_val_ref_t*)qse_awk_rtx_getarg(rtx, 1), vrows) <= -1) + if (hawk_rtx_setrefval(rtx, (hawk_val_ref_t*)hawk_rtx_getarg(rtx, 1), vrows) <= -1) { - qse_awk_rtx_refupval (rtx, vrows); - qse_awk_rtx_refdownval (rtx, vrows); + hawk_rtx_refupval (rtx, vrows); + hawk_rtx_refdownval (rtx, vrows); take_rtx_err = 1; goto oops; } @@ -732,53 +732,53 @@ static int fnc_affected_rows (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) } done: - if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, QSE_NULL); - qse_awk_rtx_setretval (rtx, qse_awk_rtx_makeintval(rtx, ret)); + if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL); + hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, ret)); return 0; oops: - if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, QSE_NULL); + if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL); return -1; } -static int fnc_escape_string (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_escape_string (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { sql_list_t* sql_list; sql_node_t* sql_node; int ret = -1, take_rtx_err = 0; - qse_awk_val_t* a1, *retv; - qse_mchar_t* qstr = QSE_NULL; - qse_mchar_t* ebuf = QSE_NULL; + hawk_val_t* a1, *retv; + hawk_mchar_t* qstr = HAWK_NULL; + hawk_mchar_t* ebuf = HAWK_NULL; sql_list = rtx_to_sql_list(rtx, fi); - sql_node = get_sql_list_node_with_arg(rtx, sql_list, qse_awk_rtx_getarg(rtx, 0)); + sql_node = get_sql_list_node_with_arg(rtx, sql_list, hawk_rtx_getarg(rtx, 0)); if (sql_node) { - qse_size_t qlen; + hawk_size_t qlen; - a1 = qse_awk_rtx_getarg(rtx, 1); + a1 = hawk_rtx_getarg(rtx, 1); - qstr = qse_awk_rtx_getvalmbs(rtx, a1, &qlen); + qstr = hawk_rtx_getvalmbs(rtx, a1, &qlen); if (!qstr) { take_rtx_err = 1; goto oops; } - ebuf = qse_awk_rtx_allocmem(rtx, (qlen * 2 + 1) * QSE_SIZEOF(*qstr)); + ebuf = hawk_rtx_allocmem(rtx, (qlen * 2 + 1) * HAWK_SIZEOF(*qstr)); if (!ebuf) { take_rtx_err = 1; goto oops; } ENSURE_CONNECT_EVER_ATTEMPTED(rtx, sql_list, sql_node); mysql_real_escape_string(sql_node->mysql, ebuf, qstr, qlen); - retv = qse_awk_rtx_makestrvalwithmbs(rtx, ebuf); + retv = hawk_rtx_makestrvalwithmbs(rtx, ebuf); if (!retv) { take_rtx_err = 1; goto oops; } - if (qse_awk_rtx_setrefval(rtx, (qse_awk_val_ref_t*)qse_awk_rtx_getarg(rtx, 2), retv) <= -1) + if (hawk_rtx_setrefval(rtx, (hawk_val_ref_t*)hawk_rtx_getarg(rtx, 2), retv) <= -1) { - qse_awk_rtx_refupval (rtx, retv); - qse_awk_rtx_refdownval (rtx, retv); + hawk_rtx_refupval (rtx, retv); + hawk_rtx_refdownval (rtx, retv); take_rtx_err = 1; goto oops; } @@ -787,43 +787,43 @@ static int fnc_escape_string (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) } done: - if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, QSE_NULL); - if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, QSE_NULL); - if (ebuf) qse_awk_rtx_freemem (rtx, ebuf); - if (qstr) qse_awk_rtx_freevalmbs (rtx, a1, qstr); - qse_awk_rtx_setretval (rtx, qse_awk_rtx_makeintval(rtx, ret)); + if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL); + if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL); + if (ebuf) hawk_rtx_freemem (rtx, ebuf); + if (qstr) hawk_rtx_freevalmbs (rtx, a1, qstr); + hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, ret)); return 0; oops: - if (ebuf) qse_awk_rtx_freemem (rtx, ebuf); - if (qstr) qse_awk_rtx_freevalmbs (rtx, a1, qstr); + if (ebuf) hawk_rtx_freemem (rtx, ebuf); + if (qstr) hawk_rtx_freevalmbs (rtx, a1, qstr); return -1; } -static int fnc_query (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_query (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { sql_list_t* sql_list; sql_node_t* sql_node; int ret = -1, take_rtx_err = 0; - qse_awk_val_t* a1; - qse_mchar_t* qstr = QSE_NULL; + hawk_val_t* a1; + hawk_mchar_t* qstr = HAWK_NULL; sql_list = rtx_to_sql_list(rtx, fi); - sql_node = get_sql_list_node_with_arg(rtx, sql_list, qse_awk_rtx_getarg(rtx, 0)); + sql_node = get_sql_list_node_with_arg(rtx, sql_list, hawk_rtx_getarg(rtx, 0)); if (sql_node) { - qse_size_t qlen; - a1 = qse_awk_rtx_getarg(rtx, 1); + hawk_size_t qlen; + a1 = hawk_rtx_getarg(rtx, 1); - qstr = qse_awk_rtx_getvalmbs(rtx, a1, &qlen); + qstr = hawk_rtx_getvalmbs(rtx, a1, &qlen); if (!qstr) { take_rtx_err = 1; goto oops; } ENSURE_CONNECT_EVER_ATTEMPTED(rtx, sql_list, sql_node); if (mysql_real_query(sql_node->mysql, qstr, qlen) != 0) { - set_error_on_sql_list (rtx, sql_list, QSE_T("%hs"), mysql_error(sql_node->mysql)); + set_error_on_sql_list (rtx, sql_list, HAWK_T("%hs"), mysql_error(sql_node->mysql)); goto done; } @@ -831,25 +831,25 @@ static int fnc_query (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) } done: - if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, QSE_NULL); - if (qstr) qse_awk_rtx_freevalmbs (rtx, a1, qstr); - qse_awk_rtx_setretval (rtx, qse_awk_rtx_makeintval(rtx, ret)); + if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL); + if (qstr) hawk_rtx_freevalmbs (rtx, a1, qstr); + hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, ret)); return 0; oops: - if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, QSE_NULL); - if (qstr) qse_awk_rtx_freevalmbs (rtx, a1, qstr); + if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL); + if (qstr) hawk_rtx_freevalmbs (rtx, a1, qstr); return -1; } -static int fnc_store_result (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_store_result (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { sql_list_t* sql_list; sql_node_t* sql_node; int ret = -1, take_rtx_err = 0; sql_list = rtx_to_sql_list(rtx, fi); - sql_node = get_sql_list_node_with_arg(rtx, sql_list, qse_awk_rtx_getarg(rtx, 0)); + sql_node = get_sql_list_node_with_arg(rtx, sql_list, hawk_rtx_getarg(rtx, 0)); if (sql_node) { res_list_t* res_list; @@ -864,9 +864,9 @@ static int fnc_store_result (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) if (!res) { if (mysql_errno(sql_node->mysql) == 0) - set_error_on_sql_list (rtx, sql_list, QSE_T("no result")); + set_error_on_sql_list (rtx, sql_list, HAWK_T("no result")); else - set_error_on_sql_list (rtx, sql_list, QSE_T("%hs"), mysql_error(sql_node->mysql)); + set_error_on_sql_list (rtx, sql_list, HAWK_T("%hs"), mysql_error(sql_node->mysql)); goto done; } @@ -882,12 +882,12 @@ static int fnc_store_result (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) } done: - if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, QSE_NULL); - qse_awk_rtx_setretval (rtx, qse_awk_rtx_makeintval(rtx, ret)); + if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL); + hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, ret)); return 0; } -static int fnc_free_result (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_free_result (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { sql_list_t* sql_list; res_list_t* res_list; @@ -896,33 +896,33 @@ static int fnc_free_result (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) sql_list = rtx_to_sql_list(rtx, fi); res_list = rtx_to_res_list(rtx, fi); - res_node = get_res_list_node_with_arg(rtx, sql_list, res_list, qse_awk_rtx_getarg(rtx, 0)); + res_node = get_res_list_node_with_arg(rtx, sql_list, res_list, hawk_rtx_getarg(rtx, 0)); if (res_node) { free_res_node (rtx, res_list, res_node); ret = 0; } - qse_awk_rtx_setretval (rtx, qse_awk_rtx_makeintval(rtx, ret)); + hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, ret)); return 0; } -static int fnc_fetch_row (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_fetch_row (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { sql_list_t* sql_list; res_list_t* res_list; res_node_t* res_node; int ret = -1, take_rtx_err = 0; - qse_awk_val_t* row_map = QSE_NULL; + hawk_val_t* row_map = HAWK_NULL; sql_list = rtx_to_sql_list(rtx, fi); res_list = rtx_to_res_list(rtx, fi); - res_node = get_res_list_node_with_arg(rtx, sql_list, res_list, qse_awk_rtx_getarg(rtx, 0)); + res_node = get_res_list_node_with_arg(rtx, sql_list, res_list, hawk_rtx_getarg(rtx, 0)); if (res_node) { MYSQL_ROW row; unsigned int i; - qse_awk_val_t* row_val; + hawk_val_t* row_val; int x; row = mysql_fetch_row(res_node->res); @@ -933,191 +933,188 @@ static int fnc_fetch_row (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) goto done; } - row_map = qse_awk_rtx_makemapval(rtx); + row_map = hawk_rtx_makemapval(rtx); if (!row_map) goto oops; - qse_awk_rtx_refupval (rtx, row_map); + hawk_rtx_refupval (rtx, row_map); for (i = 0; i < res_node->num_fields; ) { - qse_char_t key_buf[QSE_SIZEOF(qse_awk_int_t) * 8 + 2]; - qse_size_t key_len; + hawk_ooch_t key_buf[HAWK_SIZEOF(hawk_int_t) * 8 + 2]; + hawk_size_t key_len; if (row[i]) { -/* TODO: consider using make multi byte string - qse_awk_rtx_makembsstr */ - row_val = qse_awk_rtx_makestrvalwithmbs(rtx, row[i]); +/* TODO: consider using make multi byte string - hawk_rtx_makembsstr */ + row_val = hawk_rtx_makestrvalwithmbs(rtx, row[i]); if (!row_val) goto oops; } else { - row_val = qse_awk_rtx_makenilval(rtx); + row_val = hawk_rtx_makenilval(rtx); } ++i; /* put it into the map */ - key_len = qse_awk_inttostr(qse_awk_rtx_getawk(rtx), i, 10, QSE_NULL, key_buf, QSE_COUNTOF(key_buf)); - QSE_ASSERT (key_len != (qse_size_t)-1); + key_len = hawk_inttostr(hawk_rtx_getawk(rtx), i, 10, HAWK_NULL, key_buf, HAWK_COUNTOF(key_buf)); + HAWK_ASSERT (key_len != (hawk_size_t)-1); - if (qse_awk_rtx_setmapvalfld(rtx, row_map, key_buf, key_len, row_val) == QSE_NULL) + if (hawk_rtx_setmapvalfld(rtx, row_map, key_buf, key_len, row_val) == HAWK_NULL) { - qse_awk_rtx_refupval (rtx, row_val); - qse_awk_rtx_refdownval (rtx, row_val); + hawk_rtx_refupval (rtx, row_val); + hawk_rtx_refdownval (rtx, row_val); goto oops; } } - x = qse_awk_rtx_setrefval(rtx, (qse_awk_val_ref_t*)qse_awk_rtx_getarg(rtx, 1), row_map); + x = hawk_rtx_setrefval(rtx, (hawk_val_ref_t*)hawk_rtx_getarg(rtx, 1), row_map); - qse_awk_rtx_refdownval (rtx, row_map); - row_map = QSE_NULL; + hawk_rtx_refdownval (rtx, row_map); + row_map = HAWK_NULL; if (x <= -1) goto oops; ret = 1; /* indicate that there is a row */ } done: - if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, QSE_NULL); - qse_awk_rtx_setretval (rtx, qse_awk_rtx_makeintval(rtx, ret)); + if (take_rtx_err) set_error_on_sql_list (rtx, sql_list, HAWK_NULL); + hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, ret)); return 0; oops: - if (row_map) qse_awk_rtx_refdownval (rtx, row_map); + if (row_map) hawk_rtx_refdownval (rtx, row_map); return -1; } typedef struct fnctab_t fnctab_t; struct fnctab_t { - const qse_char_t* name; - qse_awk_mod_sym_fnc_t info; + const hawk_ooch_t* name; + hawk_mod_sym_fnc_t info; }; typedef struct inttab_t inttab_t; struct inttab_t { - const qse_char_t* name; - qse_awk_mod_sym_int_t info; + const hawk_ooch_t* name; + hawk_mod_sym_int_t info; }; -#define A_MAX QSE_TYPE_MAX(int) +#define A_MAX HAWK_TYPE_MAX(int) static fnctab_t fnctab[] = { /* keep this table sorted for binary search in query(). */ - { QSE_T("affected_rows"), { { 2, 2, QSE_T("vr") }, fnc_affected_rows, 0 } }, - { QSE_T("autocommit"), { { 2, 2, QSE_NULL }, fnc_autocommit, 0 } }, - { QSE_T("close"), { { 1, 1, QSE_NULL }, fnc_close, 0 } }, - { QSE_T("commit"), { { 1, 1, QSE_NULL }, fnc_commit, 0 } }, - { QSE_T("connect"), { { 4, 7, QSE_NULL }, fnc_connect, 0 } }, - { QSE_T("errmsg"), { { 0, 0, QSE_NULL }, fnc_errmsg, 0 } }, - { QSE_T("escape_string"), { { 3, 3, QSE_T("vvr") }, fnc_escape_string, 0 } }, - { QSE_T("fetch_row"), { { 2, 2, QSE_T("vr") }, fnc_fetch_row, 0 } }, - { QSE_T("free_result"), { { 1, 1, QSE_NULL }, fnc_free_result, 0 } }, - /*{ QSE_T("get_option"), { { 3, 3, QSE_T("vr") }, fnc_get_option, 0 } },*/ - { QSE_T("open"), { { 0, 0, QSE_NULL }, fnc_open, 0 } }, - { QSE_T("ping"), { { 1, 1, QSE_NULL }, fnc_ping, 0 } }, - { QSE_T("query"), { { 2, 2, QSE_NULL }, fnc_query, 0 } }, - { QSE_T("rollback"), { { 1, 1, QSE_NULL }, fnc_rollback, 0 } }, - { QSE_T("select_db"), { { 2, 2, QSE_NULL }, fnc_select_db, 0 } }, - { QSE_T("set_option"), { { 3, 3, QSE_NULL }, fnc_set_option, 0 } }, - { QSE_T("store_result"), { { 1, 1, QSE_NULL }, fnc_store_result, 0 } } + { HAWK_T("affected_rows"), { { 2, 2, HAWK_T("vr") }, fnc_affected_rows, 0 } }, + { HAWK_T("autocommit"), { { 2, 2, HAWK_NULL }, fnc_autocommit, 0 } }, + { HAWK_T("close"), { { 1, 1, HAWK_NULL }, fnc_close, 0 } }, + { HAWK_T("commit"), { { 1, 1, HAWK_NULL }, fnc_commit, 0 } }, + { HAWK_T("connect"), { { 4, 7, HAWK_NULL }, fnc_connect, 0 } }, + { HAWK_T("errmsg"), { { 0, 0, HAWK_NULL }, fnc_errmsg, 0 } }, + { HAWK_T("escape_string"), { { 3, 3, HAWK_T("vvr") }, fnc_escape_string, 0 } }, + { HAWK_T("fetch_row"), { { 2, 2, HAWK_T("vr") }, fnc_fetch_row, 0 } }, + { HAWK_T("free_result"), { { 1, 1, HAWK_NULL }, fnc_free_result, 0 } }, + /*{ HAWK_T("get_option"), { { 3, 3, HAWK_T("vr") }, fnc_get_option, 0 } },*/ + { HAWK_T("open"), { { 0, 0, HAWK_NULL }, fnc_open, 0 } }, + { HAWK_T("ping"), { { 1, 1, HAWK_NULL }, fnc_ping, 0 } }, + { HAWK_T("query"), { { 2, 2, HAWK_NULL }, fnc_query, 0 } }, + { HAWK_T("rollback"), { { 1, 1, HAWK_NULL }, fnc_rollback, 0 } }, + { HAWK_T("select_db"), { { 2, 2, HAWK_NULL }, fnc_select_db, 0 } }, + { HAWK_T("set_option"), { { 3, 3, HAWK_NULL }, fnc_set_option, 0 } }, + { HAWK_T("store_result"), { { 1, 1, HAWK_NULL }, fnc_store_result, 0 } } }; static inttab_t inttab[] = { /* keep this table sorted for binary search in query(). */ - { QSE_T("OPT_CONNECT_TIMEOUT"), { MYSQL_OPT_CONNECT_TIMEOUT } }, - { QSE_T("OPT_READ_TIMEOUT"), { MYSQL_OPT_READ_TIMEOUT } }, + { HAWK_T("OPT_CONNECT_TIMEOUT"), { MYSQL_OPT_CONNECT_TIMEOUT } }, + { HAWK_T("OPT_READ_TIMEOUT"), { MYSQL_OPT_READ_TIMEOUT } }, #if defined(MYSQL_OPT_RECONNECT) - { QSE_T("OPT_RECONNECT"), { MYSQL_OPT_RECONNECT } }, + { HAWK_T("OPT_RECONNECT"), { MYSQL_OPT_RECONNECT } }, #else - { QSE_T("OPT_RECONNECT"), { DUMMY_OPT_RECONNECT } }, + { HAWK_T("OPT_RECONNECT"), { DUMMY_OPT_RECONNECT } }, #endif - { QSE_T("OPT_WRITE_TIMEOUT"), { MYSQL_OPT_WRITE_TIMEOUT } } + { HAWK_T("OPT_WRITE_TIMEOUT"), { MYSQL_OPT_WRITE_TIMEOUT } } }; -static int query (qse_awk_mod_t* mod, qse_awk_t* awk, const qse_char_t* name, qse_awk_mod_sym_t* sym) +static int query (hawk_mod_t* mod, hawk_t* awk, const hawk_ooch_t* name, hawk_mod_sym_t* sym) { - qse_cstr_t ea; int left, right, mid, n; - left = 0; right = QSE_COUNTOF(fnctab) - 1; + left = 0; right = HAWK_COUNTOF(fnctab) - 1; while (left <= right) { mid = left + (right - left) / 2; - n = qse_strcmp (fnctab[mid].name, name); + n = hawk_strcmp (fnctab[mid].name, name); if (n > 0) right = mid - 1; else if (n < 0) left = mid + 1; else { - sym->type = QSE_AWK_MOD_FNC; + sym->type = HAWK_MOD_FNC; sym->u.fnc = fnctab[mid].info; return 0; } } - left = 0; right = QSE_COUNTOF(inttab) - 1; + left = 0; right = HAWK_COUNTOF(inttab) - 1; while (left <= right) { mid = left + (right - left) / 2; - n = qse_strcmp (inttab[mid].name, name); + n = hawk_strcmp (inttab[mid].name, name); if (n > 0) right = mid - 1; else if (n < 0) left = mid + 1; else { - sym->type = QSE_AWK_MOD_INT; + sym->type = HAWK_MOD_INT; sym->u.in = inttab[mid].info; return 0; } } - ea.ptr = (qse_char_t*)name; - ea.len = qse_strlen(name); - qse_awk_seterror (awk, QSE_AWK_ENOENT, &ea, QSE_NULL); + hawk_seterrfmt (awk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js' not found"), name); return -1; } -static int init (qse_awk_mod_t* mod, qse_awk_rtx_t* rtx) +static int init (hawk_mod_t* mod, hawk_rtx_t* rtx) { - qse_rbt_t* rbt; + hawk_rbt_t* rbt; rtx_data_t data; - rbt = (qse_rbt_t*)mod->ctx; + rbt = (hawk_rbt_t*)mod->ctx; - QSE_MEMSET (&data, 0, QSE_SIZEOF(data)); - if (qse_rbt_insert(rbt, &rtx, QSE_SIZEOF(rtx), &data, QSE_SIZEOF(data)) == QSE_NULL) + HAWK_MEMSET (&data, 0, HAWK_SIZEOF(data)); + if (hawk_rbt_insert(rbt, &rtx, HAWK_SIZEOF(rtx), &data, HAWK_SIZEOF(data)) == HAWK_NULL) { - qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL); + hawk_rtx_seterrnum (rtx, HAWK_ENOMEM, HAWK_NULL); return -1; } return 0; } -static void fini (qse_awk_mod_t* mod, qse_awk_rtx_t* rtx) +static void fini (hawk_mod_t* mod, hawk_rtx_t* rtx) { - qse_rbt_t* rbt; - qse_rbt_pair_t* pair; + hawk_rbt_t* rbt; + hawk_rbt_pair_t* pair; - rbt = (qse_rbt_t*)mod->ctx; + rbt = (hawk_rbt_t*)mod->ctx; /* garbage clean-up */ - pair = qse_rbt_search(rbt, &rtx, QSE_SIZEOF(rtx)); + pair = hawk_rbt_search(rbt, &rtx, HAWK_SIZEOF(rtx)); if (pair) { rtx_data_t* data; sql_node_t* sql_node, * sql_next; res_node_t* res_node, * res_next; - data = (rtx_data_t*)QSE_RBT_VPTR(pair); + data = (rtx_data_t*)HAWK_RBT_VPTR(pair); res_node = data->res_list.head; while (res_node) @@ -1135,24 +1132,24 @@ static void fini (qse_awk_mod_t* mod, qse_awk_rtx_t* rtx) sql_node = sql_next; } - qse_rbt_delete (rbt, &rtx, QSE_SIZEOF(rtx)); + hawk_rbt_delete (rbt, &rtx, HAWK_SIZEOF(rtx)); } } -static void unload (qse_awk_mod_t* mod, qse_awk_t* awk) +static void unload (hawk_mod_t* mod, hawk_t* hawk) { - qse_rbt_t* rbt; + hawk_rbt_t* rbt; - rbt = (qse_rbt_t*)mod->ctx; + rbt = (hawk_rbt_t*)mod->ctx; - QSE_ASSERT (QSE_RBT_SIZE(rbt) == 0); - qse_rbt_close (rbt); + HAWK_ASSERT (HAWK_RBT_SIZE(rbt) == 0); + hawk_rbt_close (rbt); //mysql_library_end (); } -int qse_awk_mod_mysql (qse_awk_mod_t* mod, qse_awk_t* awk) +int hawk_mod_mysql (hawk_mod_t* mod, hawk_t* hawk) { - qse_rbt_t* rbt; + hawk_rbt_t* rbt; mod->query = query; mod->unload = unload; @@ -1160,26 +1157,23 @@ int qse_awk_mod_mysql (qse_awk_mod_t* mod, qse_awk_t* awk) mod->init = init; mod->fini = fini; - rbt = qse_rbt_open(qse_awk_getmmgr(awk), 0, 1, 1); - if (rbt == QSE_NULL) - { - qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL); - return -1; - } - qse_rbt_setstyle (rbt, qse_getrbtstyle(QSE_RBT_STYLE_INLINE_COPIERS)); + rbt = hawk_rbt_open(hawk_getgem(awk), 0, 1, 1); + if (rbt == HAWK_NULL) return -1; + + hawk_rbt_setstyle (rbt, hawk_getrbtstyle(HAWK_RBT_STYLE_INLINE_COPIERS)); mod->ctx = rbt; return 0; } -QSE_EXPORT int qse_awk_mod_mysql_init (int argc, qse_achar_t* argv[]) +HAWK_EXPORT int hawk_mod_mysql_init (int argc, hawk_achar_t* argv[]) { - if (mysql_library_init(argc, argv, QSE_NULL) != 0) return -1; + if (mysql_library_init(argc, argv, HAWK_NULL) != 0) return -1; return 0; } -QSE_EXPORT void qse_awk_mod_mysql_fini (void) +HAWK_EXPORT void hawk_mod_mysql_fini (void) { mysql_library_end (); } diff --git a/hawk/mod/mod-mysql.h b/hawk/mod/mod-mysql.h index 8c90d1cb..9ab0adec 100644 --- a/hawk/mod/mod-mysql.h +++ b/hawk/mod/mod-mysql.h @@ -24,16 +24,16 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _QSE_LIB_AWKMOD_MYSQL_H_ -#define _QSE_LIB_AWKMOD_MYSQL_H_ +#ifndef _HAWK_MOD_MYSQL_H_ +#define _HAWK_MOD_MYSQL_H_ -#include +#include #if defined(__cplusplus) extern "C" { #endif -QSE_EXPORT int qse_awk_mod_mysql (qse_awk_mod_t* mod, qse_awk_t* awk); +HAWK_EXPORT int hawk_mod_mysql (hawk_mod_t* mod, hawk_t* hawk); #if defined(__cplusplus) } diff --git a/hawk/mod/mod-uci.c b/hawk/mod/mod-uci.c index c58210fc..d93248ea 100644 --- a/hawk/mod/mod-uci.c +++ b/hawk/mod/mod-uci.c @@ -25,10 +25,10 @@ */ #include "mod-uci.h" -#include -#include -#include -#include +#include +#include +#include +#include #include "../cmn/mem-prv.h" #if defined(HAVE_UCI_H) @@ -65,17 +65,17 @@ struct uctx_list_t int errnum; }; -static uctx_node_t* new_uctx_node (qse_awk_rtx_t* rtx, uctx_list_t* list) +static uctx_node_t* new_uctx_node (hawk_rtx_t* rtx, uctx_list_t* list) { /* create a new context node and append it to the list tail */ uctx_node_t* node; - node = QSE_NULL; + node = HAWK_NULL; if (list->free) node = list->free; else { - node = qse_awk_rtx_callocmem (rtx, QSE_SIZEOF(*node)); + node = hawk_rtx_callocmem (rtx, HAWK_SIZEOF(*node)); if (!node) goto oops; } @@ -93,25 +93,25 @@ static uctx_node_t* new_uctx_node (qse_awk_rtx_t* rtx, uctx_list_t* list) newcapa = list->map.capa + 64; if (newcapa < list->map.capa) goto oops; /* overflow */ - tmp = (uctx_node_t**) qse_awk_rtx_reallocmem ( - rtx, list->map.tab, QSE_SIZEOF(*tmp) * newcapa); + tmp = (uctx_node_t**) hawk_rtx_reallocmem ( + rtx, list->map.tab, HAWK_SIZEOF(*tmp) * newcapa); if (!tmp) goto oops; - QSE_MEMSET (&tmp[list->map.capa], 0, - QSE_SIZEOF(*tmp) * (newcapa - list->map.capa)); + HAWK_MEMSET (&tmp[list->map.capa], 0, + HAWK_SIZEOF(*tmp) * (newcapa - list->map.capa)); list->map.tab = tmp; list->map.capa = newcapa; } node->id = list->map.high; - QSE_ASSERT (list->map.tab[node->id] == QSE_NULL); + HAWK_ASSERT (list->map.tab[node->id] == HAWK_NULL); list->map.tab[node->id] = node; list->map.high++; } /* append it to the tail */ - node->next = QSE_NULL; + node->next = HAWK_NULL; node->prev = list->tail; if (list->tail) list->tail->next = node; else list->head = node; @@ -120,19 +120,19 @@ static uctx_node_t* new_uctx_node (qse_awk_rtx_t* rtx, uctx_list_t* list) return node; oops: - if (node) qse_awk_rtx_freemem (rtx, node); - qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL); - return QSE_NULL; + if (node) hawk_rtx_freemem (rtx, node); + hawk_rtx_seterrnum (rtx, HAWK_ENOMEM, HAWK_NULL); + return HAWK_NULL; } -static void free_uctx_node (qse_awk_rtx_t* rtx, uctx_list_t* list, uctx_node_t* node) +static void free_uctx_node (hawk_rtx_t* rtx, uctx_list_t* list, uctx_node_t* node) { if (node->prev) node->prev->next = node->next; if (node->next) node->next->prev = node->prev; if (list->head == node) list->head = node->next; if (list->tail == node) list->tail = node->prev; - list->map.tab[node->id] = QSE_NULL; + list->map.tab[node->id] = HAWK_NULL; if (node->ctx) { @@ -143,44 +143,44 @@ static void free_uctx_node (qse_awk_rtx_t* rtx, uctx_list_t* list, uctx_node_t* { /* destroy the actual node if the node to be freed has the * highest id */ - QSE_MMGR_FREE (qse_awk_rtx_getmmgr(rtx), node); + HAWK_MMGR_FREE (hawk_rtx_getmmgr(rtx), node); list->map.high--; } else { /* otherwise, chain the node to the free list */ - node->ctx = QSE_NULL; + node->ctx = HAWK_NULL; node->next = list->free; list->free = node; } /* however, i destroy the whole free list when all the nodes are * chanined to the free list */ - if (list->head == QSE_NULL) + if (list->head == HAWK_NULL) { - qse_mmgr_t* mmgr; + hawk_mmgr_t* mmgr; uctx_node_t* curnode; - mmgr = qse_awk_rtx_getmmgr(rtx); + mmgr = hawk_rtx_getmmgr(rtx); while (list->free) { curnode = list->free; list->free = list->free->next; - QSE_ASSERT (curnode->ctx == QSE_NULL); - QSE_MMGR_FREE (mmgr, curnode); + HAWK_ASSERT (curnode->ctx == HAWK_NULL); + HAWK_MMGR_FREE (mmgr, curnode); } - QSE_MMGR_FREE (mmgr, list->map.tab); + HAWK_MMGR_FREE (mmgr, list->map.tab); list->map.high = 0; list->map.capa = 0; - list->map.tab = QSE_NULL; + list->map.tab = HAWK_NULL; } } /* ------------------------------------------------------------------------ */ -static int close_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id) +static int close_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id) { int x = UCI_ERR_INVAL; @@ -194,32 +194,32 @@ static int close_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id) } static int load_byid ( - qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, qse_mchar_t* path) + hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mchar_t* path) { int x = UCI_ERR_INVAL; if (id >= 0 && id < list->map.high && list->map.tab[id]) { - x = uci_load (list->map.tab[id]->ctx, path, QSE_NULL); + x = uci_load (list->map.tab[id]->ctx, path, HAWK_NULL); } return -x; } -static int unload_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id) +static int unload_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id) { int x = UCI_ERR_INVAL; if (id >= 0 && id < list->map.high && list->map.tab[id]) { - x = uci_unload (list->map.tab[id]->ctx, QSE_NULL); + x = uci_unload (list->map.tab[id]->ctx, HAWK_NULL); return 0; } return -x; } -static int save_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, qse_mchar_t* item) +static int save_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mchar_t* item) { int x = UCI_ERR_INVAL; @@ -242,7 +242,7 @@ static int save_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, q return -x; } -static int commit_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, qse_mchar_t* item) +static int commit_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mchar_t* item) { int x = UCI_ERR_INVAL; @@ -264,7 +264,7 @@ static int commit_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, return -x; } -static int revert_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, qse_mchar_t* item) +static int revert_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mchar_t* item) { int x = UCI_ERR_INVAL; @@ -286,7 +286,7 @@ static int revert_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, return -x; } -static int delete_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, qse_mchar_t* item) +static int delete_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mchar_t* item) { int x = UCI_ERR_INVAL; @@ -308,7 +308,7 @@ static int delete_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, return -x; } -static int rename_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, qse_mchar_t* item) +static int rename_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mchar_t* item) { int x = UCI_ERR_INVAL; @@ -330,7 +330,7 @@ static int rename_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, return -x; } -static int set_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, qse_mchar_t* item) +static int set_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mchar_t* item) { int x = UCI_ERR_INVAL; @@ -349,7 +349,7 @@ static int set_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, qs return -x; } -static int addsection_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, qse_mchar_t* item, qse_mchar_t* type) +static int addsection_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mchar_t* item, hawk_mchar_t* type) { int x = UCI_ERR_INVAL; @@ -362,7 +362,7 @@ static int addsection_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t if (x == UCI_OK) { /* add an unnamed section. use set to add a named section */ - struct uci_section* s = QSE_NULL; + struct uci_section* s = HAWK_NULL; if (!ptr.value && (ptr.flags & UCI_LOOKUP_COMPLETE) && (ptr.last->type == UCI_TYPE_PACKAGE)) x = uci_add_section (list->map.tab[id]->ctx, ptr.p, type, &s); else x = UCI_ERR_INVAL; @@ -372,7 +372,7 @@ static int addsection_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t return -x; } -static int addlist_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, qse_mchar_t* item) +static int addlist_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mchar_t* item) { int x = UCI_ERR_INVAL; @@ -392,7 +392,7 @@ static int addlist_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id } static int setconfdir_byid ( - qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, qse_mchar_t* path) + hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mchar_t* path) { int x = UCI_ERR_INVAL; @@ -405,7 +405,7 @@ static int setconfdir_byid ( } static int setsavedir_byid ( - qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, qse_mchar_t* path) + hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mchar_t* path) { int x = UCI_ERR_INVAL; @@ -418,7 +418,7 @@ static int setsavedir_byid ( } static int adddeltapath_byid ( - qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, qse_mchar_t* path) + hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mchar_t* path) { int x = UCI_ERR_INVAL; @@ -431,8 +431,8 @@ static int adddeltapath_byid ( } static int getsection_byid ( - qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, - qse_mchar_t* tuple, qse_awk_val_ref_t* ref) + hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, + hawk_mchar_t* tuple, hawk_val_ref_t* ref) { int x = UCI_ERR_INVAL; @@ -452,35 +452,35 @@ static int getsection_byid ( e = ptr.last; if (e->type == UCI_TYPE_SECTION) { - qse_awk_val_map_data_t md[4]; - qse_awk_int_t lv; - qse_awk_val_t* tmp; + hawk_val_map_data_t md[4]; + hawk_int_t lv; + hawk_val_t* tmp; - QSE_MEMSET (md, 0, QSE_SIZEOF(md)); + HAWK_MEMSET (md, 0, HAWK_SIZEOF(md)); - md[0].key.ptr = QSE_T("type"); + md[0].key.ptr = HAWK_T("type"); md[0].key.len = 4; - md[0].type = QSE_AWK_VAL_MAP_DATA_MBS; + md[0].type = HAWK_VAL_MAP_DATA_MBS; md[0].vptr = ptr.s->type; - md[1].key.ptr = QSE_T("name"); + md[1].key.ptr = HAWK_T("name"); md[1].key.len = 4; - md[1].type = QSE_AWK_VAL_MAP_DATA_MBS; + md[1].type = HAWK_VAL_MAP_DATA_MBS; md[1].vptr = ptr.s->e.name; /* e->name == ptr.s->e.name */ - md[2].key.ptr = QSE_T("anon"); + md[2].key.ptr = HAWK_T("anon"); md[2].key.len = 4; - md[2].vptr = QSE_AWK_VAL_MAP_DATA_INT; + md[2].vptr = HAWK_VAL_MAP_DATA_INT; lv = ptr.s->anonymous; md[2].vptr = &lv; - tmp = qse_awk_rtx_makemapvalwithdata (rtx, md); + tmp = hawk_rtx_makemapvalwithdata (rtx, md); if (tmp) { int n; - qse_awk_rtx_refupval (rtx, tmp); - n = qse_awk_rtx_setrefval (rtx, ref, tmp); - qse_awk_rtx_refdownval (rtx, tmp); + hawk_rtx_refupval (rtx, tmp); + n = hawk_rtx_setrefval (rtx, ref, tmp); + hawk_rtx_refdownval (rtx, tmp); if (n <= -1) return -9999; } else x = UCI_ERR_MEM; @@ -496,8 +496,8 @@ static int getsection_byid ( } static int getoption_byid ( - qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, - qse_mchar_t* tuple, qse_awk_val_ref_t* ref) + hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, + hawk_mchar_t* tuple, hawk_val_ref_t* ref) { int x = UCI_ERR_INVAL; @@ -521,31 +521,31 @@ static int getoption_byid ( if (uo->type == UCI_TYPE_STRING) { - qse_awk_val_t* map; - qse_awk_val_map_data_t md[3]; + hawk_val_t* map; + hawk_val_map_data_t md[3]; - QSE_MEMSET (md, 0, QSE_SIZEOF(md)); + HAWK_MEMSET (md, 0, HAWK_SIZEOF(md)); - md[0].key.ptr = QSE_T("type"); + md[0].key.ptr = HAWK_T("type"); md[0].key.len = 4; - md[0].type = QSE_AWK_VAL_MAP_DATA_STR; - md[0].vptr = QSE_T("string"); + md[0].type = HAWK_VAL_MAP_DATA_STR; + md[0].vptr = HAWK_T("string"); - md[1].key.ptr = QSE_T("value"); + md[1].key.ptr = HAWK_T("value"); md[1].key.len = 5; - md[1].type = QSE_AWK_VAL_MAP_DATA_MBS; + md[1].type = HAWK_VAL_MAP_DATA_MBS; md[1].vptr = uo->v.string; - map = qse_awk_rtx_makemapvalwithdata (rtx, md); + map = hawk_rtx_makemapvalwithdata (rtx, md); if (map) { int n; - qse_awk_rtx_refupval (rtx, map); - n = qse_awk_rtx_setrefval (rtx, ref, map); - qse_awk_rtx_refdownval (rtx, map); + hawk_rtx_refupval (rtx, map); + n = hawk_rtx_setrefval (rtx, ref, map); + hawk_rtx_refdownval (rtx, map); if (n <= -1) { - map = QSE_NULL; + map = HAWK_NULL; return -9999; } } @@ -553,83 +553,83 @@ static int getoption_byid ( } else if (uo->type == UCI_TYPE_LIST) { - qse_awk_val_t* map, * fld; - qse_awk_val_map_data_t md[3]; + hawk_val_t* map, * fld; + hawk_val_map_data_t md[3]; struct uci_element* tmp; - qse_awk_int_t count; + hawk_int_t count; count = 0; uci_foreach_element(&uo->v.list, tmp) { count++; } - QSE_MEMSET (md, 0, QSE_SIZEOF(md)); + HAWK_MEMSET (md, 0, HAWK_SIZEOF(md)); - md[0].key.ptr = QSE_T("type"); + md[0].key.ptr = HAWK_T("type"); md[0].key.len = 4; - md[0].type = QSE_AWK_VAL_MAP_DATA_STR; - md[0].vptr = QSE_T("list"); + md[0].type = HAWK_VAL_MAP_DATA_STR; + md[0].vptr = HAWK_T("list"); - md[1].key.ptr = QSE_T("count"); + md[1].key.ptr = HAWK_T("count"); md[1].key.len = 5; - md[1].type = QSE_AWK_VAL_MAP_DATA_INT; + md[1].type = HAWK_VAL_MAP_DATA_INT; md[1].vptr = &count; - map = qse_awk_rtx_makemapvalwithdata (rtx, md); + map = hawk_rtx_makemapvalwithdata (rtx, md); if (map) { count = 1; uci_foreach_element(&uo->v.list, tmp) { - const qse_cstr_t* subsep; - qse_cstr_t k[4]; - qse_char_t idxbuf[64]; - qse_char_t* kp; - qse_size_t kl; + const hawk_cstr_t* subsep; + hawk_cstr_t k[4]; + hawk_char_t idxbuf[64]; + hawk_char_t* kp; + hawk_size_t kl; - fld = qse_awk_rtx_makestrvalwithmbs (rtx, tmp->name); + fld = hawk_rtx_makestrvalwithmbs (rtx, tmp->name); if (!fld) { - qse_awk_rtx_refupval (rtx, map); - qse_awk_rtx_refdownval (rtx, map); - map = QSE_NULL; + hawk_rtx_refupval (rtx, map); + hawk_rtx_refdownval (rtx, map); + map = HAWK_NULL; x = UCI_ERR_MEM; break; } - subsep = qse_awk_rtx_getsubsep (rtx); + subsep = hawk_rtx_getsubsep (rtx); - k[0].ptr = QSE_T("value"); + k[0].ptr = HAWK_T("value"); k[0].len = 5; k[1].ptr = subsep->ptr; k[1].len = subsep->len; k[2].ptr = idxbuf; - k[2].len = qse_fmtuintmax (idxbuf, QSE_COUNTOF(idxbuf), count, 10, -1, QSE_T('\0'), QSE_NULL); - k[3].ptr = QSE_NULL; + k[2].len = hawk_fmtuintmax (idxbuf, HAWK_COUNTOF(idxbuf), count, 10, -1, HAWK_T('\0'), HAWK_NULL); + k[3].ptr = HAWK_NULL; k[3].len = 0; - kp = qse_wcstradup (k, &kl, qse_awk_rtx_getmmgr(rtx)); - if (kp == QSE_NULL || qse_awk_rtx_setmapvalfld (rtx, map, kp, kl, fld) == QSE_NULL) + kp = hawk_wcstradup (k, &kl, hawk_rtx_getmmgr(rtx)); + if (kp == HAWK_NULL || hawk_rtx_setmapvalfld (rtx, map, kp, kl, fld) == HAWK_NULL) { - if (kp) QSE_MMGR_FREE (qse_awk_rtx_getmmgr(rtx), kp); - qse_awk_rtx_refupval (rtx, fld); - qse_awk_rtx_refdownval (rtx, fld); - qse_awk_rtx_refupval (rtx, map); - qse_awk_rtx_refdownval (rtx, map); - map = QSE_NULL; + if (kp) HAWK_MMGR_FREE (hawk_rtx_getmmgr(rtx), kp); + hawk_rtx_refupval (rtx, fld); + hawk_rtx_refdownval (rtx, fld); + hawk_rtx_refupval (rtx, map); + hawk_rtx_refdownval (rtx, map); + map = HAWK_NULL; x = UCI_ERR_MEM; break; } - QSE_MMGR_FREE (qse_awk_rtx_getmmgr(rtx), kp); + HAWK_MMGR_FREE (hawk_rtx_getmmgr(rtx), kp); count++; } if (map) { - if (qse_awk_rtx_setrefval (rtx, ref, map) <= -1) + if (hawk_rtx_setrefval (rtx, ref, map) <= -1) { - qse_awk_rtx_refupval (rtx, map); - qse_awk_rtx_refdownval (rtx, map); - map = QSE_NULL; + hawk_rtx_refupval (rtx, map); + hawk_rtx_refdownval (rtx, map); + map = HAWK_NULL; return -9999; } } @@ -648,69 +648,69 @@ static int getoption_byid ( } /* ------------------------------------------------------------------------ */ -static QSE_INLINE uctx_list_t* rtx_to_list (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static HAWK_INLINE uctx_list_t* rtx_to_list (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { - qse_rbt_pair_t* pair; - pair = qse_rbt_search ((qse_rbt_t*)fi->mod->ctx, &rtx, QSE_SIZEOF(rtx)); - QSE_ASSERT (pair != QSE_NULL); - return (uctx_list_t*)QSE_RBT_VPTR(pair); + hawk_rbt_pair_t* pair; + pair = hawk_rbt_search ((hawk_rbt_t*)fi->mod->ctx, &rtx, HAWK_SIZEOF(rtx)); + HAWK_ASSERT (pair != HAWK_NULL); + return (uctx_list_t*)HAWK_RBT_VPTR(pair); } -static int fnc_uci_errno (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_uci_errno (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { uctx_list_t* list; - qse_awk_val_t* retv; + hawk_val_t* retv; list = rtx_to_list (rtx, fi); - retv = qse_awk_rtx_makeintval (rtx, list->errnum); - if (retv == QSE_NULL) return -1; + retv = hawk_rtx_makeintval (rtx, list->errnum); + if (retv == HAWK_NULL) return -1; - qse_awk_rtx_setretval (rtx, retv); + hawk_rtx_setretval (rtx, retv); return 0; } -static qse_char_t* errmsg[] = +static hawk_char_t* errmsg[] = { - QSE_T("no error"), - QSE_T("out of memory"), - QSE_T("invalid data"), - QSE_T("not found"), - QSE_T("I/O error"), - QSE_T("parse error"), - QSE_T("duplicate data"), - QSE_T("unknown error") + HAWK_T("no error"), + HAWK_T("out of memory"), + HAWK_T("invalid data"), + HAWK_T("not found"), + HAWK_T("I/O error"), + HAWK_T("parse error"), + HAWK_T("duplicate data"), + HAWK_T("unknown error") }; -static int fnc_uci_errstr (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_uci_errstr (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { uctx_list_t* list; - qse_awk_val_t* retv; - qse_awk_int_t errnum; + hawk_val_t* retv; + hawk_int_t errnum; list = rtx_to_list (rtx, fi); - if (qse_awk_rtx_getnargs (rtx) <= 0 || - qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &errnum) <= -1) + if (hawk_rtx_getnargs (rtx) <= 0 || + hawk_rtx_valtoint (rtx, hawk_rtx_getarg (rtx, 0), &errnum) <= -1) { errnum = list->errnum; } - if (errnum < 0 || errnum >= QSE_COUNTOF(errmsg)) errnum = QSE_COUNTOF(errmsg) - 1; + if (errnum < 0 || errnum >= HAWK_COUNTOF(errmsg)) errnum = HAWK_COUNTOF(errmsg) - 1; - retv = qse_awk_rtx_makestrvalwithstr (rtx, errmsg[errnum]); - if (retv == QSE_NULL) return -1; + retv = hawk_rtx_makestrvalwithstr (rtx, errmsg[errnum]); + if (retv == HAWK_NULL) return -1; - qse_awk_rtx_setretval (rtx, retv); + hawk_rtx_setretval (rtx, retv); return 0; } -static int fnc_uci_open (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_uci_open (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { uctx_list_t* list; uctx_node_t* node; - qse_awk_int_t ret; - qse_awk_val_t* retv; + hawk_int_t ret; + hawk_val_t* retv; list = rtx_to_list (rtx, fi); node = new_uctx_node (rtx, list); @@ -722,23 +722,23 @@ static int fnc_uci_open (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) ret = -1; } - retv = qse_awk_rtx_makeintval (rtx, ret); - if (retv == QSE_NULL) return -1; + retv = hawk_rtx_makeintval (rtx, ret); + if (retv == HAWK_NULL) return -1; - qse_awk_rtx_setretval (rtx, retv); + hawk_rtx_setretval (rtx, retv); return 0; } -static int fnc_uci_close (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_uci_close (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { uctx_list_t* list; - qse_awk_val_t* retv; - qse_awk_int_t id; + hawk_val_t* retv; + hawk_int_t id; int ret; list = rtx_to_list (rtx, fi); - ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id); + ret = hawk_rtx_valtoint (rtx, hawk_rtx_getarg (rtx, 0), &id); if (ret <= -1) ret = -UCI_ERR_INVAL; else ret = close_byid (rtx, list, id); @@ -748,33 +748,33 @@ static int fnc_uci_close (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) ret = -1; } - retv = qse_awk_rtx_makeintval (rtx, ret); - if (retv == QSE_NULL) return -1; + retv = hawk_rtx_makeintval (rtx, ret); + if (retv == HAWK_NULL) return -1; - qse_awk_rtx_setretval (rtx, retv); + hawk_rtx_setretval (rtx, retv); return 0; } -static int fnc_uci_load (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_uci_load (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { uctx_list_t* list; - qse_awk_val_t* retv; - qse_awk_int_t id; + hawk_val_t* retv; + hawk_int_t id; int ret; list = rtx_to_list (rtx, fi); - ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id); + ret = hawk_rtx_valtoint (rtx, hawk_rtx_getarg (rtx, 0), &id); if (ret <= -1) ret = -UCI_ERR_INVAL; else { - qse_mchar_t* item; + hawk_mchar_t* item; - item = qse_awk_rtx_valtombsdup(rtx, qse_awk_rtx_getarg(rtx, 1), QSE_NULL); + item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); if (item) { ret = load_byid (rtx, list, id, item); - qse_awk_rtx_freemem (rtx, item); + hawk_rtx_freemem (rtx, item); } else ret = -UCI_ERR_MEM; } @@ -785,23 +785,23 @@ static int fnc_uci_load (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) ret = -1; } - retv = qse_awk_rtx_makeintval (rtx, ret); - if (retv == QSE_NULL) return -1; + retv = hawk_rtx_makeintval (rtx, ret); + if (retv == HAWK_NULL) return -1; - qse_awk_rtx_setretval (rtx, retv); + hawk_rtx_setretval (rtx, retv); return 0; } -static int fnc_uci_unload (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_uci_unload (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { uctx_list_t* list; - qse_awk_val_t* retv; - qse_awk_int_t id; + hawk_val_t* retv; + hawk_int_t id; int ret; list = rtx_to_list (rtx, fi); - ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id); + ret = hawk_rtx_valtoint (rtx, hawk_rtx_getarg (rtx, 0), &id); if (ret <= -1) ret = -UCI_ERR_INVAL; else ret = unload_byid (rtx, list, id); @@ -811,33 +811,33 @@ static int fnc_uci_unload (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) ret = -1; } - retv = qse_awk_rtx_makeintval (rtx, ret); - if (retv == QSE_NULL) return -1; + retv = hawk_rtx_makeintval (rtx, ret); + if (retv == HAWK_NULL) return -1; - qse_awk_rtx_setretval (rtx, retv); + hawk_rtx_setretval (rtx, retv); return 0; } -static int fnc_uci_save (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_uci_save (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { uctx_list_t* list; - qse_awk_val_t* retv; - qse_awk_int_t id; + hawk_val_t* retv; + hawk_int_t id; int ret; list = rtx_to_list (rtx, fi); - ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id); + ret = hawk_rtx_valtoint (rtx, hawk_rtx_getarg (rtx, 0), &id); if (ret <= -1) ret = -UCI_ERR_INVAL; else { - qse_mchar_t* item; + hawk_mchar_t* item; - item = qse_awk_rtx_valtombsdup(rtx, qse_awk_rtx_getarg(rtx, 1), QSE_NULL); + item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); if (item) { ret = save_byid (rtx, list, id, item); - qse_awk_rtx_freemem (rtx, item); + hawk_rtx_freemem (rtx, item); } else ret = -UCI_ERR_MEM; } @@ -848,33 +848,33 @@ static int fnc_uci_save (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) ret = -1; } - retv = qse_awk_rtx_makeintval (rtx, ret); - if (retv == QSE_NULL) return -1; + retv = hawk_rtx_makeintval (rtx, ret); + if (retv == HAWK_NULL) return -1; - qse_awk_rtx_setretval (rtx, retv); + hawk_rtx_setretval (rtx, retv); return 0; } -static int fnc_uci_commit (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_uci_commit (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { uctx_list_t* list; - qse_awk_val_t* retv; - qse_awk_int_t id; + hawk_val_t* retv; + hawk_int_t id; int ret; list = rtx_to_list (rtx, fi); - ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id); + ret = hawk_rtx_valtoint (rtx, hawk_rtx_getarg (rtx, 0), &id); if (ret <= -1) ret = -UCI_ERR_INVAL; else { - qse_mchar_t* item; + hawk_mchar_t* item; - item = qse_awk_rtx_valtombsdup(rtx, qse_awk_rtx_getarg(rtx, 1), QSE_NULL); + item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); if (item) { ret = commit_byid (rtx, list, id, item); - qse_awk_rtx_freemem (rtx, item); + hawk_rtx_freemem (rtx, item); } else ret = -UCI_ERR_MEM; } @@ -885,33 +885,33 @@ static int fnc_uci_commit (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) ret = -1; } - retv = qse_awk_rtx_makeintval (rtx, ret); - if (retv == QSE_NULL) return -1; + retv = hawk_rtx_makeintval (rtx, ret); + if (retv == HAWK_NULL) return -1; - qse_awk_rtx_setretval (rtx, retv); + hawk_rtx_setretval (rtx, retv); return 0; } -static int fnc_uci_revert (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_uci_revert (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { uctx_list_t* list; - qse_awk_val_t* retv; - qse_awk_int_t id; + hawk_val_t* retv; + hawk_int_t id; int ret; list = rtx_to_list (rtx, fi); - ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id); + ret = hawk_rtx_valtoint (rtx, hawk_rtx_getarg (rtx, 0), &id); if (ret <= -1) ret = -UCI_ERR_INVAL; else { - qse_mchar_t* item; + hawk_mchar_t* item; - item = qse_awk_rtx_valtombsdup(rtx, qse_awk_rtx_getarg(rtx, 1), QSE_NULL); + item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); if (item) { ret = revert_byid (rtx, list, id, item); - qse_awk_rtx_freemem (rtx, item); + hawk_rtx_freemem (rtx, item); } else ret = -UCI_ERR_MEM; } @@ -922,33 +922,33 @@ static int fnc_uci_revert (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) ret = -1; } - retv = qse_awk_rtx_makeintval (rtx, ret); - if (retv == QSE_NULL) return -1; + retv = hawk_rtx_makeintval (rtx, ret); + if (retv == HAWK_NULL) return -1; - qse_awk_rtx_setretval (rtx, retv); + hawk_rtx_setretval (rtx, retv); return 0; } -static int fnc_uci_delete (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_uci_delete (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { uctx_list_t* list; - qse_awk_val_t* retv; - qse_awk_int_t id; + hawk_val_t* retv; + hawk_int_t id; int ret; list = rtx_to_list (rtx, fi); - ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id); + ret = hawk_rtx_valtoint (rtx, hawk_rtx_getarg (rtx, 0), &id); if (ret <= -1) ret = -UCI_ERR_INVAL; else { - qse_mchar_t* item; + hawk_mchar_t* item; - item = qse_awk_rtx_valtombsdup(rtx, qse_awk_rtx_getarg(rtx, 1), QSE_NULL); + item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); if (item) { ret = delete_byid (rtx, list, id, item); - qse_awk_rtx_freemem (rtx, item); + hawk_rtx_freemem (rtx, item); } else ret = -UCI_ERR_MEM; } @@ -959,33 +959,33 @@ static int fnc_uci_delete (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) ret = -1; } - retv = qse_awk_rtx_makeintval (rtx, ret); - if (retv == QSE_NULL) return -1; + retv = hawk_rtx_makeintval (rtx, ret); + if (retv == HAWK_NULL) return -1; - qse_awk_rtx_setretval (rtx, retv); + hawk_rtx_setretval (rtx, retv); return 0; } -static int fnc_uci_rename (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_uci_rename (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { uctx_list_t* list; - qse_awk_val_t* retv; - qse_awk_int_t id; + hawk_val_t* retv; + hawk_int_t id; int ret; list = rtx_to_list (rtx, fi); - ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id); + ret = hawk_rtx_valtoint (rtx, hawk_rtx_getarg (rtx, 0), &id); if (ret <= -1) ret = -UCI_ERR_INVAL; else { - qse_mchar_t* item; + hawk_mchar_t* item; - item = qse_awk_rtx_valtombsdup(rtx, qse_awk_rtx_getarg(rtx, 1), QSE_NULL); + item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); if (item) { ret = rename_byid (rtx, list, id, item); - qse_awk_rtx_freemem (rtx, item); + hawk_rtx_freemem (rtx, item); } else ret = -UCI_ERR_MEM; } @@ -996,33 +996,33 @@ static int fnc_uci_rename (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) ret = -1; } - retv = qse_awk_rtx_makeintval (rtx, ret); - if (retv == QSE_NULL) return -1; + retv = hawk_rtx_makeintval (rtx, ret); + if (retv == HAWK_NULL) return -1; - qse_awk_rtx_setretval (rtx, retv); + hawk_rtx_setretval (rtx, retv); return 0; } -static int fnc_uci_set (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_uci_set (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { uctx_list_t* list; - qse_awk_val_t* retv; - qse_awk_int_t id; + hawk_val_t* retv; + hawk_int_t id; int ret; list = rtx_to_list (rtx, fi); - ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id); + ret = hawk_rtx_valtoint (rtx, hawk_rtx_getarg (rtx, 0), &id); if (ret <= -1) ret = -UCI_ERR_INVAL; else { - qse_mchar_t* item; + hawk_mchar_t* item; - item = qse_awk_rtx_valtombsdup(rtx, qse_awk_rtx_getarg(rtx, 1), QSE_NULL); + item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); if (item) { ret = set_byid (rtx, list, id, item); - qse_awk_rtx_freemem (rtx, item); + hawk_rtx_freemem (rtx, item); } else ret = -UCI_ERR_MEM; } @@ -1033,38 +1033,38 @@ static int fnc_uci_set (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) ret = -1; } - retv = qse_awk_rtx_makeintval (rtx, ret); - if (retv == QSE_NULL) return -1; + retv = hawk_rtx_makeintval (rtx, ret); + if (retv == HAWK_NULL) return -1; - qse_awk_rtx_setretval (rtx, retv); + hawk_rtx_setretval (rtx, retv); return 0; } -static int fnc_uci_addsection (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_uci_addsection (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { uctx_list_t* list; - qse_awk_val_t* retv; - qse_awk_int_t id; + hawk_val_t* retv; + hawk_int_t id; int ret; list = rtx_to_list (rtx, fi); - ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id); + ret = hawk_rtx_valtoint (rtx, hawk_rtx_getarg (rtx, 0), &id); if (ret <= -1) ret = -UCI_ERR_INVAL; else { - qse_mchar_t* item, * type; + hawk_mchar_t* item, * type; - item = qse_awk_rtx_valtombsdup(rtx, qse_awk_rtx_getarg(rtx, 1), QSE_NULL); - type = qse_awk_rtx_valtombsdup(rtx, qse_awk_rtx_getarg(rtx, 2), QSE_NULL); + item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); + type = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 2), HAWK_NULL); if (item && type) { ret = addsection_byid (rtx, list, id, item, type); } else ret = -UCI_ERR_MEM; - if (type) qse_awk_rtx_freemem (rtx, type); - if (item) qse_awk_rtx_freemem (rtx, item); + if (type) hawk_rtx_freemem (rtx, type); + if (item) hawk_rtx_freemem (rtx, item); } if (ret <= -1) @@ -1073,33 +1073,33 @@ static int fnc_uci_addsection (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) ret = -1; } - retv = qse_awk_rtx_makeintval (rtx, ret); - if (retv == QSE_NULL) return -1; + retv = hawk_rtx_makeintval (rtx, ret); + if (retv == HAWK_NULL) return -1; - qse_awk_rtx_setretval (rtx, retv); + hawk_rtx_setretval (rtx, retv); return 0; } -static int fnc_uci_addlist (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_uci_addlist (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { uctx_list_t* list; - qse_awk_val_t* retv; - qse_awk_int_t id; + hawk_val_t* retv; + hawk_int_t id; int ret; list = rtx_to_list (rtx, fi); - ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id); + ret = hawk_rtx_valtoint (rtx, hawk_rtx_getarg (rtx, 0), &id); if (ret <= -1) ret = -UCI_ERR_INVAL; else { - qse_mchar_t* item; + hawk_mchar_t* item; - item = qse_awk_rtx_valtombsdup(rtx, qse_awk_rtx_getarg(rtx, 1), QSE_NULL); + item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); if (item) { ret = addlist_byid (rtx, list, id, item); - qse_awk_rtx_freemem (rtx, item); + hawk_rtx_freemem (rtx, item); } else ret = -UCI_ERR_MEM; } @@ -1110,33 +1110,33 @@ static int fnc_uci_addlist (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) ret = -1; } - retv = qse_awk_rtx_makeintval (rtx, ret); - if (retv == QSE_NULL) return -1; + retv = hawk_rtx_makeintval (rtx, ret); + if (retv == HAWK_NULL) return -1; - qse_awk_rtx_setretval (rtx, retv); + hawk_rtx_setretval (rtx, retv); return 0; } -static int fnc_uci_setconfdir (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_uci_setconfdir (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { uctx_list_t* list; - qse_awk_val_t* retv; - qse_awk_int_t id; + hawk_val_t* retv; + hawk_int_t id; int ret; list = rtx_to_list (rtx, fi); - ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id); + ret = hawk_rtx_valtoint (rtx, hawk_rtx_getarg (rtx, 0), &id); if (ret <= -1) ret = -UCI_ERR_INVAL; else { - qse_mchar_t* item; + hawk_mchar_t* item; - item = qse_awk_rtx_valtombsdup(rtx, qse_awk_rtx_getarg(rtx, 1), QSE_NULL); + item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); if (item) { ret = setconfdir_byid (rtx, list, id, item); - qse_awk_rtx_freemem (rtx, item); + hawk_rtx_freemem (rtx, item); } else ret = -UCI_ERR_MEM; } @@ -1147,34 +1147,34 @@ static int fnc_uci_setconfdir (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi ret = -1; } - retv = qse_awk_rtx_makeintval (rtx, ret); - if (retv == QSE_NULL) return -1; + retv = hawk_rtx_makeintval (rtx, ret); + if (retv == HAWK_NULL) return -1; - qse_awk_rtx_setretval (rtx, retv); + hawk_rtx_setretval (rtx, retv); return 0; } -static int fnc_uci_setsavedir (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_uci_setsavedir (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { uctx_list_t* list; - qse_awk_val_t* retv; - qse_awk_int_t id; + hawk_val_t* retv; + hawk_int_t id; int ret; list = rtx_to_list (rtx, fi); - ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id); + ret = hawk_rtx_valtoint (rtx, hawk_rtx_getarg (rtx, 0), &id); if (ret <= -1) ret = -UCI_ERR_INVAL; else { - qse_mchar_t* item; + hawk_mchar_t* item; - item = qse_awk_rtx_valtombsdup(rtx, qse_awk_rtx_getarg(rtx, 1), QSE_NULL); + item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); if (item) { ret = setsavedir_byid (rtx, list, id, item); - qse_awk_rtx_freemem (rtx, item); + hawk_rtx_freemem (rtx, item); } else ret = -UCI_ERR_MEM; } @@ -1185,33 +1185,33 @@ static int fnc_uci_setsavedir (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi ret = -1; } - retv = qse_awk_rtx_makeintval (rtx, ret); - if (retv == QSE_NULL) return -1; + retv = hawk_rtx_makeintval (rtx, ret); + if (retv == HAWK_NULL) return -1; - qse_awk_rtx_setretval (rtx, retv); + hawk_rtx_setretval (rtx, retv); return 0; } -static int fnc_uci_adddeltapath (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_uci_adddeltapath (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { uctx_list_t* list; - qse_awk_val_t* retv; - qse_awk_int_t id; + hawk_val_t* retv; + hawk_int_t id; int ret; list = rtx_to_list (rtx, fi); - ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id); + ret = hawk_rtx_valtoint (rtx, hawk_rtx_getarg (rtx, 0), &id); if (ret <= -1) ret = -UCI_ERR_INVAL; else { - qse_mchar_t* item; + hawk_mchar_t* item; - item = qse_awk_rtx_valtombsdup(rtx, qse_awk_rtx_getarg(rtx, 1), QSE_NULL); + item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); if (item) { ret = adddeltapath_byid (rtx, list, id, item); - qse_awk_rtx_freemem (rtx, item); + hawk_rtx_freemem (rtx, item); } else ret = -UCI_ERR_MEM; } @@ -1222,32 +1222,32 @@ static int fnc_uci_adddeltapath (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* ret = -1; } - retv = qse_awk_rtx_makeintval (rtx, ret); - if (retv == QSE_NULL) return -1; + retv = hawk_rtx_makeintval (rtx, ret); + if (retv == HAWK_NULL) return -1; - qse_awk_rtx_setretval (rtx, retv); + hawk_rtx_setretval (rtx, retv); return 0; } -static int fnc_uci_getoption (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_uci_getoption (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { uctx_list_t* list; - qse_awk_int_t id; + hawk_int_t id; int ret; list = rtx_to_list (rtx, fi); - ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id); + ret = hawk_rtx_valtoint (rtx, hawk_rtx_getarg (rtx, 0), &id); if (ret <= -1) ret = -UCI_ERR_INVAL; else { - qse_mchar_t* item; + hawk_mchar_t* item; - item = qse_awk_rtx_valtombsdup(rtx, qse_awk_rtx_getarg(rtx, 1), QSE_NULL); + item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); if (item) { - ret = getoption_byid (rtx, list, id, item, qse_awk_rtx_getarg (rtx, 2)); - qse_awk_rtx_freemem (rtx, item); + ret = getoption_byid (rtx, list, id, item, hawk_rtx_getarg (rtx, 2)); + hawk_rtx_freemem (rtx, item); if (ret == -9999) return -1; } else ret = -UCI_ERR_MEM; @@ -1260,29 +1260,29 @@ static int fnc_uci_getoption (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) } else ret = 0; - qse_awk_rtx_setretval (rtx, qse_awk_rtx_makeintval (rtx, ret)); + hawk_rtx_setretval (rtx, hawk_rtx_makeintval (rtx, ret)); return 0; } -static int fnc_uci_getsection (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) +static int fnc_uci_getsection (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { uctx_list_t* list; - qse_awk_int_t id; + hawk_int_t id; int ret; list = rtx_to_list (rtx, fi); - ret = qse_awk_rtx_valtoint(rtx, qse_awk_rtx_getarg (rtx, 0), &id); + ret = hawk_rtx_valtoint(rtx, hawk_rtx_getarg (rtx, 0), &id); if (ret <= -1) ret = -UCI_ERR_INVAL; else { - qse_mchar_t* item; + hawk_mchar_t* item; - item = qse_awk_rtx_valtombsdup(rtx, qse_awk_rtx_getarg (rtx, 1), QSE_NULL); + item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg (rtx, 1), HAWK_NULL); if (item) { - ret = getsection_byid(rtx, list, id, item, qse_awk_rtx_getarg (rtx, 2)); - qse_awk_rtx_freemem (rtx, item); + ret = getsection_byid(rtx, list, id, item, hawk_rtx_getarg (rtx, 2)); + hawk_rtx_freemem (rtx, item); if (ret == -9999) return -1; } else ret = -UCI_ERR_MEM; @@ -1295,7 +1295,7 @@ static int fnc_uci_getsection (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) } else ret = 0; - qse_awk_rtx_setretval (rtx, qse_awk_rtx_makeintval (rtx, ret)); + hawk_rtx_setretval (rtx, hawk_rtx_makeintval (rtx, ret)); return 0; } @@ -1304,95 +1304,92 @@ static int fnc_uci_getsection (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) typedef struct fnctab_t fnctab_t; struct fnctab_t { - const qse_char_t* name; - qse_awk_mod_sym_fnc_t info; + const hawk_char_t* name; + hawk_mod_sym_fnc_t info; }; static fnctab_t fnctab[] = { - { QSE_T("adddeltapath"), { { 2, 2, QSE_NULL }, fnc_uci_adddeltapath, 0 } }, - { QSE_T("addlist"), { { 2, 2, QSE_NULL }, fnc_uci_addlist, 0 } }, - { QSE_T("addsection"), { { 3, 3, QSE_NULL }, fnc_uci_addsection, 0 } }, - { QSE_T("close"), { { 1, 1, QSE_NULL }, fnc_uci_close, 0 } }, - { QSE_T("commit"), { { 2, 2, QSE_NULL }, fnc_uci_commit, 0 } }, - { QSE_T("delete"), { { 2, 2, QSE_NULL }, fnc_uci_delete, 0 } }, - { QSE_T("errno"), { { 0, 0, QSE_NULL }, fnc_uci_errno, 0 } }, - { QSE_T("errstr"), { { 0, 1, QSE_NULL }, fnc_uci_errstr, 0 } }, - { QSE_T("getoption"), { { 3, 3, QSE_T("vvr")}, fnc_uci_getoption, 0 } }, - { QSE_T("getsection"), { { 3, 3, QSE_T("vvr")}, fnc_uci_getsection, 0 } }, - { QSE_T("load"), { { 2, 2, QSE_NULL }, fnc_uci_load, 0 } }, - { QSE_T("open"), { { 0, 0, QSE_NULL }, fnc_uci_open, 0 } }, - { QSE_T("rename"), { { 2, 2, QSE_NULL }, fnc_uci_rename, 0 } }, - { QSE_T("revert"), { { 2, 2, QSE_NULL }, fnc_uci_revert, 0 } }, - { QSE_T("save"), { { 2, 2, QSE_NULL }, fnc_uci_save, 0 } }, - { QSE_T("set"), { { 2, 2, QSE_NULL }, fnc_uci_set, 0 } }, - { QSE_T("setconfdir"), { { 2, 2, QSE_NULL }, fnc_uci_setconfdir, 0 } }, - { QSE_T("setsavedir"), { { 2, 2, QSE_NULL }, fnc_uci_setsavedir, 0 } }, - { QSE_T("unload"), { { 1, 1, QSE_NULL }, fnc_uci_unload, 0 } } + { HAWK_T("adddeltapath"), { { 2, 2, HAWK_NULL }, fnc_uci_adddeltapath, 0 } }, + { HAWK_T("addlist"), { { 2, 2, HAWK_NULL }, fnc_uci_addlist, 0 } }, + { HAWK_T("addsection"), { { 3, 3, HAWK_NULL }, fnc_uci_addsection, 0 } }, + { HAWK_T("close"), { { 1, 1, HAWK_NULL }, fnc_uci_close, 0 } }, + { HAWK_T("commit"), { { 2, 2, HAWK_NULL }, fnc_uci_commit, 0 } }, + { HAWK_T("delete"), { { 2, 2, HAWK_NULL }, fnc_uci_delete, 0 } }, + { HAWK_T("errno"), { { 0, 0, HAWK_NULL }, fnc_uci_errno, 0 } }, + { HAWK_T("errstr"), { { 0, 1, HAWK_NULL }, fnc_uci_errstr, 0 } }, + { HAWK_T("getoption"), { { 3, 3, HAWK_T("vvr")}, fnc_uci_getoption, 0 } }, + { HAWK_T("getsection"), { { 3, 3, HAWK_T("vvr")}, fnc_uci_getsection, 0 } }, + { HAWK_T("load"), { { 2, 2, HAWK_NULL }, fnc_uci_load, 0 } }, + { HAWK_T("open"), { { 0, 0, HAWK_NULL }, fnc_uci_open, 0 } }, + { HAWK_T("rename"), { { 2, 2, HAWK_NULL }, fnc_uci_rename, 0 } }, + { HAWK_T("revert"), { { 2, 2, HAWK_NULL }, fnc_uci_revert, 0 } }, + { HAWK_T("save"), { { 2, 2, HAWK_NULL }, fnc_uci_save, 0 } }, + { HAWK_T("set"), { { 2, 2, HAWK_NULL }, fnc_uci_set, 0 } }, + { HAWK_T("setconfdir"), { { 2, 2, HAWK_NULL }, fnc_uci_setconfdir, 0 } }, + { HAWK_T("setsavedir"), { { 2, 2, HAWK_NULL }, fnc_uci_setsavedir, 0 } }, + { HAWK_T("unload"), { { 1, 1, HAWK_NULL }, fnc_uci_unload, 0 } } }; /* ------------------------------------------------------------------------ */ -static int query (qse_awk_mod_t* mod, qse_awk_t* awk, const qse_char_t* name, qse_awk_mod_sym_t* sym) +static int query (hawk_mod_t* mod, hawk_t* awk, const hawk_char_t* name, hawk_mod_sym_t* sym) { - qse_cstr_t ea; int left, right, mid, n; - left = 0; right = QSE_COUNTOF(fnctab) - 1; + left = 0; right = HAWK_COUNTOF(fnctab) - 1; while (left <= right) { mid = left + (right - left) / 2; - n = qse_strcmp (fnctab[mid].name, name); + n = hawk_strcmp (fnctab[mid].name, name); if (n > 0) right = mid - 1; else if (n < 0) left = mid + 1; else { - sym->type = QSE_AWK_MOD_FNC; + sym->type = HAWK_MOD_FNC; sym->u.fnc = fnctab[mid].info; return 0; } } - ea.ptr = name; - ea.len = qse_strlen(name); - qse_awk_seterror (awk, QSE_AWK_ENOENT, &ea, QSE_NULL); + hawk_seterrfmt (awk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js' not found"), name); return -1; } -static int init (qse_awk_mod_t* mod, qse_awk_rtx_t* rtx) +static int init (hawk_mod_t* mod, hawk_rtx_t* rtx) { - qse_rbt_t* rbt; + hawk_rbt_t* rbt; uctx_list_t list; - rbt = (qse_rbt_t*)mod->ctx; + rbt = (hawk_rbt_t*)mod->ctx; - QSE_MEMSET (&list, 0, QSE_SIZEOF(list)); - if (qse_rbt_insert (rbt, &rtx, QSE_SIZEOF(rtx), &list, QSE_SIZEOF(list)) == QSE_NULL) + HAWK_MEMSET (&list, 0, HAWK_SIZEOF(list)); + if (hawk_rbt_insert (rbt, &rtx, HAWK_SIZEOF(rtx), &list, HAWK_SIZEOF(list)) == HAWK_NULL) { - qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL); + hawk_rtx_seterrnum (rtx, HAWK_ENOMEM, HAWK_NULL); return -1; } return 0; } -static void fini (qse_awk_mod_t* mod, qse_awk_rtx_t* rtx) +static void fini (hawk_mod_t* mod, hawk_rtx_t* rtx) { - qse_rbt_t* rbt; - qse_rbt_pair_t* pair; + hawk_rbt_t* rbt; + hawk_rbt_pair_t* pair; - rbt = (qse_rbt_t*)mod->ctx; + rbt = (hawk_rbt_t*)mod->ctx; /* garbage clean-up */ - pair = qse_rbt_search (rbt, &rtx, QSE_SIZEOF(rtx)); + pair = hawk_rbt_search (rbt, &rtx, HAWK_SIZEOF(rtx)); if (pair) { uctx_list_t* list; uctx_node_t* node, * next; - list = QSE_RBT_VPTR(pair); + list = HAWK_RBT_VPTR(pair); node = list->head; while (node) { @@ -1401,23 +1398,23 @@ static void fini (qse_awk_mod_t* mod, qse_awk_rtx_t* rtx) node = next; } - qse_rbt_delete (rbt, &rtx, QSE_SIZEOF(rtx)); + hawk_rbt_delete (rbt, &rtx, HAWK_SIZEOF(rtx)); } } -static void unload (qse_awk_mod_t* mod, qse_awk_t* awk) +static void unload (hawk_mod_t* mod, hawk_t* hawk) { - qse_rbt_t* rbt; + hawk_rbt_t* rbt; - rbt = (qse_rbt_t*)mod->ctx; + rbt = (hawk_rbt_t*)mod->ctx; - QSE_ASSERT (QSE_RBT_SIZE(rbt) == 0); - qse_rbt_close (rbt); + HAWK_ASSERT (HAWK_RBT_SIZE(rbt) == 0); + hawk_rbt_close (rbt); } -int qse_awk_mod_uci (qse_awk_mod_t* mod, qse_awk_t* awk) +int hawk_mod_uci (hawk_mod_t* mod, hawk_t* hawk) { - qse_rbt_t* rbt; + hawk_rbt_t* rbt; mod->query = query; mod->unload = unload; @@ -1425,13 +1422,10 @@ int qse_awk_mod_uci (qse_awk_mod_t* mod, qse_awk_t* awk) mod->init = init; mod->fini = fini; - rbt = qse_rbt_open (qse_awk_getmmgr(awk), 0, 1, 1); - if (rbt == QSE_NULL) - { - qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL); - return -1; - } - qse_rbt_setstyle (rbt, qse_getrbtstyle(QSE_RBT_STYLE_INLINE_COPIERS)); + rbt = hawk_rbt_open (hawk_getgem(hawk), 0, 1, 1); + if (rbt == HAWK_NULL) return -1; + + hawk_rbt_setstyle (rbt, hawk_getrbtstyle(HAWK_RBT_STYLE_INLINE_COPIERS)); mod->ctx = rbt; return 0; diff --git a/hawk/mod/mod-uci.h b/hawk/mod/mod-uci.h index 6688e737..c21e2d88 100644 --- a/hawk/mod/mod-uci.h +++ b/hawk/mod/mod-uci.h @@ -24,16 +24,16 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _QSE_LIB_AWKMOD_UCI_H_ -#define _QSE_LIB_AWKMOD_UCI_H_ +#ifndef _HAWK_MOD_UCI_H_ +#define _HAWK_MOD_UCI_H_ -#include +#include #if defined(__cplusplus) extern "C" { #endif -QSE_EXPORT int qse_awk_mod_uci (qse_awk_mod_t* mod, qse_awk_t* awk); +HAWK_EXPORT int hawk_mod_uci (hawk_mod_t* mod, hawk_t* hawk); #if defined(__cplusplus) } diff --git a/hawk/t/test.txt b/hawk/t/test.txt index 2e66900b..c46e6e19 100644 --- a/hawk/t/test.txt +++ b/hawk/t/test.txt @@ -148,8 +148,46 @@ $ ~/xxx/bin/hawk --implicit=off 'BEGIN { print kcx[10]; }' HAWK_EUNDEF -> ERROR: CODE 69 LINE 1 COLUMN 16 - undefined identifier 'kcx' $ ~/xxx/bin/hawk --implicit=off 'BEGIN { print ax; }' -ERROR: CODE 69 LINE 1 COLUMN 16 - undefined identifier 'ax' +HAWK_EUNDEF -> ERROR: CODE 69 LINE 1 COLUMN 16 - undefined identifier 'ax' $ ~/xxx/bin/hawk 'function 1.2(a) {}' -ERROR: CODE 54 LINE 1 COLUMN 10 - '1.2' not a valid function name +HAWK_EFUNNAM -> ERROR: CODE 54 LINE 1 COLUMN 10 - '1.2' not a valid function name + + +$ ~/xxx/bin/hawk 'function abc(x) print t; }' +HAWK_ELBRACE -> ERROR: CODE 38 LINE 1 COLUMN 17 - left brace expected in place of 'print' + + +$ ~/xxx/bin/hawk 'function abc(x) { print a[10; }' +HAWK_ERBRACK -> ERROR: CODE 41 LINE 1 COLUMN 29 - right bracket expected in place of ';' + + +$ ~/xxx/bin/hawk 'function abc x) { print 10; }' +HAWK_ELPAREN -> ERROR: CODE 39 LINE 1 COLUMN 14 - left parenthesis expected in place of 'x' + +$ ~/xxx/bin/hawk 'function abc (x) { print (x; }' +HAWK_EPAREN -> ERROR: CODE 40 LINE 1 COLUMN 28 - right parenthesis expected in place of ';' + +$ ~/xxx/bin/hawk 'function abc (x { print 10; }' +HAWK_ECOMMA -> ERROR: CODE 42 LINE 1 COLUMN 17 - comma expected in place of '{' + +$ ~/xxx/bin/hawk 'function abc (x) { for (i = 10) print i; }' +HAWK_ESCOLON -> ERROR: CODE 43 LINE 1 COLUMN 31 - semicolon expected in place of ')' + +$ ~/xxx/bin/hawk 'function abc (x) { print (i? 20, 30); }' +HAWK_ECOLON -> ERROR: CODE 44 LINE 1 COLUMN 32 - colon expected in place of ',' + + +$ ~/xxx/bin/hawk '@includ "xxx.inc"; BEGIN {}' +HAWK_EXKWNR -> ERROR: CODE 88 LINE 1 COLUMN 1 - '@includ' not recognized + +$ ~/xxx/bin/hawk 'function abc (x) { do { print x }; }' +HAWK_EKWWHL -> ERROR: CODE 51 LINE 1 COLUMN 34 - keyword 'while' expected in place of ';' + +$ ~/xxx/bin/hawk 'function abc (x) { do { print sysxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxtt::xx }; }' +HAWK_ESEGTL -> ERROR: CODE 75 LINE 1 COLUMN 31 - segment 'sysxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxtt' too long + +$ ~/xxx/bin/hawk --tolerant=off 'function abc (x) { (1, 2, 3) }' +HAWK_EKWIN -> ERROR: CODE 47 LINE 1 COLUMN 30 - keyword 'in' expected in place of '}' +