diff --git a/configure b/configure index 2bcd588c..268a995b 100755 --- a/configure +++ b/configure @@ -20279,6 +20279,12 @@ then : printf "%s\n" "#define HAVE_CRT_EXTERNS_H 1" >>confdefs.h fi +ac_fn_c_check_header_compile "$LINENO" "uci.h" "ac_cv_header_uci_h" "$ac_includes_default" +if test "x$ac_cv_header_uci_h" = xyes +then : + printf "%s\n" "#define HAVE_UCI_H 1" >>confdefs.h + +fi diff --git a/configure.ac b/configure.ac index 78eeddec..7cf06b09 100644 --- a/configure.ac +++ b/configure.ac @@ -252,7 +252,7 @@ AC_CHECK_HEADERS([netinet/in.h sys/un.h netpacket/packet.h net/if.h net/if_dl.h #include #include ]) AC_CHECK_HEADERS([sys/stropts.h sys/macstat.h linux/ethtool.h linux/sockios.h]) -AC_CHECK_HEADERS([ffi.h libunwind.h quadmath.h crt_externs.h]) +AC_CHECK_HEADERS([ffi.h libunwind.h quadmath.h crt_externs.h uci.h]) dnl check data types dnl AC_CHECK_TYPE([wchar_t], diff --git a/lib/gem.c b/lib/gem.c index 95030dbd..6eae887b 100644 --- a/lib/gem.c +++ b/lib/gem.c @@ -172,6 +172,43 @@ hawk_bch_t* hawk_gem_dupbcstrarr (hawk_gem_t* gem, const hawk_bch_t* str[], hawk return buf; } +hawk_uch_t* hawk_gem_dupucsarr (hawk_gem_t* gem, const hawk_ucs_t* str, hawk_oow_t* len) +{ + hawk_uch_t* buf, * ptr; + hawk_oow_t i; + hawk_oow_t capa = 0; + + for (i = 0; str[i].ptr; i++) capa += str[i].len; + + buf = (hawk_uch_t*)hawk_gem_allocmem(gem, (capa + 1) * HAWK_SIZEOF(*buf)); + if (!buf) return HAWK_NULL; + + ptr = buf; + for (i = 0; str[i].ptr; i++) ptr += hawk_copy_uchars_to_ucstr_unlimited(ptr, str[i].ptr, str[i].len); + + if (len) *len = capa; + return buf; +} + +hawk_bch_t* hawk_gem_dupbcsarr (hawk_gem_t* gem, const hawk_bcs_t* str, hawk_oow_t* len) +{ + hawk_bch_t* buf, * ptr; + hawk_oow_t i; + hawk_oow_t capa = 0; + + for (i = 0; str[i].ptr; i++) capa += str[i].len; + + buf = (hawk_bch_t*)hawk_gem_allocmem(gem, (capa + 1) * HAWK_SIZEOF(*buf)); + if (!buf) return HAWK_NULL; + + ptr = buf; + for (i = 0; str[i].ptr; i++) ptr += hawk_copy_bchars_to_bcstr_unlimited(ptr, str[i].ptr, str[i].len); + + if (len) *len = capa; + return buf; +} + + /* ------------------------------------------------------------------------ */ int hawk_gem_convbtouchars (hawk_gem_t* gem, const hawk_bch_t* bcs, hawk_oow_t* bcslen, hawk_uch_t* ucs, hawk_oow_t* ucslen, int all) diff --git a/lib/hawk-cfg.h.in b/lib/hawk-cfg.h.in index 0f2a9092..088ff6f3 100644 --- a/lib/hawk-cfg.h.in +++ b/lib/hawk-cfg.h.in @@ -618,6 +618,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_TIME_H +/* Define to 1 if you have the header file. */ +#undef HAVE_UCI_H + /* Define to 1 if you have the header file. */ #undef HAVE_UCONTEXT_H diff --git a/lib/hawk-gem.h b/lib/hawk-gem.h index 1720fd07..f62e7b29 100644 --- a/lib/hawk-gem.h +++ b/lib/hawk-gem.h @@ -168,16 +168,30 @@ HAWK_EXPORT hawk_bch_t* hawk_gem_dupbcstrarr ( hawk_oow_t* len ); +HAWK_EXPORT hawk_uch_t* hawk_gem_dupucsarr ( + hawk_gem_t* gem, + const hawk_ucs_t* str, + hawk_oow_t* len +); + +HAWK_EXPORT hawk_bch_t* hawk_gem_dupbcsarr ( + hawk_gem_t* gem, + const hawk_bcs_t* str, + hawk_oow_t* len +); + #if defined(HAWK_OOCH_IS_UCH) # define hawk_gem_dupoocstr hawk_gem_dupucstr # define hawk_gem_dupoochars hawk_gem_dupuchars # define hawk_gem_dupoocs hawk_gem_dupucs # define hawk_gem_dupoocstrarr hawk_gem_dupucstrarr +# define hawk_gem_dupoocsarr hawk_gem_dupucsarr #else # define hawk_gem_dupoocstr hawk_gem_dupbcstr # define hawk_gem_dupoochars hawk_gem_dupbchars # define hawk_gem_dupoocs hawk_gem_dupbcs # define hawk_gem_dupoocstrarr hawk_gem_dupbcstrarr +# define hawk_gem_dupoocsarr hawk_gem_dupbcsarr #endif /* ----------------------------------------------------------------------- */ diff --git a/lib/hawk.h b/lib/hawk.h index 5535a68e..fab9f7bd 100644 --- a/lib/hawk.h +++ b/lib/hawk.h @@ -3207,7 +3207,7 @@ HAWK_EXPORT void hawk_rtx_refdownval_nofree ( #define HAWK_RTX_GC_GEN_AUTO (-1) /* - * The hawk_rtc_gc() function triggers garbage collection. + * The hawk_rtx_gc() function triggers garbage collection. * It returns the generation number collected and never fails */ HAWK_EXPORT int hawk_rtx_gc ( @@ -3531,6 +3531,8 @@ static HAWK_INLINE hawk_uch_t* hawk_rtx_dupucs (hawk_rtx_t* rtx, const hawk_ucs_ static HAWK_INLINE hawk_bch_t* hawk_rtx_dupbcs (hawk_rtx_t* rtx, const hawk_bcs_t* bcs) { return hawk_gem_dupbcs(hawk_rtx_getgem(rtx), bcs); } static HAWK_INLINE hawk_uch_t* hawk_rtx_dupucstrarr (hawk_rtx_t* rtx, const hawk_uch_t* strs[], hawk_oow_t* len) { return hawk_gem_dupucstrarr(hawk_rtx_getgem(rtx), strs, len); } static HAWK_INLINE hawk_bch_t* hawk_rtx_dupbcstrarr (hawk_rtx_t* rtx, const hawk_bch_t* strs[], hawk_oow_t* len) { return hawk_gem_dupbcstrarr(hawk_rtx_getgem(rtx), strs, len); } +static HAWK_INLINE hawk_uch_t* hawk_rtx_dupucsarr (hawk_rtx_t* rtx, const hawk_ucs_t* strs, hawk_oow_t* len) { return hawk_gem_dupucsarr(hawk_rtx_getgem(rtx), strs, len); } +static HAWK_INLINE hawk_bch_t* hawk_rtx_dupbcsarr (hawk_rtx_t* rtx, const hawk_bcs_t* strs, hawk_oow_t* len) { return hawk_gem_dupbcsarr(hawk_rtx_getgem(rtx), strs, len); } #else #define hawk_rtx_dupucstr(rtx, ucs, ucslen) hawk_gem_dupucstr(hawk_rtx_getgem(rtx), ucs, ucslen) #define hawk_rtx_dupbcstr(rtx, bcs, bcslen) hawk_gem_dupbcstr(hawk_rtx_getgem(rtx), bcs, bcslen) @@ -3540,6 +3542,8 @@ static HAWK_INLINE hawk_bch_t* hawk_rtx_dupbcstrarr (hawk_rtx_t* rtx, const hawk #define hawk_rtx_dupbcs(rtx, bcs) hawk_gem_dupbcs(hawk_rtx_getgem(rtx), bcs) #define hawk_rtx_dupucstrarr(rtx, strs, len) hawk_gem_dupucstrarr(hawk_rtx_getgem(rtx), strs, len) #define hawk_rtx_dupbcstrarr(rtx, strs, len) hawk_gem_dupbcstrarr(hawk_rtx_getgem(rtx), strs, len) +#define hawk_rtx_dupucsarr(rtx, strs, len) hawk_gem_dupucsarr(hawk_rtx_getgem(rtx), strs, len) +#define hawk_rtx_dupbcsarr(rtx, strs, len) hawk_gem_dupbcsarr(hawk_rtx_getgem(rtx), strs, len) #endif #if defined(HAWK_OOCH_IS_UCH) @@ -3547,11 +3551,13 @@ static HAWK_INLINE hawk_bch_t* hawk_rtx_dupbcstrarr (hawk_rtx_t* rtx, const hawk # define hawk_rtx_dupoochars hawk_rtx_dupuchars # define hawk_rtx_dupoocs hawk_rtx_dupucs # define hawk_rtx_dupoocstrarr hawk_rtx_dupucstrarr +# define hawk_rtx_dupoocsarr hawk_rtx_dupucsarr #else # define hawk_rtx_dupoocstr hawk_rtx_dupbcstr # define hawk_rtx_dupoochars hawk_rtx_dupbchars # define hawk_rtx_dupoocs hawk_rtx_dupbcs # define hawk_rtx_dupoocstrarr hawk_rtx_dupbcstrarr +# define hawk_rtx_dupoocsarr hawk_rtx_dupbcsarr #endif /* ----------------------------------------------------------------------- */ diff --git a/mod/mod-ffi.c b/mod/mod-ffi.c index c00148a7..9469b3ff 100644 --- a/mod/mod-ffi.c +++ b/mod/mod-ffi.c @@ -194,7 +194,7 @@ static ffi_node_t* new_ffi_node (hawk_rtx_t* rtx, ffi_list_t* ffi_list, const ha { hawk_t* hawk = hawk_rtx_gethawk(rtx); ffi_node_t* ffi_node; - + void* handle; ffi_node = __new_ffi_node(rtx, ffi_list); @@ -211,7 +211,7 @@ static ffi_node_t* new_ffi_node (hawk_rtx_t* rtx, ffi_list_t* ffi_list, const ha { handle = hawk->prm.modopen(hawk, HAWK_NULL); } - if (!handle) + if (!handle) { const hawk_ooch_t* olderrmsg; olderrmsg = hawk_backuperrmsg(hawk); @@ -838,8 +838,8 @@ static int fnc_call (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) continue; } - /* more items in signature than the actual argument */ - if (j >= hawk_rtx_getnargs(rtx) - FNC_CALL_ARG_BASE) + /* more items in signature than the actual argument */ + if (j >= hawk_rtx_getnargs(rtx) - FNC_CALL_ARG_BASE) { ret = set_error_on_ffi_list(rtx, ffi_list, HAWK_EINVAL, HAWK_T("two few arguments for the argument signature")); goto done; @@ -852,7 +852,7 @@ static int fnc_call (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) while (i < sig.len && sig.ptr[i] == ' ') i++; /* skip all spaces after > */ fmtc = (i >= sig.len)? FMTC_NULL: sig.ptr[i]; - if (fmtc == 'u') + if (fmtc == 'u') { _unsigned = 1; fmtc = (i >= sig.len)? FMTC_NULL: sig.ptr[i]; diff --git a/mod/mod-mysql.c b/mod/mod-mysql.c index d137c68a..c44a58c6 100644 --- a/mod/mod-mysql.c +++ b/mod/mod-mysql.c @@ -395,7 +395,7 @@ static int fnc_open (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) if (sql_node) ret = sql_node->id; else set_error_on_sql_list (rtx, sql_list, HAWK_NULL); - /* ret may not be a statically managed number. + /* ret may not be a statically managed number. * error checking is required */ retv = hawk_rtx_makeintval(rtx, ret); if (retv == HAWK_NULL) @@ -475,7 +475,7 @@ static int fnc_get_option (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) #if defined(DUMMY_OPT_RECONNECT) case DUMMY_OPT_RECONNECT: /* the system without MYSQL_OPT_RECONNECT available. return 1 all the time */ - if (hawk_rtx_setrefval(rtx, (hawk_val_ref_t*)hawk_rtx_getarg(rtx, 2), hawk_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) { hawk_rtx_refupval(rtx, retv); hawk_rtx_refdownval(rtx, retv); @@ -495,7 +495,7 @@ static int fnc_get_option (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) retv = hawk_rtx_makeintval(rtx, v.b); if (!retv) goto oops; - if (hawk_rtx_setrefval(rtx, (hawk_val_ref_t*)hawk_rtx_getarg(rtx, 2), retv) <= -1) + if (hawk_rtx_setrefval(rtx, (hawk_val_ref_t*)hawk_rtx_getarg(rtx, 2), retv) <= -1) { hawk_rtx_refupval(rtx, retv); hawk_rtx_refdownval(rtx, retv); @@ -632,7 +632,7 @@ static int fnc_connect (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { arg_fail: take_rtx_err = 1; - goto done; + goto done; } if (nargs >= 5) @@ -1044,7 +1044,7 @@ static int fnc_store_result (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) } res_node = new_res_node(rtx, res_list, res); - if (!res_node) + if (!res_node) { mysql_free_result (res); take_rtx_err = 1; @@ -1124,7 +1124,7 @@ static int fnc_fetch_row (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { /* TODO: consider using make multi byte string - hawk_rtx_makembsstr depending on user options or depending on column types */ row_val = hawk_rtx_makestrvalwithbcstr(rtx, row[i]); - if (!row_val) + if (!row_val) { take_rtx_err = 1; goto done; @@ -1137,7 +1137,7 @@ static int fnc_fetch_row (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) ++i; - /* put it into the map */ + /* put it into the map */ key_len = hawk_int_to_oocstr(i, 10, HAWK_NULL, key_buf, HAWK_COUNTOF(key_buf)); /* TOOD: change this function to hawk_rtx_intxxxxx */ HAWK_ASSERT (key_len != (hawk_oow_t)-1); @@ -1229,11 +1229,11 @@ static int fnc_stmt_close (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) stmt_node = get_stmt_list_node_with_arg(rtx, sql_list, stmt_list, hawk_rtx_getarg(rtx, 0)); if (stmt_node) { - if (stmt_node->res_data) + if (stmt_node->res_data) { if (stmt_node->res_binds) { - /* the program guarantees thats res_binds is non-null if res_data is to have + /* the program guarantees thats res_binds is non-null if res_data is to have * some valid data. so i do this clearance if res_binds is non-null */ hawk_oow_t i; for (i = 0; i < stmt_node->res_capa; i++) @@ -1253,11 +1253,11 @@ static int fnc_stmt_close (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) if (stmt_node->res_binds) hawk_rtx_freemem (rtx, stmt_node->res_binds); - if (stmt_node->param_data) + if (stmt_node->param_data) { if (stmt_node->param_binds) { - /* the program guarantees thats param_binds is non-null if param_data is to have + /* the program guarantees thats param_binds is non-null if param_data is to have * some valid data. so i do this clearance if param_binds is non-null */ hawk_oow_t i; for (i = 0; i < stmt_node->param_capa; i++) @@ -1520,7 +1520,7 @@ static int fnc_stmt_execute (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) HAWK_MEMSET (stmt_node->res_binds, 0, HAWK_SIZEOF(MYSQL_BIND)* stmt_node->res_capa); HAWK_MEMSET (stmt_node->res_data, 0, HAWK_SIZEOF(res_data_t)* stmt_node->res_capa); - + for (i = 0; i < ncols; i++) { /* TOOD: more types... */ @@ -1855,7 +1855,7 @@ static void fini (hawk_mod_t* mod, hawk_rtx_t* rtx) { hawk_rbt_t* rbt; hawk_rbt_pair_t* pair; - + rbt = (hawk_rbt_t*)mod->ctx; /* garbage clean-up */ diff --git a/mod/mod-sed.c b/mod/mod-sed.c index e5883250..a3d9bbb6 100644 --- a/mod/mod-sed.c +++ b/mod/mod-sed.c @@ -94,7 +94,7 @@ static int fnc_file_to_file (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) /* result = sed::file_to_file ("s/ABC/123/g", input_file, output_file [, option_string]) */ sed = hawk_sed_openstdwithmmgr(hawk_rtx_getmmgr(rtx), 0, hawk_rtx_getcmgr(rtx), HAWK_NULL); - if (sed == HAWK_NULL) + if (sed == HAWK_NULL) { ret = -2; goto oops; @@ -106,20 +106,20 @@ static int fnc_file_to_file (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { a[i] = hawk_rtx_getarg(rtx, i); xstr[i].ptr = hawk_rtx_getvaloocstr(rtx, a[i], &xstr[i].len); - if (xstr[i].ptr == HAWK_NULL) + if (xstr[i].ptr == HAWK_NULL) { ret = -2; goto oops; } } - if (hawk_sed_compstdoocs(sed, &xstr[0]) <= -1) + if (hawk_sed_compstdoocs(sed, &xstr[0]) <= -1) { ret = -3; /* compile error */ goto oops; } - if (hawk_sed_execstdfile(sed, xstr[1].ptr, xstr[2].ptr, HAWK_NULL) <= -1) + if (hawk_sed_execstdfile(sed, xstr[1].ptr, xstr[2].ptr, HAWK_NULL) <= -1) { ret = -4; goto oops; @@ -150,7 +150,7 @@ static int fnc_str_to_str (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) int i = 0, ret = 0, n; sed = hawk_sed_openstdwithmmgr (hawk_rtx_getmmgr(rtx), 0, hawk_rtx_getcmgr(rtx), HAWK_NULL); - if (sed == HAWK_NULL) + if (sed == HAWK_NULL) { ret = -2; goto oops; @@ -161,20 +161,20 @@ static int fnc_str_to_str (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { a[i] = hawk_rtx_getarg(rtx, i); xstr[i].ptr = hawk_rtx_getvaloocstr(rtx, a[i], &xstr[i].len); - if (xstr[i].ptr == HAWK_NULL) + if (xstr[i].ptr == HAWK_NULL) { ret = -2; goto oops; } } - if (hawk_sed_compstdoocs(sed, &xstr[0]) <= -1) + if (hawk_sed_compstdoocs(sed, &xstr[0]) <= -1) { ret = -3; /* compile error */ goto oops; } - if (hawk_sed_execstdxstr (sed, &xstr[1], &outstr, HAWK_NULL) <= -1) + if (hawk_sed_execstdxstr (sed, &xstr[1], &outstr, HAWK_NULL) <= -1) { ret = -4; goto oops; @@ -223,7 +223,7 @@ static hawk_mod_fnc_tab_t fnctab[] = /* ------------------------------------------------------------------------ */ static int query (hawk_mod_t* mod, hawk_t* hawk, const hawk_ooch_t* name, hawk_mod_sym_t* sym) -{ +{ return hawk_findmodsymfnc(hawk, fnctab, HAWK_COUNTOF(fnctab), name, sym); } diff --git a/mod/mod-uci.c b/mod/mod-uci.c index ab17fbf6..014e7fd5 100644 --- a/mod/mod-uci.c +++ b/mod/mod-uci.c @@ -25,11 +25,13 @@ */ #include "mod-uci.h" -#include -#include -#include -#include -#include "../cmn/mem-prv.h" +/* +#include +#include +#include +#include +*/ +#include "../lib/hawk-prv.h" #if defined(HAVE_UCI_H) # include @@ -121,7 +123,7 @@ static uctx_node_t* new_uctx_node (hawk_rtx_t* rtx, uctx_list_t* list) oops: if (node) hawk_rtx_freemem (rtx, node); - hawk_rtx_seterrnum (rtx, HAWK_ENOMEM, HAWK_NULL); + hawk_rtx_seterrnum (rtx, HAWK_NULL, HAWK_ENOMEM); return HAWK_NULL; } @@ -158,7 +160,6 @@ static void free_uctx_node (hawk_rtx_t* rtx, uctx_list_t* list, uctx_node_t* nod * chanined to the free list */ if (list->head == HAWK_NULL) { - hawk_mmgr_t* mmgr; uctx_node_t* curnode; while (list->free) @@ -191,14 +192,13 @@ static int close_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id) return -x; } -static int load_byid ( - hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mchar_t* path) +static int load_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_bch_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, HAWK_NULL); + x = uci_load(list->map.tab[id]->ctx, path, HAWK_NULL); } return -x; @@ -210,14 +210,14 @@ static int unload_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id) if (id >= 0 && id < list->map.high && list->map.tab[id]) { - x = uci_unload (list->map.tab[id]->ctx, HAWK_NULL); + x = uci_unload(list->map.tab[id]->ctx, HAWK_NULL); return 0; } return -x; } -static int save_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mchar_t* item) +static int save_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_bch_t* item) { int x = UCI_ERR_INVAL; @@ -225,8 +225,7 @@ static int save_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mc { struct uci_ptr ptr; - x = uci_lookup_ptr (list->map.tab[id]->ctx, &ptr, item, 1); - + x = uci_lookup_ptr(list->map.tab[id]->ctx, &ptr, item, 1); if (x == UCI_OK) { @@ -240,7 +239,7 @@ static int save_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mc return -x; } -static int commit_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mchar_t* item) +static int commit_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_bch_t* item) { int x = UCI_ERR_INVAL; @@ -248,8 +247,7 @@ static int commit_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_ { struct uci_ptr ptr; - x = uci_lookup_ptr (list->map.tab[id]->ctx, &ptr, item, 1); - + x = uci_lookup_ptr(list->map.tab[id]->ctx, &ptr, item, 1); if (x == UCI_OK) { if (!ptr.value && (ptr.flags & UCI_LOOKUP_COMPLETE) && (ptr.last->type == UCI_TYPE_PACKAGE)) @@ -262,7 +260,7 @@ static int commit_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_ return -x; } -static int revert_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mchar_t* item) +static int revert_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_bch_t* item) { int x = UCI_ERR_INVAL; @@ -270,8 +268,7 @@ static int revert_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_ { struct uci_ptr ptr; - x = uci_lookup_ptr (list->map.tab[id]->ctx, &ptr, item, 1); - + x = uci_lookup_ptr(list->map.tab[id]->ctx, &ptr, item, 1); if (x == UCI_OK) { if (!ptr.value && (ptr.flags & UCI_LOOKUP_COMPLETE)) @@ -284,7 +281,7 @@ static int revert_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_ return -x; } -static int delete_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mchar_t* item) +static int delete_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_bch_t* item) { int x = UCI_ERR_INVAL; @@ -292,8 +289,7 @@ static int delete_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_ { struct uci_ptr ptr; - x = uci_lookup_ptr (list->map.tab[id]->ctx, &ptr, item, 1); - + x = uci_lookup_ptr(list->map.tab[id]->ctx, &ptr, item, 1); if (x == UCI_OK) { if (!ptr.value && (ptr.flags & UCI_LOOKUP_COMPLETE)) @@ -306,7 +302,7 @@ static int delete_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_ return -x; } -static int rename_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mchar_t* item) +static int rename_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_bch_t* item) { int x = UCI_ERR_INVAL; @@ -314,8 +310,7 @@ static int rename_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_ { struct uci_ptr ptr; - x = uci_lookup_ptr (list->map.tab[id]->ctx, &ptr, item, 1); - + x = uci_lookup_ptr(list->map.tab[id]->ctx, &ptr, item, 1); if (x == UCI_OK) { if (ptr.value && (ptr.flags & UCI_LOOKUP_COMPLETE)) @@ -328,7 +323,7 @@ static int rename_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_ return -x; } -static int set_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mchar_t* item) +static int set_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_bch_t* item) { int x = UCI_ERR_INVAL; @@ -336,8 +331,7 @@ static int set_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mch { struct uci_ptr ptr; - x = uci_lookup_ptr (list->map.tab[id]->ctx, &ptr, item, 1); - + x = uci_lookup_ptr(list->map.tab[id]->ctx, &ptr, item, 1); if (x == UCI_OK) { x = ptr.value? uci_set (list->map.tab[id]->ctx, &ptr): UCI_ERR_INVAL; @@ -347,22 +341,24 @@ static int set_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mch return -x; } -static int addsection_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mchar_t* item, hawk_mchar_t* type) +static int addsection_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_bch_t* item, hawk_bch_t* type) { int x = UCI_ERR_INVAL; +/* TODO: this looks like a wrong implementation */ if (id >= 0 && id < list->map.high && list->map.tab[id]) { struct uci_ptr ptr; - x = uci_lookup_ptr (list->map.tab[id]->ctx, &ptr, item, 1); - + x = uci_lookup_ptr(list->map.tab[id]->ctx, &ptr, item, 1); if (x == UCI_OK) { /* add an unnamed section. use set to add a named section */ 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); + { + x = uci_add_section(list->map.tab[id]->ctx, ptr.p, type, &s); + } else x = UCI_ERR_INVAL; } } @@ -370,7 +366,7 @@ static int addsection_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, h return -x; } -static int addlist_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mchar_t* item) +static int addlist_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_bch_t* item) { int x = UCI_ERR_INVAL; @@ -378,8 +374,7 @@ static int addlist_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk { struct uci_ptr ptr; - x = uci_lookup_ptr (list->map.tab[id]->ctx, &ptr, item, 1); - + x = uci_lookup_ptr(list->map.tab[id]->ctx, &ptr, item, 1); if (x == UCI_OK) { x = ptr.value? uci_add_list (list->map.tab[id]->ctx, &ptr): UCI_ERR_INVAL; @@ -390,7 +385,7 @@ static int addlist_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk } static int setconfdir_byid ( - hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mchar_t* path) + hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_bch_t* path) { int x = UCI_ERR_INVAL; @@ -403,7 +398,7 @@ static int setconfdir_byid ( } static int setsavedir_byid ( - hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mchar_t* path) + hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_bch_t* path) { int x = UCI_ERR_INVAL; @@ -416,7 +411,7 @@ static int setsavedir_byid ( } static int adddeltapath_byid ( - hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mchar_t* path) + hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_bch_t* path) { int x = UCI_ERR_INVAL; @@ -428,9 +423,7 @@ static int adddeltapath_byid ( return -x; } -static int getsection_byid ( - hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, - hawk_mchar_t* tuple, hawk_val_ref_t* ref) +static int getsection_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_bch_t* tuple, hawk_val_ref_t* ref) { int x = UCI_ERR_INVAL; @@ -438,7 +431,7 @@ static int getsection_byid ( { struct uci_ptr ptr; - x = uci_lookup_ptr (list->map.tab[id]->ctx, &ptr, tuple, 1); + x = uci_lookup_ptr(list->map.tab[id]->ctx, &ptr, tuple, 1); if (x == UCI_OK) { /* ptr.value is not null if the tuple specified contains @@ -450,7 +443,7 @@ static int getsection_byid ( e = ptr.last; if (e->type == UCI_TYPE_SECTION) { - hawk_val_map_data_t md[4]; + hawk_val_map_data_t md[3]; hawk_int_t lv; hawk_val_t* tmp; @@ -458,12 +451,12 @@ static int getsection_byid ( md[0].key.ptr = HAWK_T("type"); md[0].key.len = 4; - md[0].type = HAWK_VAL_MAP_DATA_MBS; + md[0].type = HAWK_VAL_MAP_DATA_BCSTR; md[0].vptr = ptr.s->type; md[1].key.ptr = HAWK_T("name"); md[1].key.len = 4; - md[1].type = HAWK_VAL_MAP_DATA_MBS; + md[1].type = HAWK_VAL_MAP_DATA_BCSTR; md[1].vptr = ptr.s->e.name; /* e->name == ptr.s->e.name */ md[2].key.ptr = HAWK_T("anon"); @@ -472,7 +465,7 @@ static int getsection_byid ( lv = ptr.s->anonymous; md[2].vptr = &lv; - tmp = hawk_rtx_makemapvalwithdata (rtx, md); + tmp = hawk_rtx_makemapvalwithdata(rtx, md, 3); if (tmp) { int n; @@ -493,9 +486,7 @@ static int getsection_byid ( return -x; } -static int getoption_byid ( - hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, - hawk_mchar_t* tuple, hawk_val_ref_t* ref) +static int getoption_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_bch_t* tuple, hawk_val_ref_t* ref) { int x = UCI_ERR_INVAL; @@ -503,7 +494,7 @@ static int getoption_byid ( { struct uci_ptr ptr; - x = uci_lookup_ptr (list->map.tab[id]->ctx, &ptr, tuple, 1); + x = uci_lookup_ptr(list->map.tab[id]->ctx, &ptr, tuple, 1); if (x == UCI_OK) { /* ptr.value is not null if the tuple specified contains @@ -520,21 +511,21 @@ static int getoption_byid ( if (uo->type == UCI_TYPE_STRING) { hawk_val_t* map; - hawk_val_map_data_t md[3]; + hawk_val_map_data_t md[2]; HAWK_MEMSET (md, 0, HAWK_SIZEOF(md)); md[0].key.ptr = HAWK_T("type"); md[0].key.len = 4; - md[0].type = HAWK_VAL_MAP_DATA_STR; + md[0].type = HAWK_VAL_MAP_DATA_OOCSTR; md[0].vptr = HAWK_T("string"); md[1].key.ptr = HAWK_T("value"); md[1].key.len = 5; - md[1].type = HAWK_VAL_MAP_DATA_MBS; + md[1].type = HAWK_VAL_MAP_DATA_BCSTR; md[1].vptr = uo->v.string; - map = hawk_rtx_makemapvalwithdata (rtx, md); + map = hawk_rtx_makemapvalwithdata(rtx, md, 2); if (map) { int n; @@ -552,7 +543,7 @@ static int getoption_byid ( else if (uo->type == UCI_TYPE_LIST) { hawk_val_t* map, * fld; - hawk_val_map_data_t md[3]; + hawk_val_map_data_t md[2]; struct uci_element* tmp; hawk_int_t count; @@ -563,7 +554,7 @@ static int getoption_byid ( md[0].key.ptr = HAWK_T("type"); md[0].key.len = 4; - md[0].type = HAWK_VAL_MAP_DATA_STR; + md[0].type = HAWK_VAL_MAP_DATA_OOCSTR; md[0].vptr = HAWK_T("list"); md[1].key.ptr = HAWK_T("count"); @@ -571,17 +562,17 @@ static int getoption_byid ( md[1].type = HAWK_VAL_MAP_DATA_INT; md[1].vptr = &count; - map = hawk_rtx_makemapvalwithdata(rtx, md); + map = hawk_rtx_makemapvalwithdata(rtx, md, 2); if (map) { count = 1; uci_foreach_element(&uo->v.list, tmp) { - const hawk_cstr_t* subsep; - hawk_cstr_t k[4]; - hawk_char_t idxbuf[64]; - hawk_char_t* kp; - hawk_size_t kl; + const hawk_oocs_t* subsep; + hawk_oocs_t k[4]; + hawk_ooch_t idxbuf[64]; + hawk_ooch_t* kp; + hawk_oow_t kl; fld = hawk_rtx_makestrvalwithbcstr(rtx, tmp->name); if (!fld) @@ -600,12 +591,12 @@ static int getoption_byid ( k[1].ptr = subsep->ptr; k[1].len = subsep->len; k[2].ptr = idxbuf; - k[2].len = hawk_fmtuintmax(idxbuf, HAWK_COUNTOF(idxbuf), count, 10, -1, HAWK_T('\0'), HAWK_NULL); + k[2].len = hawk_fmt_uintmax_to_oocstr(idxbuf, HAWK_COUNTOF(idxbuf), count, 10, -1, HAWK_T('\0'), HAWK_NULL); k[3].ptr = HAWK_NULL; k[3].len = 0; - kp = hawk_wcstradup(k, &kl, hawk_rtx_getmmgr(rtx)); - if (kp == HAWK_NULL || hawk_rtx_setmapvalfld(rtx, map, kp, kl, fld) == HAWK_NULL) + kp = hawk_rtx_dupoocsarr(rtx, k, &kl); + if (!kp || hawk_rtx_setmapvalfld(rtx, map, kp, kl, fld) == HAWK_NULL) { if (kp) hawk_rtx_freemem (rtx, kp); hawk_rtx_refupval (rtx, fld); @@ -661,14 +652,14 @@ static int fnc_uci_errno (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) list = rtx_to_list (rtx, fi); - retv = hawk_rtx_makeintval (rtx, list->errnum); - if (retv == HAWK_NULL) return -1; + retv = hawk_rtx_makeintval(rtx, list->errnum); + if (!retv) return -1; hawk_rtx_setretval (rtx, retv); return 0; } -static hawk_char_t* errmsg[] = +static hawk_ooch_t* errmsg[] = { HAWK_T("no error"), HAWK_T("out of memory"), @@ -688,16 +679,16 @@ static int fnc_uci_errstr (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) list = rtx_to_list (rtx, fi); - if (hawk_rtx_getnargs (rtx) <= 0 || - hawk_rtx_valtoint (rtx, hawk_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 >= HAWK_COUNTOF(errmsg)) errnum = HAWK_COUNTOF(errmsg) - 1; - retv = hawk_rtx_makestrvalwithstr (rtx, errmsg[errnum]); - if (retv == HAWK_NULL) return -1; + retv = hawk_rtx_makestrvalwithoocstr(rtx, errmsg[errnum]); + if (!retv) return -1; hawk_rtx_setretval (rtx, retv); return 0; @@ -720,8 +711,8 @@ static int fnc_uci_open (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) ret = -1; } - retv = hawk_rtx_makeintval (rtx, ret); - if (retv == HAWK_NULL) return -1; + retv = hawk_rtx_makeintval(rtx, ret); + if (!retv) return -1; hawk_rtx_setretval (rtx, retv); return 0; @@ -736,9 +727,9 @@ static int fnc_uci_close (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) list = rtx_to_list (rtx, fi); - ret = hawk_rtx_valtoint (rtx, hawk_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); + else ret = close_byid(rtx, list, id); if (ret <= -1) { @@ -746,8 +737,8 @@ static int fnc_uci_close (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) ret = -1; } - retv = hawk_rtx_makeintval (rtx, ret); - if (retv == HAWK_NULL) return -1; + retv = hawk_rtx_makeintval(rtx, ret); + if (!retv) return -1; hawk_rtx_setretval (rtx, retv); return 0; @@ -766,12 +757,12 @@ static int fnc_uci_load (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) if (ret <= -1) ret = -UCI_ERR_INVAL; else { - hawk_mchar_t* item; + hawk_bch_t* item; - item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); + item = hawk_rtx_valtobcstrdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); if (item) { - ret = load_byid (rtx, list, id, item); + ret = load_byid(rtx, list, id, item); hawk_rtx_freemem (rtx, item); } else ret = -UCI_ERR_MEM; @@ -783,14 +774,14 @@ static int fnc_uci_load (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) ret = -1; } - retv = hawk_rtx_makeintval (rtx, ret); - if (retv == HAWK_NULL) return -1; + retv = hawk_rtx_makeintval(rtx, ret); + if (!retv) return -1; hawk_rtx_setretval (rtx, retv); return 0; } -static int fnc_uci_unload (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) +static int fnc_uci_unload (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { uctx_list_t* list; hawk_val_t* retv; @@ -801,7 +792,7 @@ static int fnc_uci_unload (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) 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); + else ret = unload_byid(rtx, list, id); if (ret <= -1) { @@ -809,8 +800,8 @@ static int fnc_uci_unload (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) ret = -1; } - retv = hawk_rtx_makeintval (rtx, ret); - if (retv == HAWK_NULL) return -1; + retv = hawk_rtx_makeintval(rtx, ret); + if (!retv) return -1; hawk_rtx_setretval (rtx, retv); return 0; @@ -829,12 +820,12 @@ static int fnc_uci_save (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) if (ret <= -1) ret = -UCI_ERR_INVAL; else { - hawk_mchar_t* item; + hawk_bch_t* item; - item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); + item = hawk_rtx_valtobcstrdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); if (item) { - ret = save_byid (rtx, list, id, item); + ret = save_byid(rtx, list, id, item); hawk_rtx_freemem (rtx, item); } else ret = -UCI_ERR_MEM; @@ -846,8 +837,8 @@ static int fnc_uci_save (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) ret = -1; } - retv = hawk_rtx_makeintval (rtx, ret); - if (retv == HAWK_NULL) return -1; + retv = hawk_rtx_makeintval(rtx, ret); + if (!retv) return -1; hawk_rtx_setretval (rtx, retv); return 0; @@ -866,12 +857,12 @@ static int fnc_uci_commit (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) if (ret <= -1) ret = -UCI_ERR_INVAL; else { - hawk_mchar_t* item; + hawk_bch_t* item; - item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); + item = hawk_rtx_valtobcstrdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); if (item) { - ret = commit_byid (rtx, list, id, item); + ret = commit_byid(rtx, list, id, item); hawk_rtx_freemem (rtx, item); } else ret = -UCI_ERR_MEM; @@ -883,8 +874,8 @@ static int fnc_uci_commit (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) ret = -1; } - retv = hawk_rtx_makeintval (rtx, ret); - if (retv == HAWK_NULL) return -1; + retv = hawk_rtx_makeintval(rtx, ret); + if (!retv) return -1; hawk_rtx_setretval (rtx, retv); return 0; @@ -903,12 +894,12 @@ static int fnc_uci_revert (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) if (ret <= -1) ret = -UCI_ERR_INVAL; else { - hawk_mchar_t* item; + hawk_bch_t* item; - item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); + item = hawk_rtx_valtobcstrdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); if (item) { - ret = revert_byid (rtx, list, id, item); + ret = revert_byid(rtx, list, id, item); hawk_rtx_freemem (rtx, item); } else ret = -UCI_ERR_MEM; @@ -920,8 +911,8 @@ static int fnc_uci_revert (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) ret = -1; } - retv = hawk_rtx_makeintval (rtx, ret); - if (retv == HAWK_NULL) return -1; + retv = hawk_rtx_makeintval(rtx, ret); + if (!retv) return -1; hawk_rtx_setretval (rtx, retv); return 0; @@ -940,12 +931,12 @@ static int fnc_uci_delete (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) if (ret <= -1) ret = -UCI_ERR_INVAL; else { - hawk_mchar_t* item; + hawk_bch_t* item; - item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); + item = hawk_rtx_valtobcstrdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); if (item) { - ret = delete_byid (rtx, list, id, item); + ret = delete_byid(rtx, list, id, item); hawk_rtx_freemem (rtx, item); } else ret = -UCI_ERR_MEM; @@ -957,8 +948,8 @@ static int fnc_uci_delete (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) ret = -1; } - retv = hawk_rtx_makeintval (rtx, ret); - if (retv == HAWK_NULL) return -1; + retv = hawk_rtx_makeintval(rtx, ret); + if (!retv) return -1; hawk_rtx_setretval (rtx, retv); return 0; @@ -977,12 +968,12 @@ static int fnc_uci_rename (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) if (ret <= -1) ret = -UCI_ERR_INVAL; else { - hawk_mchar_t* item; + hawk_bch_t* item; - item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); + item = hawk_rtx_valtobcstrdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); if (item) { - ret = rename_byid (rtx, list, id, item); + ret = rename_byid(rtx, list, id, item); hawk_rtx_freemem (rtx, item); } else ret = -UCI_ERR_MEM; @@ -994,8 +985,8 @@ static int fnc_uci_rename (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) ret = -1; } - retv = hawk_rtx_makeintval (rtx, ret); - if (retv == HAWK_NULL) return -1; + retv = hawk_rtx_makeintval(rtx, ret); + if (!retv) return -1; hawk_rtx_setretval (rtx, retv); return 0; @@ -1014,12 +1005,12 @@ static int fnc_uci_set (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) if (ret <= -1) ret = -UCI_ERR_INVAL; else { - hawk_mchar_t* item; + hawk_bch_t* item; - item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); + item = hawk_rtx_valtobcstrdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); if (item) { - ret = set_byid (rtx, list, id, item); + ret = set_byid(rtx, list, id, item); hawk_rtx_freemem (rtx, item); } else ret = -UCI_ERR_MEM; @@ -1031,8 +1022,8 @@ static int fnc_uci_set (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) ret = -1; } - retv = hawk_rtx_makeintval (rtx, ret); - if (retv == HAWK_NULL) return -1; + retv = hawk_rtx_makeintval(rtx, ret); + if (!retv) return -1; hawk_rtx_setretval (rtx, retv); return 0; @@ -1051,13 +1042,13 @@ static int fnc_uci_addsection (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) if (ret <= -1) ret = -UCI_ERR_INVAL; else { - hawk_mchar_t* item, * type; + hawk_bch_t* item, * type; - item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); - type = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 2), HAWK_NULL); + item = hawk_rtx_valtobcstrdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); + type = hawk_rtx_valtobcstrdup(rtx, hawk_rtx_getarg(rtx, 2), HAWK_NULL); if (item && type) { - ret = addsection_byid (rtx, list, id, item, type); + ret = addsection_byid(rtx, list, id, item, type); } else ret = -UCI_ERR_MEM; @@ -1071,8 +1062,8 @@ static int fnc_uci_addsection (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) ret = -1; } - retv = hawk_rtx_makeintval (rtx, ret); - if (retv == HAWK_NULL) return -1; + retv = hawk_rtx_makeintval(rtx, ret); + if (!retv) return -1; hawk_rtx_setretval (rtx, retv); return 0; @@ -1091,12 +1082,12 @@ static int fnc_uci_addlist (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) if (ret <= -1) ret = -UCI_ERR_INVAL; else { - hawk_mchar_t* item; + hawk_bch_t* item; - item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); + item = hawk_rtx_valtobcstrdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); if (item) { - ret = addlist_byid (rtx, list, id, item); + ret = addlist_byid(rtx, list, id, item); hawk_rtx_freemem (rtx, item); } else ret = -UCI_ERR_MEM; @@ -1108,8 +1099,8 @@ static int fnc_uci_addlist (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) ret = -1; } - retv = hawk_rtx_makeintval (rtx, ret); - if (retv == HAWK_NULL) return -1; + retv = hawk_rtx_makeintval(rtx, ret); + if (!retv) return -1; hawk_rtx_setretval (rtx, retv); return 0; @@ -1128,12 +1119,12 @@ static int fnc_uci_setconfdir (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) if (ret <= -1) ret = -UCI_ERR_INVAL; else { - hawk_mchar_t* item; + hawk_bch_t* item; - item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); + item = hawk_rtx_valtobcstrdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); if (item) { - ret = setconfdir_byid (rtx, list, id, item); + ret = setconfdir_byid(rtx, list, id, item); hawk_rtx_freemem (rtx, item); } else ret = -UCI_ERR_MEM; @@ -1145,8 +1136,8 @@ static int fnc_uci_setconfdir (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) ret = -1; } - retv = hawk_rtx_makeintval (rtx, ret); - if (retv == HAWK_NULL) return -1; + retv = hawk_rtx_makeintval(rtx, ret); + if (!retv) return -1; hawk_rtx_setretval (rtx, retv); return 0; @@ -1166,12 +1157,12 @@ static int fnc_uci_setsavedir (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) if (ret <= -1) ret = -UCI_ERR_INVAL; else { - hawk_mchar_t* item; + hawk_bch_t* item; - item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); + item = hawk_rtx_valtobcstrdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); if (item) { - ret = setsavedir_byid (rtx, list, id, item); + ret = setsavedir_byid(rtx, list, id, item); hawk_rtx_freemem (rtx, item); } else ret = -UCI_ERR_MEM; @@ -1183,8 +1174,8 @@ static int fnc_uci_setsavedir (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) ret = -1; } - retv = hawk_rtx_makeintval (rtx, ret); - if (retv == HAWK_NULL) return -1; + retv = hawk_rtx_makeintval(rtx, ret); + if (!retv) return -1; hawk_rtx_setretval (rtx, retv); return 0; @@ -1203,12 +1194,12 @@ static int fnc_uci_adddeltapath (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) if (ret <= -1) ret = -UCI_ERR_INVAL; else { - hawk_mchar_t* item; + hawk_bch_t* item; - item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); + item = hawk_rtx_valtobcstrdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); if (item) { - ret = adddeltapath_byid (rtx, list, id, item); + ret = adddeltapath_byid(rtx, list, id, item); hawk_rtx_freemem (rtx, item); } else ret = -UCI_ERR_MEM; @@ -1220,8 +1211,8 @@ static int fnc_uci_adddeltapath (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) ret = -1; } - retv = hawk_rtx_makeintval (rtx, ret); - if (retv == HAWK_NULL) return -1; + retv = hawk_rtx_makeintval(rtx, ret); + if (!retv) return -1; hawk_rtx_setretval (rtx, retv); return 0; @@ -1239,12 +1230,12 @@ static int fnc_uci_getoption (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) if (ret <= -1) ret = -UCI_ERR_INVAL; else { - hawk_mchar_t* item; + hawk_bch_t* item; - item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); + item = hawk_rtx_valtobcstrdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); if (item) { - ret = getoption_byid (rtx, list, id, item, hawk_rtx_getarg (rtx, 2)); + ret = getoption_byid(rtx, list, id, item, (hawk_val_ref_t*)hawk_rtx_getarg(rtx, 2)); hawk_rtx_freemem (rtx, item); if (ret == -9999) return -1; } @@ -1258,7 +1249,7 @@ static int fnc_uci_getoption (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) } else ret = 0; - hawk_rtx_setretval (rtx, hawk_rtx_makeintval (rtx, ret)); + hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, ret)); return 0; } @@ -1270,16 +1261,16 @@ static int fnc_uci_getsection (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) list = rtx_to_list (rtx, fi); - ret = hawk_rtx_valtoint(rtx, hawk_rtx_getarg (rtx, 0), &id); + ret = hawk_rtx_valtoint(rtx, hawk_rtx_getarg(rtx, 0), &id); if (ret <= -1) ret = -UCI_ERR_INVAL; else { - hawk_mchar_t* item; + hawk_bch_t* item; - item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg (rtx, 1), HAWK_NULL); + item = hawk_rtx_valtobcstrdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL); if (item) { - ret = getsection_byid(rtx, list, id, item, hawk_rtx_getarg (rtx, 2)); + ret = getsection_byid(rtx, list, id, item, (hawk_val_ref_t*)hawk_rtx_getarg(rtx, 2)); hawk_rtx_freemem (rtx, item); if (ret == -9999) return -1; } @@ -1293,7 +1284,7 @@ static int fnc_uci_getsection (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) } else ret = 0; - hawk_rtx_setretval (rtx, hawk_rtx_makeintval (rtx, ret)); + hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, ret)); return 0; } @@ -1324,7 +1315,7 @@ static hawk_mod_fnc_tab_t fnctab[] = /* ------------------------------------------------------------------------ */ -static int query (hawk_mod_t* mod, hawk_t* awk, const hawk_char_t* name, hawk_mod_sym_t* sym) +static int query (hawk_mod_t* mod, hawk_t* hawk, const hawk_ooch_t* name, hawk_mod_sym_t* sym) { return hawk_findmodsymfnc(hawk, fnctab, HAWK_COUNTOF(fnctab), name, sym); } @@ -1339,7 +1330,7 @@ static int init (hawk_mod_t* mod, hawk_rtx_t* rtx) HAWK_MEMSET (&list, 0, HAWK_SIZEOF(list)); if (hawk_rbt_insert(rbt, &rtx, HAWK_SIZEOF(rtx), &list, HAWK_SIZEOF(list)) == HAWK_NULL) { - hawk_rtx_seterrnum (rtx, HAWK_ENOMEM, HAWK_NULL); + hawk_rtx_seterrnum (rtx, HAWK_NULL, HAWK_ENOMEM); return -1; } @@ -1393,10 +1384,10 @@ int hawk_mod_uci (hawk_mod_t* mod, hawk_t* hawk) mod->init = init; mod->fini = fini; - rbt = hawk_rbt_open (hawk_getgem(hawk), 0, 1, 1); - if (rbt == HAWK_NULL) return -1; + rbt = hawk_rbt_open(hawk_getgem(hawk), 0, 1, 1); + if (!rbt) return -1; - hawk_rbt_setstyle (rbt, hawk_getrbtstyle(HAWK_RBT_STYLE_INLINE_COPIERS)); + hawk_rbt_setstyle (rbt, hawk_get_rbt_style(HAWK_RBT_STYLE_INLINE_COPIERS)); mod->ctx = rbt; return 0;