summaryrefslogtreecommitdiffstats
path: root/lib/frrlua.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 04:24:34 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 04:24:34 +0000
commit137ce8dd46d313f15ee93ddbb5428d702aa61ed8 (patch)
treea49f76849019651842962dff2197b705e33831e7 /lib/frrlua.c
parentReleasing progress-linux version 9.1-0.1~progress7.99u1. (diff)
downloadfrr-137ce8dd46d313f15ee93ddbb5428d702aa61ed8.tar.xz
frr-137ce8dd46d313f15ee93ddbb5428d702aa61ed8.zip
Merging upstream version 10.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/frrlua.c')
-rw-r--r--lib/frrlua.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/lib/frrlua.c b/lib/frrlua.c
index e626efe..2cab1a5 100644
--- a/lib/frrlua.c
+++ b/lib/frrlua.c
@@ -259,12 +259,12 @@ void *lua_tosockunion(lua_State *L, int idx)
return su;
}
-void lua_pushintegerp(lua_State *L, const long long *num)
+void lua_pushintegerp(lua_State *L, const int *num)
{
lua_pushinteger(L, *num);
}
-void lua_decode_integerp(lua_State *L, int idx, long long *num)
+void lua_decode_integerp(lua_State *L, int idx, int *num)
{
int isnum;
*num = lua_tonumberx(L, idx, &isnum);
@@ -274,7 +274,7 @@ void lua_decode_integerp(lua_State *L, int idx, long long *num)
void *lua_tointegerp(lua_State *L, int idx)
{
- long long *num = XCALLOC(MTYPE_SCRIPT_RES, sizeof(long long));
+ int *num = XCALLOC(MTYPE_SCRIPT_RES, sizeof(int));
lua_decode_integerp(L, idx, num);
return num;
@@ -332,32 +332,39 @@ void lua_pushnexthop_group(lua_State *L, const struct nexthop_group *ng)
}
}
-void lua_decode_stringp(lua_State *L, int idx, char *str)
+void lua_pushlonglongp(lua_State *L, const long long *num)
{
- strlcpy(str, lua_tostring(L, idx), strlen(str) + 1);
+ /* lua library function; this can take a long long */
+ lua_pushinteger(L, *num);
+}
+
+void lua_decode_longlongp(lua_State *L, int idx, long long *num)
+{
+ int isnum;
+ *num = lua_tonumberx(L, idx, &isnum);
lua_pop(L, 1);
+ assert(isnum);
}
-void *lua_tostringp(lua_State *L, int idx)
+void *lua_tolonglongp(lua_State *L, int idx)
{
- char *string = XSTRDUP(MTYPE_SCRIPT_RES, lua_tostring(L, idx));
+ long long *num = XCALLOC(MTYPE_SCRIPT_RES, sizeof(long long));
- return string;
+ lua_decode_longlongp(L, idx, num);
+ return num;
}
-/*
- * Decoder for const values, since we cannot modify them.
- */
-void lua_decode_noop(lua_State *L, int idx, const void *ptr)
+void lua_decode_stringp(lua_State *L, int idx, char *str)
{
+ strlcpy(str, lua_tostring(L, idx), strlen(str) + 1);
+ lua_pop(L, 1);
}
-
-/*
- * Noop decoder for int.
- */
-void lua_decode_integer_noop(lua_State *L, int idx, int i)
+void *lua_tostringp(lua_State *L, int idx)
{
+ char *string = XSTRDUP(MTYPE_SCRIPT_RES, lua_tostring(L, idx));
+
+ return string;
}
/*