26#if !defined(LUA_STRFTIMEOPTIONS)
28#if !defined(LUA_USE_POSIX)
29#define LUA_STRFTIMEOPTIONS { "aAbBcdHIjmMpSUwWxXyYz%", "" }
31#define LUA_STRFTIMEOPTIONS \
32 { "aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%", "" \
34 "O", "deHImMSuUVwWy" }
45#if defined(LUA_USE_MKSTEMP)
47#define LUA_TMPNAMBUFSIZE 32
48#define lua_tmpnam(b,e) { \
49 strcpy(b, "/tmp/lua_XXXXXX"); \
51 if (e != -1) close(e); \
54#elif !defined(lua_tmpnam)
56#define LUA_TMPNAMBUFSIZE L_tmpnam
57#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); }
66#if defined(LUA_USE_GMTIME_R)
68#define l_gmtime(t,r) gmtime_r(t,r)
69#define l_localtime(t,r) localtime_r(t,r)
71#elif !defined(l_gmtime)
73#define l_gmtime(t,r) ((void)r, gmtime(t))
74#define l_localtime(t,r) ((void)r, localtime(t))
82 int stat = system(cmd);
110 return luaL_error(L,
"unable to generate a unique filename");
174 for (i = 0; i <
sizeof(options)/
sizeof(options[0]); i += 2) {
175 if (*conv !=
'\0' && strchr(options[i], *conv) !=
NULL) {
177 if (*options[i + 1] ==
'\0') {
181 else if (*(conv + 1) !=
'\0' &&
182 strchr(options[i + 1], *(conv + 1)) !=
NULL) {
183 buff[2] = *(conv + 1);
207 else if (strcmp(
s,
"*t") == 0) {
213 setfield(L,
"month", stm->tm_mon+1);
214 setfield(L,
"year", stm->tm_year+1900);
215 setfield(L,
"wday", stm->tm_wday+1);
216 setfield(L,
"yday", stm->tm_yday+1);
231 reslen = strftime(buff,
sizeof(buff), cc, stm);
251 ts.tm_hour =
getfield(L,
"hour", 12);
252 ts.tm_mday =
getfield(L,
"day", -1);
253 ts.tm_mon =
getfield(L,
"month", -1) - 1;
254 ts.tm_year =
getfield(L,
"year", -1) - 1900;
258 if (t == (time_t)(-1))
276 static const int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY,
277 LC_NUMERIC, LC_TIME};
278 static const char *
const catnames[] = {
"all",
"collate",
"ctype",
"monetary",
279 "numeric",
"time",
NULL};
290 status = (
lua_toboolean(L, 1) ? EXIT_SUCCESS : EXIT_FAILURE);
LUA_API void lua_pushstring(lua_State *L, const char *s)
LUA_API void lua_pushnil(lua_State *L)
LUA_API void lua_pushnumber(lua_State *L, lua_Number n)
LUA_API const char * lua_pushfstring(lua_State *L, const char *fmt,...)
LUA_API void lua_setfield(lua_State *L, int idx, const char *k)
LUA_API int lua_toboolean(lua_State *L, int idx)
LUA_API void lua_pushboolean(lua_State *L, int b)
LUA_API void lua_createtable(lua_State *L, int narray, int nrec)
LUA_API void lua_settop(lua_State *L, int idx)
LUA_API void lua_pushinteger(lua_State *L, lua_Integer n)
LUA_API void lua_getfield(lua_State *L, int idx, const char *k)
LUALIB_API void luaL_buffinit(lua_State *L, luaL_Buffer *B)
LUALIB_API void luaL_addlstring(luaL_Buffer *B, const char *s, size_t l)
LUALIB_API void luaL_checktype(lua_State *L, int narg, int t)
LUALIB_API void luaL_pushresult(luaL_Buffer *B)
LUALIB_API lua_Number luaL_optnumber(lua_State *L, int narg, lua_Number def)
LUALIB_API int luaL_error(lua_State *L, const char *fmt,...)
LUALIB_API int luaL_checkoption(lua_State *L, int narg, const char *def, const char *const lst[])
LUALIB_API int luaL_argerror(lua_State *L, int narg, const char *extramsg)
LUALIB_API lua_Number luaL_checknumber(lua_State *L, int narg)
#define luaL_addchar(B, c)
#define luaL_optstring(L, n, d)
#define luaL_optint(L, n, d)
#define luaL_opt(L, f, n, d)
#define luaL_checkstring(L, n)
LUA_API void lua_close(lua_State *L)
#define lua_isboolean(L, n)
#define lua_isnoneornil(L, n)
LUA_API lua_Integer lua_tointegerx(lua_State *L, int idx, int *isnum)
LUALIB_API int luaL_execresult(lua_State *L, int stat)
LUALIB_API int luaL_fileresult(lua_State *L, int stat, const char *fname)
#define luaL_newlib(L, l)
LUAMOD_API int luaopen_os(lua_State *L)
#define LUA_TMPNAMBUFSIZE
static int os_setlocale(lua_State *L)
static int os_execute(lua_State *L)
static int os_getenv(lua_State *L)
static int getfield(lua_State *L, const char *key, int d)
static const char * checkoption(lua_State *L, const char *conv, char *buff)
static int getboolfield(lua_State *L, const char *key)
static int os_date(lua_State *L)
static void setboolfield(lua_State *L, const char *key, int value)
static const luaL_Reg syslib[]
#define l_localtime(t, r)
static void setfield(lua_State *L, const char *key, int value)
static int os_tmpname(lua_State *L)
static int os_exit(lua_State *L)
static int os_rename(lua_State *L)
static int os_difftime(lua_State *L)
#define LUA_STRFTIMEOPTIONS
static int os_clock(lua_State *L)
static int os_time(lua_State *L)
static int os_remove(lua_State *L)
CURL_EXTERN CURLMcode curl_socket_t s