31 #if !defined(LUA_STRFTIMEOPTIONS) 34 #define L_STRFTIMEC89 "aAbBcdHIjmMpSUwWxXyYZ%" 37 #define L_STRFTIMEC99 "aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%" \ 38 "||" "EcECExEXEyEY" "OdOeOHOIOmOMOSOuOUOVOwOWOy" 41 #define L_STRFTIMEWIN "aAbBcdHIjmMpSUwWxXyYzZ%" \ 42 "||" "#c#x#d#H#I#j#m#M#S#U#w#W#y#Y" 44 #if defined(LUA_USE_WINDOWS) 45 #define LUA_STRFTIMEOPTIONS L_STRFTIMEWIN 46 #elif defined(LUA_USE_C89) 47 #define LUA_STRFTIMEOPTIONS L_STRFTIMEC89 49 #define LUA_STRFTIMEOPTIONS L_STRFTIMEC99 65 #if !defined(LUA_NUMTIME) 67 #define l_timet lua_Integer 68 #define l_pushtime(L,t) lua_pushinteger(L,(lua_Integer)(t)) 69 #define l_gettime(L,arg) luaL_checkinteger(L, arg) 73 #define l_timet lua_Number 74 #define l_pushtime(L,t) lua_pushnumber(L,(lua_Number)(t)) 75 #define l_gettime(L,arg) luaL_checknumber(L, arg) 80 #if !defined(l_gmtime) 86 #if defined(LUA_USE_POSIX) 88 #define l_gmtime(t,r) gmtime_r(t,r) 89 #define l_localtime(t,r) localtime_r(t,r) 94 #define l_gmtime(t,r) ((void)(r)->tm_sec, gmtime(t)) 95 #define l_localtime(t,r) ((void)(r)->tm_sec, localtime(t)) 111 #if !defined(lua_tmpnam) 113 #if defined(LUA_USE_POSIX) 117 #define LUA_TMPNAMBUFSIZE 32 119 #if !defined(LUA_TMPNAMTEMPLATE) 120 #define LUA_TMPNAMTEMPLATE "/tmp/lua_XXXXXX" 123 #define lua_tmpnam(b,e) { \ 124 strcpy(b, LUA_TMPNAMTEMPLATE); \ 126 if (e != -1) close(e); \ 132 #define LUA_TMPNAMBUFSIZE L_tmpnam 133 #define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } 174 return luaL_error(L,
"unable to generate a unique filename");
210 #if (defined(LUA_NUMTIME) && LUA_MAXINTEGER <= INT_MAX) 211 if (value > LUA_MAXINTEGER - delta)
212 luaL_error(L,
"field '%s' is out-of-bound", key);
231 setfield(L,
"year", stm->tm_year, 1900);
232 setfield(L,
"month", stm->tm_mon, 1);
233 setfield(L,
"day", stm->tm_mday, 0);
234 setfield(L,
"hour", stm->tm_hour, 0);
237 setfield(L,
"yday", stm->tm_yday, 1);
238 setfield(L,
"wday", stm->tm_wday, 1);
257 return luaL_error(L,
"field '%s' is not an integer", key);
259 return luaL_error(L,
"field '%s' missing in date table", key);
266 return luaL_error(L,
"field '%s' is out-of-bound", key);
275 ptrdiff_t convlen,
char *buff) {
278 for (; *option !=
'\0' && oplen <= convlen; option += oplen) {
281 else if (memcmp(conv, option, oplen) == 0) {
282 memcpy(buff, conv, oplen);
301 #define SIZETIMEFMT 250 308 const char *se = s + slen;
318 "date result cannot be represented in this installation");
319 if (strcmp(s,
"*t") == 0) {
354 ts.tm_year =
getfield(L,
"year", -1, 1900);
355 ts.tm_mon =
getfield(L,
"month", -1, 1);
356 ts.tm_mday =
getfield(L,
"day", -1, 0);
357 ts.tm_hour =
getfield(L,
"hour", 12, 0);
358 ts.tm_min =
getfield(L,
"min", 0, 0);
359 ts.tm_sec =
getfield(L,
"sec", 0, 0);
364 if (t != (time_t)(
l_timet)t || t == (time_t)(-1))
366 "time result cannot be represented in this installation");
383 static const int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY,
384 LC_NUMERIC, LC_TIME};
385 static const char *
const catnames[] = {
"all",
"collate",
"ctype",
"monetary",
386 "numeric",
"time", NULL};
397 status = (
lua_toboolean(L, 1) ? EXIT_SUCCESS : EXIT_FAILURE);
#define luaL_addsize(B, s)
#define lua_isnoneornil(L, n)
enum MQTTPropertyCodes value
static const luaL_Reg syslib[]
static int os_date(lua_State *L)
LUALIB_API int luaL_checkoption(lua_State *L, int arg, const char *def, const char *const lst[])
static int os_difftime(lua_State *L)
static int os_execute(lua_State *L)
LUA_API int lua_toboolean(lua_State *L, int idx)
LUAMOD_API int luaopen_os(lua_State *L)
LUA_API void lua_setfield(lua_State *L, int idx, const char *k)
LUA_API lua_Integer lua_tointegerx(lua_State *L, int idx, int *pisnum)
size_t strftime(char *str, size_t count, const char *format, const std::tm *time)
#define LUA_STRFTIMEOPTIONS
LUA_API const char * lua_pushstring(lua_State *L, const char *s)
LUALIB_API void luaL_buffinit(lua_State *L, luaL_Buffer *B)
static time_t l_checktime(lua_State *L, int arg)
static int os_clock(lua_State *L)
static void setboolfield(lua_State *L, const char *key, int value)
static int os_setlocale(lua_State *L)
LUALIB_API int luaL_execresult(lua_State *L, int stat)
static int os_time(lua_State *L)
LUA_API void lua_settop(lua_State *L, int idx)
static void setallfields(lua_State *L, struct tm *stm)
#define l_gettime(L, arg)
#define luaL_opt(L, f, n, d)
LUALIB_API void luaL_pushresult(luaL_Buffer *B)
LUA_API void lua_pushboolean(lua_State *L, int b)
LUALIB_API int luaL_fileresult(lua_State *L, int stat, const char *fname)
LUA_API void lua_close(lua_State *L)
static int os_remove(lua_State *L)
#define luaL_addchar(B, c)
LUALIB_API const char * luaL_optlstring(lua_State *L, int arg, const char *def, size_t *len)
static void setfield(lua_State *L, const char *key, int value, int delta)
#define lua_isboolean(L, n)
static int os_tmpname(lua_State *L)
static const char * checkoption(lua_State *L, const char *conv, ptrdiff_t convlen, char *buff)
detail::named_arg< Char, T > arg(const Char *name, const T &arg)
LUALIB_API int luaL_argerror(lua_State *L, int arg, const char *extramsg)
LUA_API void lua_createtable(lua_State *L, int narray, int nrec)
LUALIB_API lua_Integer luaL_optinteger(lua_State *L, int arg, lua_Integer def)
static int os_getenv(lua_State *L)
LUALIB_API int luaL_error(lua_State *L, const char *fmt,...)
#define luaL_newlib(L, l)
LUA_UNSIGNED lua_Unsigned
#define luaL_argcheck(L, cond, arg, extramsg)
#define l_localtime(t, r)
LUA_API void lua_pushinteger(lua_State *L, lua_Integer n)
LUALIB_API void luaL_checktype(lua_State *L, int arg, int t)
static int os_rename(lua_State *L)
LUA_API const char * lua_pushfstring(lua_State *L, const char *fmt,...)
#define LUA_TMPNAMBUFSIZE
LUALIB_API char * luaL_prepbuffsize(luaL_Buffer *B, size_t sz)
static int os_exit(lua_State *L)
static int getfield(lua_State *L, const char *key, int d, int delta)
LUA_API int lua_getfield(lua_State *L, int idx, const char *k)
static int getboolfield(lua_State *L, const char *key)
LUA_API void lua_pushnumber(lua_State *L, lua_Number n)
#define luaL_optstring(L, n, d)
#define luaL_checkstring(L, n)