added hawk_gem_dupucsarr() and hawk_gem_dupbcsarr()
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
modifed mod-uci.h to be compilable at least - it's full of problems
This commit is contained in:
parent
5b4eac36af
commit
9fa26924c7
6
configure
vendored
6
configure
vendored
@ -20279,6 +20279,12 @@ then :
|
|||||||
printf "%s\n" "#define HAVE_CRT_EXTERNS_H 1" >>confdefs.h
|
printf "%s\n" "#define HAVE_CRT_EXTERNS_H 1" >>confdefs.h
|
||||||
|
|
||||||
fi
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ AC_CHECK_HEADERS([netinet/in.h sys/un.h netpacket/packet.h net/if.h net/if_dl.h
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>])
|
#include <sys/socket.h>])
|
||||||
AC_CHECK_HEADERS([sys/stropts.h sys/macstat.h linux/ethtool.h linux/sockios.h])
|
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 check data types
|
||||||
dnl AC_CHECK_TYPE([wchar_t],
|
dnl AC_CHECK_TYPE([wchar_t],
|
||||||
|
37
lib/gem.c
37
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;
|
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)
|
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)
|
||||||
|
@ -618,6 +618,9 @@
|
|||||||
/* Define to 1 if you have the <time.h> header file. */
|
/* Define to 1 if you have the <time.h> header file. */
|
||||||
#undef HAVE_TIME_H
|
#undef HAVE_TIME_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <uci.h> header file. */
|
||||||
|
#undef HAVE_UCI_H
|
||||||
|
|
||||||
/* Define to 1 if you have the <ucontext.h> header file. */
|
/* Define to 1 if you have the <ucontext.h> header file. */
|
||||||
#undef HAVE_UCONTEXT_H
|
#undef HAVE_UCONTEXT_H
|
||||||
|
|
||||||
|
@ -168,16 +168,30 @@ HAWK_EXPORT hawk_bch_t* hawk_gem_dupbcstrarr (
|
|||||||
hawk_oow_t* len
|
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)
|
#if defined(HAWK_OOCH_IS_UCH)
|
||||||
# define hawk_gem_dupoocstr hawk_gem_dupucstr
|
# define hawk_gem_dupoocstr hawk_gem_dupucstr
|
||||||
# define hawk_gem_dupoochars hawk_gem_dupuchars
|
# define hawk_gem_dupoochars hawk_gem_dupuchars
|
||||||
# define hawk_gem_dupoocs hawk_gem_dupucs
|
# define hawk_gem_dupoocs hawk_gem_dupucs
|
||||||
# define hawk_gem_dupoocstrarr hawk_gem_dupucstrarr
|
# define hawk_gem_dupoocstrarr hawk_gem_dupucstrarr
|
||||||
|
# define hawk_gem_dupoocsarr hawk_gem_dupucsarr
|
||||||
#else
|
#else
|
||||||
# define hawk_gem_dupoocstr hawk_gem_dupbcstr
|
# define hawk_gem_dupoocstr hawk_gem_dupbcstr
|
||||||
# define hawk_gem_dupoochars hawk_gem_dupbchars
|
# define hawk_gem_dupoochars hawk_gem_dupbchars
|
||||||
# define hawk_gem_dupoocs hawk_gem_dupbcs
|
# define hawk_gem_dupoocs hawk_gem_dupbcs
|
||||||
# define hawk_gem_dupoocstrarr hawk_gem_dupbcstrarr
|
# define hawk_gem_dupoocstrarr hawk_gem_dupbcstrarr
|
||||||
|
# define hawk_gem_dupoocsarr hawk_gem_dupbcsarr
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
@ -3207,7 +3207,7 @@ HAWK_EXPORT void hawk_rtx_refdownval_nofree (
|
|||||||
#define HAWK_RTX_GC_GEN_AUTO (-1)
|
#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
|
* It returns the generation number collected and never fails
|
||||||
*/
|
*/
|
||||||
HAWK_EXPORT int hawk_rtx_gc (
|
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_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_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_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
|
#else
|
||||||
#define hawk_rtx_dupucstr(rtx, ucs, ucslen) hawk_gem_dupucstr(hawk_rtx_getgem(rtx), ucs, ucslen)
|
#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)
|
#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_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_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_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
|
#endif
|
||||||
|
|
||||||
#if defined(HAWK_OOCH_IS_UCH)
|
#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_dupoochars hawk_rtx_dupuchars
|
||||||
# define hawk_rtx_dupoocs hawk_rtx_dupucs
|
# define hawk_rtx_dupoocs hawk_rtx_dupucs
|
||||||
# define hawk_rtx_dupoocstrarr hawk_rtx_dupucstrarr
|
# define hawk_rtx_dupoocstrarr hawk_rtx_dupucstrarr
|
||||||
|
# define hawk_rtx_dupoocsarr hawk_rtx_dupucsarr
|
||||||
#else
|
#else
|
||||||
# define hawk_rtx_dupoocstr hawk_rtx_dupbcstr
|
# define hawk_rtx_dupoocstr hawk_rtx_dupbcstr
|
||||||
# define hawk_rtx_dupoochars hawk_rtx_dupbchars
|
# define hawk_rtx_dupoochars hawk_rtx_dupbchars
|
||||||
# define hawk_rtx_dupoocs hawk_rtx_dupbcs
|
# define hawk_rtx_dupoocs hawk_rtx_dupbcs
|
||||||
# define hawk_rtx_dupoocstrarr hawk_rtx_dupbcstrarr
|
# define hawk_rtx_dupoocstrarr hawk_rtx_dupbcstrarr
|
||||||
|
# define hawk_rtx_dupoocsarr hawk_rtx_dupbcsarr
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
307
mod/mod-uci.c
307
mod/mod-uci.c
@ -25,11 +25,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mod-uci.h"
|
#include "mod-uci.h"
|
||||||
#include <hawk/cmn/str.h>
|
/*
|
||||||
#include <hawk/cmn/rbt.h>
|
#include <hawk-str.h>
|
||||||
#include <hawk/cmn/mbwc.h>
|
#include <hawk-rbt.h>
|
||||||
#include <hawk/cmn/fmt.h>
|
#include <hawk-chr.h>
|
||||||
#include "../cmn/mem-prv.h"
|
#include <hawk-fmt.h>
|
||||||
|
*/
|
||||||
|
#include "../lib/hawk-prv.h"
|
||||||
|
|
||||||
#if defined(HAVE_UCI_H)
|
#if defined(HAVE_UCI_H)
|
||||||
# include <uci.h>
|
# include <uci.h>
|
||||||
@ -121,7 +123,7 @@ static uctx_node_t* new_uctx_node (hawk_rtx_t* rtx, uctx_list_t* list)
|
|||||||
|
|
||||||
oops:
|
oops:
|
||||||
if (node) hawk_rtx_freemem (rtx, node);
|
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;
|
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 */
|
* chanined to the free list */
|
||||||
if (list->head == HAWK_NULL)
|
if (list->head == HAWK_NULL)
|
||||||
{
|
{
|
||||||
hawk_mmgr_t* mmgr;
|
|
||||||
uctx_node_t* curnode;
|
uctx_node_t* curnode;
|
||||||
|
|
||||||
while (list->free)
|
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;
|
return -x;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int load_byid (
|
static int load_byid (hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_bch_t* path)
|
||||||
hawk_rtx_t* rtx, uctx_list_t* list, hawk_int_t id, hawk_mchar_t* path)
|
|
||||||
{
|
{
|
||||||
int x = UCI_ERR_INVAL;
|
int x = UCI_ERR_INVAL;
|
||||||
|
|
||||||
if (id >= 0 && id < list->map.high && list->map.tab[id])
|
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;
|
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])
|
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 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -x;
|
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;
|
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;
|
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 (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;
|
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;
|
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;
|
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 (x == UCI_OK)
|
||||||
{
|
{
|
||||||
if (!ptr.value && (ptr.flags & UCI_LOOKUP_COMPLETE) && (ptr.last->type == UCI_TYPE_PACKAGE))
|
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;
|
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;
|
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;
|
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 (x == UCI_OK)
|
||||||
{
|
{
|
||||||
if (!ptr.value && (ptr.flags & UCI_LOOKUP_COMPLETE))
|
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;
|
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;
|
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;
|
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 (x == UCI_OK)
|
||||||
{
|
{
|
||||||
if (!ptr.value && (ptr.flags & UCI_LOOKUP_COMPLETE))
|
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;
|
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;
|
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;
|
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 (x == UCI_OK)
|
||||||
{
|
{
|
||||||
if (ptr.value && (ptr.flags & UCI_LOOKUP_COMPLETE))
|
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;
|
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;
|
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;
|
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 (x == UCI_OK)
|
||||||
{
|
{
|
||||||
x = ptr.value? uci_set (list->map.tab[id]->ctx, &ptr): UCI_ERR_INVAL;
|
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;
|
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;
|
int x = UCI_ERR_INVAL;
|
||||||
|
|
||||||
|
/* TODO: this looks like a wrong implementation */
|
||||||
if (id >= 0 && id < list->map.high && list->map.tab[id])
|
if (id >= 0 && id < list->map.high && list->map.tab[id])
|
||||||
{
|
{
|
||||||
struct uci_ptr ptr;
|
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 (x == UCI_OK)
|
||||||
{
|
{
|
||||||
/* add an unnamed section. use set to add a named section */
|
/* add an unnamed section. use set to add a named section */
|
||||||
struct uci_section* s = HAWK_NULL;
|
struct uci_section* s = HAWK_NULL;
|
||||||
if (!ptr.value && (ptr.flags & UCI_LOOKUP_COMPLETE) && (ptr.last->type == UCI_TYPE_PACKAGE))
|
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;
|
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;
|
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;
|
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;
|
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 (x == UCI_OK)
|
||||||
{
|
{
|
||||||
x = ptr.value? uci_add_list (list->map.tab[id]->ctx, &ptr): UCI_ERR_INVAL;
|
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 (
|
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;
|
int x = UCI_ERR_INVAL;
|
||||||
|
|
||||||
@ -403,7 +398,7 @@ static int setconfdir_byid (
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int setsavedir_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;
|
int x = UCI_ERR_INVAL;
|
||||||
|
|
||||||
@ -416,7 +411,7 @@ static int setsavedir_byid (
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int adddeltapath_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;
|
int x = UCI_ERR_INVAL;
|
||||||
|
|
||||||
@ -428,9 +423,7 @@ static int adddeltapath_byid (
|
|||||||
return -x;
|
return -x;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getsection_byid (
|
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)
|
||||||
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;
|
int x = UCI_ERR_INVAL;
|
||||||
|
|
||||||
@ -438,7 +431,7 @@ static int getsection_byid (
|
|||||||
{
|
{
|
||||||
struct uci_ptr ptr;
|
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)
|
if (x == UCI_OK)
|
||||||
{
|
{
|
||||||
/* ptr.value is not null if the tuple specified contains
|
/* ptr.value is not null if the tuple specified contains
|
||||||
@ -450,7 +443,7 @@ static int getsection_byid (
|
|||||||
e = ptr.last;
|
e = ptr.last;
|
||||||
if (e->type == UCI_TYPE_SECTION)
|
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_int_t lv;
|
||||||
hawk_val_t* tmp;
|
hawk_val_t* tmp;
|
||||||
|
|
||||||
@ -458,12 +451,12 @@ static int getsection_byid (
|
|||||||
|
|
||||||
md[0].key.ptr = HAWK_T("type");
|
md[0].key.ptr = HAWK_T("type");
|
||||||
md[0].key.len = 4;
|
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[0].vptr = ptr.s->type;
|
||||||
|
|
||||||
md[1].key.ptr = HAWK_T("name");
|
md[1].key.ptr = HAWK_T("name");
|
||||||
md[1].key.len = 4;
|
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[1].vptr = ptr.s->e.name; /* e->name == ptr.s->e.name */
|
||||||
|
|
||||||
md[2].key.ptr = HAWK_T("anon");
|
md[2].key.ptr = HAWK_T("anon");
|
||||||
@ -472,7 +465,7 @@ static int getsection_byid (
|
|||||||
lv = ptr.s->anonymous;
|
lv = ptr.s->anonymous;
|
||||||
md[2].vptr = &lv;
|
md[2].vptr = &lv;
|
||||||
|
|
||||||
tmp = hawk_rtx_makemapvalwithdata (rtx, md);
|
tmp = hawk_rtx_makemapvalwithdata(rtx, md, 3);
|
||||||
if (tmp)
|
if (tmp)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
@ -493,9 +486,7 @@ static int getsection_byid (
|
|||||||
return -x;
|
return -x;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getoption_byid (
|
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)
|
||||||
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;
|
int x = UCI_ERR_INVAL;
|
||||||
|
|
||||||
@ -503,7 +494,7 @@ static int getoption_byid (
|
|||||||
{
|
{
|
||||||
struct uci_ptr ptr;
|
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)
|
if (x == UCI_OK)
|
||||||
{
|
{
|
||||||
/* ptr.value is not null if the tuple specified contains
|
/* ptr.value is not null if the tuple specified contains
|
||||||
@ -520,21 +511,21 @@ static int getoption_byid (
|
|||||||
if (uo->type == UCI_TYPE_STRING)
|
if (uo->type == UCI_TYPE_STRING)
|
||||||
{
|
{
|
||||||
hawk_val_t* map;
|
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));
|
HAWK_MEMSET (md, 0, HAWK_SIZEOF(md));
|
||||||
|
|
||||||
md[0].key.ptr = HAWK_T("type");
|
md[0].key.ptr = HAWK_T("type");
|
||||||
md[0].key.len = 4;
|
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[0].vptr = HAWK_T("string");
|
||||||
|
|
||||||
md[1].key.ptr = HAWK_T("value");
|
md[1].key.ptr = HAWK_T("value");
|
||||||
md[1].key.len = 5;
|
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;
|
md[1].vptr = uo->v.string;
|
||||||
|
|
||||||
map = hawk_rtx_makemapvalwithdata (rtx, md);
|
map = hawk_rtx_makemapvalwithdata(rtx, md, 2);
|
||||||
if (map)
|
if (map)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
@ -552,7 +543,7 @@ static int getoption_byid (
|
|||||||
else if (uo->type == UCI_TYPE_LIST)
|
else if (uo->type == UCI_TYPE_LIST)
|
||||||
{
|
{
|
||||||
hawk_val_t* map, * fld;
|
hawk_val_t* map, * fld;
|
||||||
hawk_val_map_data_t md[3];
|
hawk_val_map_data_t md[2];
|
||||||
struct uci_element* tmp;
|
struct uci_element* tmp;
|
||||||
hawk_int_t count;
|
hawk_int_t count;
|
||||||
|
|
||||||
@ -563,7 +554,7 @@ static int getoption_byid (
|
|||||||
|
|
||||||
md[0].key.ptr = HAWK_T("type");
|
md[0].key.ptr = HAWK_T("type");
|
||||||
md[0].key.len = 4;
|
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[0].vptr = HAWK_T("list");
|
||||||
|
|
||||||
md[1].key.ptr = HAWK_T("count");
|
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].type = HAWK_VAL_MAP_DATA_INT;
|
||||||
md[1].vptr = &count;
|
md[1].vptr = &count;
|
||||||
|
|
||||||
map = hawk_rtx_makemapvalwithdata(rtx, md);
|
map = hawk_rtx_makemapvalwithdata(rtx, md, 2);
|
||||||
if (map)
|
if (map)
|
||||||
{
|
{
|
||||||
count = 1;
|
count = 1;
|
||||||
uci_foreach_element(&uo->v.list, tmp)
|
uci_foreach_element(&uo->v.list, tmp)
|
||||||
{
|
{
|
||||||
const hawk_cstr_t* subsep;
|
const hawk_oocs_t* subsep;
|
||||||
hawk_cstr_t k[4];
|
hawk_oocs_t k[4];
|
||||||
hawk_char_t idxbuf[64];
|
hawk_ooch_t idxbuf[64];
|
||||||
hawk_char_t* kp;
|
hawk_ooch_t* kp;
|
||||||
hawk_size_t kl;
|
hawk_oow_t kl;
|
||||||
|
|
||||||
fld = hawk_rtx_makestrvalwithbcstr(rtx, tmp->name);
|
fld = hawk_rtx_makestrvalwithbcstr(rtx, tmp->name);
|
||||||
if (!fld)
|
if (!fld)
|
||||||
@ -600,12 +591,12 @@ static int getoption_byid (
|
|||||||
k[1].ptr = subsep->ptr;
|
k[1].ptr = subsep->ptr;
|
||||||
k[1].len = subsep->len;
|
k[1].len = subsep->len;
|
||||||
k[2].ptr = idxbuf;
|
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].ptr = HAWK_NULL;
|
||||||
k[3].len = 0;
|
k[3].len = 0;
|
||||||
|
|
||||||
kp = hawk_wcstradup(k, &kl, hawk_rtx_getmmgr(rtx));
|
kp = hawk_rtx_dupoocsarr(rtx, k, &kl);
|
||||||
if (kp == HAWK_NULL || hawk_rtx_setmapvalfld(rtx, map, kp, kl, fld) == HAWK_NULL)
|
if (!kp || hawk_rtx_setmapvalfld(rtx, map, kp, kl, fld) == HAWK_NULL)
|
||||||
{
|
{
|
||||||
if (kp) hawk_rtx_freemem (rtx, kp);
|
if (kp) hawk_rtx_freemem (rtx, kp);
|
||||||
hawk_rtx_refupval (rtx, fld);
|
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);
|
list = rtx_to_list (rtx, fi);
|
||||||
|
|
||||||
retv = hawk_rtx_makeintval (rtx, list->errnum);
|
retv = hawk_rtx_makeintval(rtx, list->errnum);
|
||||||
if (retv == HAWK_NULL) return -1;
|
if (!retv) return -1;
|
||||||
|
|
||||||
hawk_rtx_setretval (rtx, retv);
|
hawk_rtx_setretval (rtx, retv);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static hawk_char_t* errmsg[] =
|
static hawk_ooch_t* errmsg[] =
|
||||||
{
|
{
|
||||||
HAWK_T("no error"),
|
HAWK_T("no error"),
|
||||||
HAWK_T("out of memory"),
|
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);
|
list = rtx_to_list (rtx, fi);
|
||||||
|
|
||||||
if (hawk_rtx_getnargs (rtx) <= 0 ||
|
if (hawk_rtx_getnargs(rtx) <= 0 ||
|
||||||
hawk_rtx_valtoint (rtx, hawk_rtx_getarg (rtx, 0), &errnum) <= -1)
|
hawk_rtx_valtoint(rtx, hawk_rtx_getarg (rtx, 0), &errnum) <= -1)
|
||||||
{
|
{
|
||||||
errnum = list->errnum;
|
errnum = list->errnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errnum < 0 || errnum >= HAWK_COUNTOF(errmsg)) errnum = HAWK_COUNTOF(errmsg) - 1;
|
if (errnum < 0 || errnum >= HAWK_COUNTOF(errmsg)) errnum = HAWK_COUNTOF(errmsg) - 1;
|
||||||
|
|
||||||
retv = hawk_rtx_makestrvalwithstr (rtx, errmsg[errnum]);
|
retv = hawk_rtx_makestrvalwithoocstr(rtx, errmsg[errnum]);
|
||||||
if (retv == HAWK_NULL) return -1;
|
if (!retv) return -1;
|
||||||
|
|
||||||
hawk_rtx_setretval (rtx, retv);
|
hawk_rtx_setretval (rtx, retv);
|
||||||
return 0;
|
return 0;
|
||||||
@ -720,8 +711,8 @@ static int fnc_uci_open (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
|||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
retv = hawk_rtx_makeintval (rtx, ret);
|
retv = hawk_rtx_makeintval(rtx, ret);
|
||||||
if (retv == HAWK_NULL) return -1;
|
if (!retv) return -1;
|
||||||
|
|
||||||
hawk_rtx_setretval (rtx, retv);
|
hawk_rtx_setretval (rtx, retv);
|
||||||
return 0;
|
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);
|
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;
|
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||||
else ret = close_byid (rtx, list, id);
|
else ret = close_byid(rtx, list, id);
|
||||||
|
|
||||||
if (ret <= -1)
|
if (ret <= -1)
|
||||||
{
|
{
|
||||||
@ -746,8 +737,8 @@ static int fnc_uci_close (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
|||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
retv = hawk_rtx_makeintval (rtx, ret);
|
retv = hawk_rtx_makeintval(rtx, ret);
|
||||||
if (retv == HAWK_NULL) return -1;
|
if (!retv) return -1;
|
||||||
|
|
||||||
hawk_rtx_setretval (rtx, retv);
|
hawk_rtx_setretval (rtx, retv);
|
||||||
return 0;
|
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;
|
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||||
else
|
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)
|
if (item)
|
||||||
{
|
{
|
||||||
ret = load_byid (rtx, list, id, item);
|
ret = load_byid(rtx, list, id, item);
|
||||||
hawk_rtx_freemem (rtx, item);
|
hawk_rtx_freemem (rtx, item);
|
||||||
}
|
}
|
||||||
else ret = -UCI_ERR_MEM;
|
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;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
retv = hawk_rtx_makeintval (rtx, ret);
|
retv = hawk_rtx_makeintval(rtx, ret);
|
||||||
if (retv == HAWK_NULL) return -1;
|
if (!retv) return -1;
|
||||||
|
|
||||||
hawk_rtx_setretval (rtx, retv);
|
hawk_rtx_setretval (rtx, retv);
|
||||||
return 0;
|
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;
|
uctx_list_t* list;
|
||||||
hawk_val_t* retv;
|
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);
|
ret = hawk_rtx_valtoint (rtx, hawk_rtx_getarg (rtx, 0), &id);
|
||||||
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||||
else ret = unload_byid (rtx, list, id);
|
else ret = unload_byid(rtx, list, id);
|
||||||
|
|
||||||
if (ret <= -1)
|
if (ret <= -1)
|
||||||
{
|
{
|
||||||
@ -809,8 +800,8 @@ static int fnc_uci_unload (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
|||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
retv = hawk_rtx_makeintval (rtx, ret);
|
retv = hawk_rtx_makeintval(rtx, ret);
|
||||||
if (retv == HAWK_NULL) return -1;
|
if (!retv) return -1;
|
||||||
|
|
||||||
hawk_rtx_setretval (rtx, retv);
|
hawk_rtx_setretval (rtx, retv);
|
||||||
return 0;
|
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;
|
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||||
else
|
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)
|
if (item)
|
||||||
{
|
{
|
||||||
ret = save_byid (rtx, list, id, item);
|
ret = save_byid(rtx, list, id, item);
|
||||||
hawk_rtx_freemem (rtx, item);
|
hawk_rtx_freemem (rtx, item);
|
||||||
}
|
}
|
||||||
else ret = -UCI_ERR_MEM;
|
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;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
retv = hawk_rtx_makeintval (rtx, ret);
|
retv = hawk_rtx_makeintval(rtx, ret);
|
||||||
if (retv == HAWK_NULL) return -1;
|
if (!retv) return -1;
|
||||||
|
|
||||||
hawk_rtx_setretval (rtx, retv);
|
hawk_rtx_setretval (rtx, retv);
|
||||||
return 0;
|
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;
|
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||||
else
|
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)
|
if (item)
|
||||||
{
|
{
|
||||||
ret = commit_byid (rtx, list, id, item);
|
ret = commit_byid(rtx, list, id, item);
|
||||||
hawk_rtx_freemem (rtx, item);
|
hawk_rtx_freemem (rtx, item);
|
||||||
}
|
}
|
||||||
else ret = -UCI_ERR_MEM;
|
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;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
retv = hawk_rtx_makeintval (rtx, ret);
|
retv = hawk_rtx_makeintval(rtx, ret);
|
||||||
if (retv == HAWK_NULL) return -1;
|
if (!retv) return -1;
|
||||||
|
|
||||||
hawk_rtx_setretval (rtx, retv);
|
hawk_rtx_setretval (rtx, retv);
|
||||||
return 0;
|
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;
|
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||||
else
|
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)
|
if (item)
|
||||||
{
|
{
|
||||||
ret = revert_byid (rtx, list, id, item);
|
ret = revert_byid(rtx, list, id, item);
|
||||||
hawk_rtx_freemem (rtx, item);
|
hawk_rtx_freemem (rtx, item);
|
||||||
}
|
}
|
||||||
else ret = -UCI_ERR_MEM;
|
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;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
retv = hawk_rtx_makeintval (rtx, ret);
|
retv = hawk_rtx_makeintval(rtx, ret);
|
||||||
if (retv == HAWK_NULL) return -1;
|
if (!retv) return -1;
|
||||||
|
|
||||||
hawk_rtx_setretval (rtx, retv);
|
hawk_rtx_setretval (rtx, retv);
|
||||||
return 0;
|
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;
|
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||||
else
|
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)
|
if (item)
|
||||||
{
|
{
|
||||||
ret = delete_byid (rtx, list, id, item);
|
ret = delete_byid(rtx, list, id, item);
|
||||||
hawk_rtx_freemem (rtx, item);
|
hawk_rtx_freemem (rtx, item);
|
||||||
}
|
}
|
||||||
else ret = -UCI_ERR_MEM;
|
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;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
retv = hawk_rtx_makeintval (rtx, ret);
|
retv = hawk_rtx_makeintval(rtx, ret);
|
||||||
if (retv == HAWK_NULL) return -1;
|
if (!retv) return -1;
|
||||||
|
|
||||||
hawk_rtx_setretval (rtx, retv);
|
hawk_rtx_setretval (rtx, retv);
|
||||||
return 0;
|
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;
|
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||||
else
|
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)
|
if (item)
|
||||||
{
|
{
|
||||||
ret = rename_byid (rtx, list, id, item);
|
ret = rename_byid(rtx, list, id, item);
|
||||||
hawk_rtx_freemem (rtx, item);
|
hawk_rtx_freemem (rtx, item);
|
||||||
}
|
}
|
||||||
else ret = -UCI_ERR_MEM;
|
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;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
retv = hawk_rtx_makeintval (rtx, ret);
|
retv = hawk_rtx_makeintval(rtx, ret);
|
||||||
if (retv == HAWK_NULL) return -1;
|
if (!retv) return -1;
|
||||||
|
|
||||||
hawk_rtx_setretval (rtx, retv);
|
hawk_rtx_setretval (rtx, retv);
|
||||||
return 0;
|
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;
|
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||||
else
|
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)
|
if (item)
|
||||||
{
|
{
|
||||||
ret = set_byid (rtx, list, id, item);
|
ret = set_byid(rtx, list, id, item);
|
||||||
hawk_rtx_freemem (rtx, item);
|
hawk_rtx_freemem (rtx, item);
|
||||||
}
|
}
|
||||||
else ret = -UCI_ERR_MEM;
|
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;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
retv = hawk_rtx_makeintval (rtx, ret);
|
retv = hawk_rtx_makeintval(rtx, ret);
|
||||||
if (retv == HAWK_NULL) return -1;
|
if (!retv) return -1;
|
||||||
|
|
||||||
hawk_rtx_setretval (rtx, retv);
|
hawk_rtx_setretval (rtx, retv);
|
||||||
return 0;
|
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;
|
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hawk_mchar_t* item, * type;
|
hawk_bch_t* item, * type;
|
||||||
|
|
||||||
item = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL);
|
item = hawk_rtx_valtobcstrdup(rtx, hawk_rtx_getarg(rtx, 1), HAWK_NULL);
|
||||||
type = hawk_rtx_valtombsdup(rtx, hawk_rtx_getarg(rtx, 2), HAWK_NULL);
|
type = hawk_rtx_valtobcstrdup(rtx, hawk_rtx_getarg(rtx, 2), HAWK_NULL);
|
||||||
if (item && type)
|
if (item && type)
|
||||||
{
|
{
|
||||||
ret = addsection_byid (rtx, list, id, item, type);
|
ret = addsection_byid(rtx, list, id, item, type);
|
||||||
}
|
}
|
||||||
else ret = -UCI_ERR_MEM;
|
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;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
retv = hawk_rtx_makeintval (rtx, ret);
|
retv = hawk_rtx_makeintval(rtx, ret);
|
||||||
if (retv == HAWK_NULL) return -1;
|
if (!retv) return -1;
|
||||||
|
|
||||||
hawk_rtx_setretval (rtx, retv);
|
hawk_rtx_setretval (rtx, retv);
|
||||||
return 0;
|
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;
|
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||||
else
|
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)
|
if (item)
|
||||||
{
|
{
|
||||||
ret = addlist_byid (rtx, list, id, item);
|
ret = addlist_byid(rtx, list, id, item);
|
||||||
hawk_rtx_freemem (rtx, item);
|
hawk_rtx_freemem (rtx, item);
|
||||||
}
|
}
|
||||||
else ret = -UCI_ERR_MEM;
|
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;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
retv = hawk_rtx_makeintval (rtx, ret);
|
retv = hawk_rtx_makeintval(rtx, ret);
|
||||||
if (retv == HAWK_NULL) return -1;
|
if (!retv) return -1;
|
||||||
|
|
||||||
hawk_rtx_setretval (rtx, retv);
|
hawk_rtx_setretval (rtx, retv);
|
||||||
return 0;
|
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;
|
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||||
else
|
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)
|
if (item)
|
||||||
{
|
{
|
||||||
ret = setconfdir_byid (rtx, list, id, item);
|
ret = setconfdir_byid(rtx, list, id, item);
|
||||||
hawk_rtx_freemem (rtx, item);
|
hawk_rtx_freemem (rtx, item);
|
||||||
}
|
}
|
||||||
else ret = -UCI_ERR_MEM;
|
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;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
retv = hawk_rtx_makeintval (rtx, ret);
|
retv = hawk_rtx_makeintval(rtx, ret);
|
||||||
if (retv == HAWK_NULL) return -1;
|
if (!retv) return -1;
|
||||||
|
|
||||||
hawk_rtx_setretval (rtx, retv);
|
hawk_rtx_setretval (rtx, retv);
|
||||||
return 0;
|
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;
|
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||||
else
|
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)
|
if (item)
|
||||||
{
|
{
|
||||||
ret = setsavedir_byid (rtx, list, id, item);
|
ret = setsavedir_byid(rtx, list, id, item);
|
||||||
hawk_rtx_freemem (rtx, item);
|
hawk_rtx_freemem (rtx, item);
|
||||||
}
|
}
|
||||||
else ret = -UCI_ERR_MEM;
|
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;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
retv = hawk_rtx_makeintval (rtx, ret);
|
retv = hawk_rtx_makeintval(rtx, ret);
|
||||||
if (retv == HAWK_NULL) return -1;
|
if (!retv) return -1;
|
||||||
|
|
||||||
hawk_rtx_setretval (rtx, retv);
|
hawk_rtx_setretval (rtx, retv);
|
||||||
return 0;
|
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;
|
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||||
else
|
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)
|
if (item)
|
||||||
{
|
{
|
||||||
ret = adddeltapath_byid (rtx, list, id, item);
|
ret = adddeltapath_byid(rtx, list, id, item);
|
||||||
hawk_rtx_freemem (rtx, item);
|
hawk_rtx_freemem (rtx, item);
|
||||||
}
|
}
|
||||||
else ret = -UCI_ERR_MEM;
|
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;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
retv = hawk_rtx_makeintval (rtx, ret);
|
retv = hawk_rtx_makeintval(rtx, ret);
|
||||||
if (retv == HAWK_NULL) return -1;
|
if (!retv) return -1;
|
||||||
|
|
||||||
hawk_rtx_setretval (rtx, retv);
|
hawk_rtx_setretval (rtx, retv);
|
||||||
return 0;
|
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;
|
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||||
else
|
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)
|
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);
|
hawk_rtx_freemem (rtx, item);
|
||||||
if (ret == -9999) return -1;
|
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;
|
else ret = 0;
|
||||||
|
|
||||||
hawk_rtx_setretval (rtx, hawk_rtx_makeintval (rtx, ret));
|
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, ret));
|
||||||
return 0;
|
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);
|
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;
|
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||||
else
|
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)
|
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);
|
hawk_rtx_freemem (rtx, item);
|
||||||
if (ret == -9999) return -1;
|
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;
|
else ret = 0;
|
||||||
|
|
||||||
hawk_rtx_setretval (rtx, hawk_rtx_makeintval (rtx, ret));
|
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, ret));
|
||||||
return 0;
|
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);
|
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));
|
HAWK_MEMSET (&list, 0, HAWK_SIZEOF(list));
|
||||||
if (hawk_rbt_insert(rbt, &rtx, HAWK_SIZEOF(rtx), &list, HAWK_SIZEOF(list)) == HAWK_NULL)
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1393,10 +1384,10 @@ int hawk_mod_uci (hawk_mod_t* mod, hawk_t* hawk)
|
|||||||
mod->init = init;
|
mod->init = init;
|
||||||
mod->fini = fini;
|
mod->fini = fini;
|
||||||
|
|
||||||
rbt = hawk_rbt_open (hawk_getgem(hawk), 0, 1, 1);
|
rbt = hawk_rbt_open(hawk_getgem(hawk), 0, 1, 1);
|
||||||
if (rbt == HAWK_NULL) return -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;
|
mod->ctx = rbt;
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user