lua_setfield(L, -2, "state");
lua_pushstring(L, peer->desc ? peer->desc : "");
lua_setfield(L, -2, "description");
- lua_pushtimet(L, &peer->uptime);
+ lua_pushinteger(L, peer->uptime);
lua_setfield(L, -2, "uptime");
- lua_pushtimet(L, &peer->readtime);
+ lua_pushinteger(L, peer->readtime);
lua_setfield(L, -2, "last_readtime");
- lua_pushtimet(L, &peer->resettime);
+ lua_pushinteger(L, peer->resettime);
lua_setfield(L, -2, "last_resettime");
lua_pushsockunion(L, peer->su_local);
lua_setfield(L, -2, "local_address");
return su;
}
-void lua_pushtimet(lua_State *L, const time_t *time)
-{
- lua_pushinteger(L, *time);
-}
-
-void lua_decode_timet(lua_State *L, int idx, time_t *t)
-{
- *t = lua_tointeger(L, idx);
- lua_pop(L, 1);
-}
-
-void *lua_totimet(lua_State *L, int idx)
-{
- time_t *t = XCALLOC(MTYPE_SCRIPT_RES, sizeof(time_t));
-
- lua_decode_timet(L, idx, t);
- return t;
-}
-
void lua_pushintegerp(lua_State *L, const long long *num)
{
lua_pushinteger(L, *num);
*/
void *lua_toin6addr(lua_State *L, int idx);
-/*
- * Converts a time_t to a Lua value and pushes it on the stack.
- */
-void lua_pushtimet(lua_State *L, const time_t *time);
-
-void lua_decode_timet(lua_State *L, int idx, time_t *time);
-
-/*
- * Converts the Lua value at idx to a time_t.
- *
- * Returns:
- * time_t allocated with MTYPE_TMP.
- */
-void *lua_totimet(lua_State *L, int idx);
-
/*
* Converts a sockunion to a Lua value and pushes it on the stack.
*/
{.typename = "sockunion",
.encoder = (encoder_func)lua_pushsockunion,
.decoder = lua_tosockunion},
- {.typename = "time_t",
- .encoder = (encoder_func)lua_pushtimet,
- .decoder = lua_totimet},
{}};
/* Type codecs */
struct in_addr * : lua_pushinaddr, \
struct in6_addr * : lua_pushin6addr, \
union sockunion * : lua_pushsockunion, \
-time_t * : lua_pushtimet, \
char * : lua_pushstring_wrapper, \
struct attr * : lua_pushattr, \
struct peer * : lua_pushpeer, \
struct in_addr * : lua_decode_inaddr, \
struct in6_addr * : lua_decode_in6addr, \
union sockunion * : lua_decode_sockunion, \
-time_t * : lua_decode_timet, \
char * : lua_decode_stringp, \
struct attr * : lua_decode_attr, \
struct peer * : lua_decode_noop, \
assert(lua_gettop(L) == 0);
time_t time_a = 100;
- time_t time_b = time_a;
+ time_t time_b;
- lua_pushtimet(L, &time_a);
- lua_decode_timet(L, -1, &time_a);
+ lua_pushinteger(L, time_a);
+ time_b = lua_tointeger(L, -1);
+ lua_pop(L, 1);
assert(time_a == time_b);
assert(lua_gettop(L) == 0);