]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: Add basic encoders
authorDonald Lee <dlqs@gmx.com>
Sun, 20 Jun 2021 00:24:44 +0000 (08:24 +0800)
committerDonald Lee <dlqs@gmx.com>
Mon, 21 Jun 2021 20:55:19 +0000 (04:55 +0800)
Signed-off-by: Donald Lee <dlqs@gmx.com>
lib/frrscript.h

index 06d247f38d612cebd7eb005d6d4e85c6a45600df..5410f53e1167d1c0c87e69d8bff7aa36abbd61a0 100644 (file)
@@ -98,7 +98,7 @@ void frrscript_init(const char *scriptdir);
 
 #define ENCODE_ARGS(name, value)                                               \
        do {                                                                   \
-               ENCODE_ARGS_WITH_STATE(L, value)                               \
+               ENCODE_ARGS_WITH_STATE(L, value);                              \
                lua_setglobal(L, name);                                        \
        } while (0)
 
@@ -108,7 +108,17 @@ void frrscript_init(const char *scriptdir);
                DECODE_ARGS_WITH_STATE(L, value)                               \
        } while (0)
 
-#define ENCODE_ARGS_WITH_STATE(L, value) _Generic((value), )(L, value);
+#define ENCODE_ARGS_WITH_STATE(L, value)                                       \
+       _Generic((value), \
+long long * : lua_pushintegerp,                                 \
+struct prefix * : lua_pushprefix,                               \
+struct interface * : lua_pushinterface,                         \
+struct in_addr * : lua_pushinaddr,                              \
+struct in6_addr * : lua_pushin6addr,                            \
+union sockunion * : lua_pushsockunion,                          \
+time_t * : lua_pushtimet,                                       \
+char * : lua_pushstring_wrapper                                 \
+)(L, value)
 
 #define DECODE_ARGS_WITH_STATE(L, value) _Generic((value), )(L, value);