25 #if !defined(LUA_STRFTIMEOPTIONS)
27 #if !defined(LUA_USE_POSIX)
28 #define LUA_STRFTIMEOPTIONS { "aAbBcdHIjmMpSUwWxXyYz%", "" }
30 #define LUA_STRFTIMEOPTIONS \
31 { "aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%", "" \
33 "O", "deHImMSuUVwWy" }
44 #if defined(LUA_USE_MKSTEMP)
46 #define LUA_TMPNAMBUFSIZE 32
47 #define lua_tmpnam(b,e) { \
48 strcpy(b, "/tmp/lua_XXXXXX"); \
50 if (e != -1) close(e); \
53 #elif !defined(lua_tmpnam)
55 #define LUA_TMPNAMBUFSIZE L_tmpnam
56 #define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); }
65 #if defined(LUA_USE_GMTIME_R)
67 #define l_gmtime(t,r) gmtime_r(t,r)
68 #define l_localtime(t,r) localtime_r(t,r)
70 #elif !defined(l_gmtime)
72 #define l_gmtime(t,r) ((void)r, gmtime(t))
73 #define l_localtime(t,r) ((void)r, localtime(t))
81 int stat = system(cmd);
109 return luaL_error(L,
"unable to generate a unique filename");
173 for (i = 0; i <
sizeof(
options)/
sizeof(options[0]); i += 2) {
174 if (*conv !=
'\0' && strchr(options[i], *conv) != NULL) {
176 if (*options[i + 1] ==
'\0') {
180 else if (*(conv + 1) !=
'\0' &&
181 strchr(options[i + 1], *(conv + 1)) != NULL) {
182 buff[2] = *(conv + 1);
206 else if (strcmp(s,
"*t") == 0) {
212 setfield(L,
"month", stm->tm_mon+1);
213 setfield(L,
"year", stm->tm_year+1900);
214 setfield(L,
"wday", stm->tm_wday+1);
215 setfield(L,
"yday", stm->tm_yday+1);
230 reslen =
strftime(buff,
sizeof(buff), cc, stm);
250 ts.tm_hour =
getfield(L,
"hour", 12);
251 ts.tm_mday =
getfield(L,
"day", -1);
252 ts.tm_mon =
getfield(L,
"month", -1) - 1;
253 ts.tm_year =
getfield(L,
"year", -1) - 1900;
257 if (t == (time_t)(-1))
275 static const int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY,
276 LC_NUMERIC, LC_TIME};
277 static const char *
const catnames[] = {
"all",
"collate",
"ctype",
"monetary",
278 "numeric",
"time", NULL};
289 status = (
lua_toboolean(L, 1) ? EXIT_SUCCESS : EXIT_FAILURE);
#define LUA_STRFTIMEOPTIONS
#define lua_isnoneornil(L, n)
size_t strftime(char *str, size_t count, const std::string &format, const std::tm *time)
LUA_API void lua_createtable(lua_State *L, int narray, int nrec)
LUA_API void lua_getfield(lua_State *L, int idx, const char *k)
LUA_API void lua_settop(lua_State *L, int idx)
LUA_API void lua_pushboolean(lua_State *L, int b)
LUALIB_API void luaL_checktype(lua_State *L, int narg, int t)
LUALIB_API void luaL_pushresult(luaL_Buffer *B)
static int os_time(lua_State *L)
static int os_execute(lua_State *L)
GLdouble GLdouble GLdouble b
LUA_API lua_Integer lua_tointegerx(lua_State *L, int idx, int *isnum)
#define l_localtime(t, r)
static int os_tmpname(lua_State *L)
LUAMOD_API int luaopen_os(lua_State *L)
LUALIB_API int luaL_fileresult(lua_State *L, int stat, const char *fname)
static int os_difftime(lua_State *L)
LUALIB_API int luaL_checkoption(lua_State *L, int narg, const char *def, const char *const lst[])
#define luaL_opt(L, f, n, d)
LUA_API int lua_toboolean(lua_State *L, int idx)
GLsizei const GLfloat * value
LUALIB_API void luaL_buffinit(lua_State *L, luaL_Buffer *B)
static int os_getenv(lua_State *L)
static int os_date(lua_State *L)
LUA_API void lua_close(lua_State *L)
LUALIB_API lua_Number luaL_checknumber(lua_State *L, int narg)
#define luaL_addchar(B, c)
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
LUALIB_API void luaL_addlstring(luaL_Buffer *B, const char *s, size_t l)
LUA_API void lua_pushnil(lua_State *L)
LUA_API void lua_pushnumber(lua_State *L, lua_Number n)
static int os_rename(lua_State *L)
LUALIB_API lua_Number luaL_optnumber(lua_State *L, int narg, lua_Number def)
#define lua_isboolean(L, n)
static int os_exit(lua_State *L)
static int os_remove(lua_State *L)
static void setboolfield(lua_State *L, const char *key, int value)
#define LUA_TMPNAMBUFSIZE
LUALIB_API int luaL_argerror(lua_State *L, int narg, const char *extramsg)
#define luaL_newlib(L, l)
LUALIB_API int luaL_error(lua_State *L, const char *fmt,...)
static const char * checkoption(lua_State *L, const char *conv, char *buff)
#define luaL_optint(L, n, d)
LUALIB_API int luaL_execresult(lua_State *L, int stat)
LUA_API const char * lua_pushfstring(lua_State *L, const char *fmt,...)
static int os_clock(lua_State *L)
static int getfield(lua_State *L, const char *key, int d)
static void setfield(lua_State *L, const char *key, int value)
LUA_API void lua_pushinteger(lua_State *L, lua_Integer n)
#define luaL_optstring(L, n, d)
LUA_API const char * lua_pushstring(lua_State *L, const char *s)
LUA_API void lua_setfield(lua_State *L, int idx, const char *k)
static const luaL_Reg syslib[]
static int getboolfield(lua_State *L, const char *key)
static int os_setlocale(lua_State *L)
#define luaL_checkstring(L, n)