#include <errno.h>
#include <locale.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
Go to the source code of this file.
Defines | |
#define | loslib_c |
#define | LUA_LIB |
Functions | |
static int | os_pushresult (lua_State *L, int i, const char *filename) |
static int | os_execute (lua_State *L) |
static int | os_remove (lua_State *L) |
static int | os_rename (lua_State *L) |
static int | os_tmpname (lua_State *L) |
static int | os_getenv (lua_State *L) |
static int | os_clock (lua_State *L) |
static void | setfield (lua_State *L, const char *key, int value) |
static void | setboolfield (lua_State *L, const char *key, int value) |
static int | getboolfield (lua_State *L, const char *key) |
static int | getfield (lua_State *L, const char *key, int d) |
static int | os_date (lua_State *L) |
static int | os_time (lua_State *L) |
static int | os_difftime (lua_State *L) |
static int | os_setlocale (lua_State *L) |
static int | os_exit (lua_State *L) |
LUALIB_API int | luaopen_os (lua_State *L) |
Variables | |
static const luaL_Reg | syslib [] |
static int getboolfield | ( | lua_State * | L, | |
const char * | key | |||
) | [static] |
Definition at line 100 of file loslib.c.
References lua_getfield(), lua_isnil, lua_pop, and lua_toboolean().
Referenced by os_time().
static int getfield | ( | lua_State * | L, | |
const char * | key, | |||
int | d | |||
) | [static] |
Definition at line 109 of file loslib.c.
References int(), lua_getfield(), lua_isnumber(), lua_pop, LUA_QS, lua_tointeger(), and luaL_error().
Referenced by os_time().
LUALIB_API int luaopen_os | ( | lua_State * | L | ) |
Definition at line 239 of file loslib.c.
References LUA_OSLIBNAME, and luaL_register().
static int os_clock | ( | lua_State * | L | ) | [static] |
Definition at line 74 of file loslib.c.
References lua_pushnumber().
static int os_date | ( | lua_State * | L | ) | [static] |
Definition at line 124 of file loslib.c.
References lua_createtable(), lua_pushnil(), luaL_addchar, luaL_addlstring(), luaL_buffinit(), luaL_checknumber(), luaL_opt, luaL_optstring, luaL_pushresult(), setboolfield(), and setfield().
static int os_difftime | ( | lua_State * | L | ) | [static] |
Definition at line 195 of file loslib.c.
References lua_pushnumber(), luaL_checknumber(), and luaL_optnumber().
static int os_execute | ( | lua_State * | L | ) | [static] |
Definition at line 38 of file loslib.c.
References lua_pushinteger(), and luaL_optstring.
static int os_exit | ( | lua_State * | L | ) | [static] |
Definition at line 216 of file loslib.c.
References luaL_optint.
static int os_getenv | ( | lua_State * | L | ) | [static] |
Definition at line 68 of file loslib.c.
References lua_pushstring(), and luaL_checkstring.
static int os_pushresult | ( | lua_State * | L, | |
int | i, | |||
const char * | filename | |||
) | [static] |
Definition at line 23 of file loslib.c.
References errno, lua_pushboolean(), lua_pushfstring(), lua_pushinteger(), and lua_pushnil().
Referenced by os_remove(), and os_rename().
static int os_remove | ( | lua_State * | L | ) | [static] |
Definition at line 44 of file loslib.c.
References luaL_checkstring, and os_pushresult().
static int os_rename | ( | lua_State * | L | ) | [static] |
Definition at line 50 of file loslib.c.
References luaL_checkstring, and os_pushresult().
static int os_setlocale | ( | lua_State * | L | ) | [static] |
Definition at line 204 of file loslib.c.
References lua_pushstring(), luaL_checkoption(), and luaL_optstring.
static int os_time | ( | lua_State * | L | ) | [static] |
Definition at line 170 of file loslib.c.
References getboolfield(), getfield(), lua_isnoneornil, lua_pushnil(), lua_pushnumber(), lua_settop(), LUA_TTABLE, and luaL_checktype().
static int os_tmpname | ( | lua_State * | L | ) | [static] |
Definition at line 57 of file loslib.c.
References lua_pushstring(), lua_tmpnam, LUA_TMPNAMBUFSIZE, and luaL_error().
static void setboolfield | ( | lua_State * | L, | |
const char * | key, | |||
int | value | |||
) | [static] |
Definition at line 93 of file loslib.c.
References lua_pushboolean(), and lua_setfield().
Referenced by os_date().
static void setfield | ( | lua_State * | L, | |
const char * | key, | |||
int | value | |||
) | [static] |
Definition at line 88 of file loslib.c.
References lua_pushinteger(), and lua_setfield().
Referenced by os_date().
{ {"clock", os_clock}, {"date", os_date}, {"difftime", os_difftime}, {"execute", os_execute}, {"exit", os_exit}, {"getenv", os_getenv}, {"remove", os_remove}, {"rename", os_rename}, {"setlocale", os_setlocale}, {"time", os_time}, {"tmpname", os_tmpname}, {NULL, NULL} }