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)
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 (l_unlikely(
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);
258 else if (l_unlikely(d < 0))
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);
CURL_EXTERN int void * arg
LUA_API void lua_pushstring(lua_State *L, const char *s)
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_checktype(lua_State *L, int narg, int t)
LUALIB_API void luaL_pushresult(luaL_Buffer *B)
LUALIB_API int luaL_error(lua_State *L, const char *fmt,...)
LUALIB_API lua_Integer luaL_optinteger(lua_State *L, int narg, lua_Integer def)
LUALIB_API int luaL_checkoption(lua_State *L, int narg, const char *def, const char *const lst[])
LUALIB_API const char * luaL_optlstring(lua_State *L, int narg, const char *def, size_t *len)
LUALIB_API int luaL_argerror(lua_State *L, int narg, const char *extramsg)
#define luaL_addsize(B, n)
#define luaL_addchar(B, c)
#define luaL_optstring(L, n, d)
#define luaL_opt(L, f, n, d)
#define luaL_checkstring(L, n)
#define luaL_argcheck(L, cond, numarg, extramsg)
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 char * luaL_prepbuffsize(luaL_Buffer *B, size_t sz)
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)
LUA_UNSIGNED lua_Unsigned
LUAMOD_API int luaopen_os(lua_State *L)
#define LUA_TMPNAMBUFSIZE
static int os_setlocale(lua_State *L)
#define l_gettime(L, arg)
static int os_execute(lua_State *L)
static int os_getenv(lua_State *L)
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 int os_tmpname(lua_State *L)
static int os_exit(lua_State *L)
static int os_rename(lua_State *L)
static int getfield(lua_State *L, const char *key, int d, int delta)
static void setfield(lua_State *L, const char *key, int value, int delta)
static const char * checkoption(lua_State *L, const char *conv, ptrdiff_t convlen, char *buff)
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 void setallfields(lua_State *L, struct tm *stm)
static time_t l_checktime(lua_State *L, int arg)
static int os_remove(lua_State *L)
CURL_EXTERN CURLMcode curl_socket_t s