The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Macros | Functions | Variables
loslib.cpp File Reference
#include <errno.h>
#include <locale.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
Include dependency graph for loslib.cpp:

Go to the source code of this file.

Macros

#define loslib_c
 
#define LUA_LIB
 
#define LUA_STRFTIMEOPTIONS   { "aAbBcdHIjmMpSUwWxXyYz%", "" }
 
#define LUA_TMPNAMBUFSIZE   L_tmpnam
 
#define lua_tmpnam(b, e)   { e = (tmpnam(b) == NULL); }
 
#define l_gmtime(t, r)   ((void)r, gmtime(t))
 
#define l_localtime(t, r)   ((void)r, localtime(t))
 

Functions

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 const char * checkoption (lua_State *L, const char *conv, char *buff)
 
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)
 
LUAMOD_API int luaopen_os (lua_State *L)
 

Variables

static const luaL_Reg syslib []
 

Macro Definition Documentation

#define l_gmtime (   t,
  r 
)    ((void)r, gmtime(t))

Definition at line 72 of file loslib.cpp.

Referenced by os_date().

#define l_localtime (   t,
  r 
)    ((void)r, localtime(t))

Definition at line 73 of file loslib.cpp.

Referenced by os_date().

#define loslib_c

Definition at line 13 of file loslib.cpp.

#define LUA_LIB

Definition at line 14 of file loslib.cpp.

#define LUA_STRFTIMEOPTIONS   { "aAbBcdHIjmMpSUwWxXyYz%", "" }

Definition at line 28 of file loslib.cpp.

Referenced by checkoption().

#define lua_tmpnam (   b,
  e 
)    { e = (tmpnam(b) == NULL); }

Definition at line 56 of file loslib.cpp.

Referenced by os_tmpname().

#define LUA_TMPNAMBUFSIZE   L_tmpnam

Definition at line 55 of file loslib.cpp.

Referenced by os_tmpname().

Function Documentation

static const char* checkoption ( lua_State L,
const char *  conv,
char *  buff 
)
static

Definition at line 170 of file loslib.cpp.

References i, lua_pushfstring(), LUA_STRFTIMEOPTIONS, luaL_argerror(), and preferences::options().

Referenced by os_date().

static int getboolfield ( lua_State L,
const char *  key 
)
static

Definition at line 147 of file loslib.cpp.

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 156 of file loslib.cpp.

References d, int(), lua_getfield(), lua_pop, LUA_QS, lua_tointegerx(), and luaL_error().

Referenced by os_time().

LUAMOD_API int luaopen_os ( lua_State L)

Definition at line 318 of file loslib.cpp.

References luaL_newlib.

Referenced by lua_kernel_base::lua_kernel_base().

static int os_clock ( lua_State L)
static

Definition at line 121 of file loslib.cpp.

References lua_pushnumber().

static int os_date ( lua_State L)
static
static int os_difftime ( lua_State L)
static

Definition at line 265 of file loslib.cpp.

References lua_pushnumber(), luaL_checknumber(), and luaL_optnumber().

static int os_execute ( lua_State L)
static

Definition at line 79 of file loslib.cpp.

References lua_pushboolean(), luaL_execresult(), and luaL_optstring.

static int os_exit ( lua_State L)
static

Definition at line 286 of file loslib.cpp.

References lua_close(), lua_isboolean, lua_toboolean(), and luaL_optint.

static int os_getenv ( lua_State L)
static

Definition at line 115 of file loslib.cpp.

References lua_pushstring(), and luaL_checkstring.

static int os_remove ( lua_State L)
static

Definition at line 91 of file loslib.cpp.

References luaL_checkstring, and luaL_fileresult().

static int os_rename ( lua_State L)
static

Definition at line 97 of file loslib.cpp.

References luaL_checkstring, and luaL_fileresult().

static int os_setlocale ( lua_State L)
static

Definition at line 274 of file loslib.cpp.

References lua_pushstring(), luaL_checkoption(), and luaL_optstring.

static int os_time ( lua_State L)
static
static int os_tmpname ( lua_State L)
static

Definition at line 104 of file loslib.cpp.

References lg::err(), lua_pushstring(), lua_tmpnam, LUA_TMPNAMBUFSIZE, and luaL_error().

static void setboolfield ( lua_State L,
const char *  key,
int  value 
)
static

Definition at line 140 of file loslib.cpp.

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 135 of file loslib.cpp.

References lua_pushinteger(), and lua_setfield().

Referenced by os_date().

Variable Documentation

const luaL_Reg syslib[]
static
Initial value:
= {
{"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}
}
static int os_time(lua_State *L)
Definition: loslib.cpp:240
static int os_execute(lua_State *L)
Definition: loslib.cpp:79
static int os_tmpname(lua_State *L)
Definition: loslib.cpp:104
static int os_difftime(lua_State *L)
Definition: loslib.cpp:265
static int os_getenv(lua_State *L)
Definition: loslib.cpp:115
static int os_date(lua_State *L)
Definition: loslib.cpp:194
static int os_rename(lua_State *L)
Definition: loslib.cpp:97
static int os_exit(lua_State *L)
Definition: loslib.cpp:286
static int os_remove(lua_State *L)
Definition: loslib.cpp:91
static int os_clock(lua_State *L)
Definition: loslib.cpp:121
static int os_setlocale(lua_State *L)
Definition: loslib.cpp:274

Definition at line 299 of file loslib.cpp.