liolib.c File Reference

Go to the source code of this file.

Defines

#define liolib_c
#define LUA_LIB
#define IO_INPUT   1
#define IO_OUTPUT   2
#define tofilep(L)   ((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE))

Functions

static int pushresult (lua_State *L, int i, const char *filename)
static void fileerror (lua_State *L, int arg, const char *filename)
static int io_type (lua_State *L)
static FILE * tofile (lua_State *L)
static FILE ** newfile (lua_State *L)
static int io_noclose (lua_State *L)
static int io_pclose (lua_State *L)
static int io_fclose (lua_State *L)
static int aux_close (lua_State *L)
static int io_close (lua_State *L)
static int io_gc (lua_State *L)
static int io_tostring (lua_State *L)
static int io_open (lua_State *L)
static int io_popen (lua_State *L)
static int io_tmpfile (lua_State *L)
static FILE * getiofile (lua_State *L, int findex)
static int g_iofile (lua_State *L, int f, const char *mode)
static int io_input (lua_State *L)
static int io_output (lua_State *L)
static int io_readline (lua_State *L)
static void aux_lines (lua_State *L, int idx, int toclose)
static int f_lines (lua_State *L)
static int io_lines (lua_State *L)
static int read_number (lua_State *L, FILE *f)
static int test_eof (lua_State *L, FILE *f)
static int read_line (lua_State *L, FILE *f)
static int read_chars (lua_State *L, FILE *f, size_t n)
static int g_read (lua_State *L, FILE *f, int first)
static int io_read (lua_State *L)
static int f_read (lua_State *L)
static int g_write (lua_State *L, FILE *f, int arg)
static int io_write (lua_State *L)
static int f_write (lua_State *L)
static int f_seek (lua_State *L)
static int f_setvbuf (lua_State *L)
static int io_flush (lua_State *L)
static int f_flush (lua_State *L)
static void createmeta (lua_State *L)
static void createstdfile (lua_State *L, FILE *f, int k, const char *fname)
static void newfenv (lua_State *L, lua_CFunction cls)
LUALIB_API int luaopen_io (lua_State *L)

Variables

static const char *const fnames [] = {"input", "output"}
static const luaL_Reg iolib []
static const luaL_Reg flib []

Define Documentation

#define IO_INPUT   1

Definition at line 23 of file liolib.c.

Referenced by io_input(), io_lines(), io_read(), and luaopen_io().

#define IO_OUTPUT   2

Definition at line 24 of file liolib.c.

Referenced by io_close(), io_flush(), io_output(), io_write(), and luaopen_io().

#define liolib_c

Definition at line 13 of file liolib.c.

#define LUA_LIB

Definition at line 14 of file liolib.c.

#define tofilep (  )     ((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE))

Definition at line 54 of file liolib.c.

Referenced by io_fclose(), io_gc(), io_pclose(), io_tostring(), and tofile().


Function Documentation

static int aux_close ( lua_State L  )  [static]

Definition at line 127 of file liolib.c.

References lua_getfenv(), lua_getfield(), and lua_tocfunction().

Referenced by io_close(), io_gc(), and io_readline().

static void aux_lines ( lua_State L,
int  idx,
int  toclose 
) [static]

Definition at line 234 of file liolib.c.

References io_readline(), lua_pushboolean(), lua_pushcclosure(), and lua_pushvalue().

Referenced by f_lines(), and io_lines().

static void createmeta ( lua_State L  )  [static]

Definition at line 507 of file liolib.c.

References LUA_FILEHANDLE, lua_pushvalue(), lua_setfield(), luaL_newmetatable(), and luaL_register().

Referenced by luaopen_io().

static void createstdfile ( lua_State L,
FILE *  f,
int  k,
const char *  fname 
) [static]

Definition at line 515 of file liolib.c.

References LUA_ENVIRONINDEX, lua_pushvalue(), lua_rawseti(), lua_setfenv(), lua_setfield(), and newfile().

Referenced by luaopen_io().

static int f_flush ( lua_State L  )  [static]

Definition at line 472 of file liolib.c.

References pushresult(), and tofile().

static int f_lines ( lua_State L  )  [static]

Definition at line 241 of file liolib.c.

References aux_lines(), and tofile().

Referenced by io_lines().

static int f_read ( lua_State L  )  [static]

Definition at line 383 of file liolib.c.

References g_read(), and tofile().

static int f_seek ( lua_State L  )  [static]

Definition at line 439 of file liolib.c.

References f(), lua_pushinteger(), luaL_checkoption(), luaL_optlong, pushresult(), and tofile().

static int f_setvbuf ( lua_State L  )  [static]

Definition at line 455 of file liolib.c.

References f(), LUAL_BUFFERSIZE, luaL_checkoption(), luaL_optinteger(), pushresult(), and tofile().

static int f_write ( lua_State L  )  [static]

Definition at line 434 of file liolib.c.

References g_write(), and tofile().

static void fileerror ( lua_State L,
int  arg,
const char *  filename 
) [static]

Definition at line 48 of file liolib.c.

References lua_pushfstring(), lua_tostring, and luaL_argerror().

Referenced by g_iofile(), and io_lines().

static int g_iofile ( lua_State L,
int  f,
const char *  mode 
) [static]
static int g_read ( lua_State L,
FILE *  f,
int  first 
) [static]
static int g_write ( lua_State L,
FILE *  f,
int  arg 
) [static]

Definition at line 410 of file liolib.c.

References lua_gettop(), LUA_NUMBER_FMT, LUA_TNUMBER, lua_tonumber(), lua_type(), luaL_checklstring(), and pushresult().

Referenced by f_write(), and io_write().

static FILE* getiofile ( lua_State L,
int  findex 
) [static]

Definition at line 190 of file liolib.c.

References f(), fnames, LUA_ENVIRONINDEX, lua_rawgeti(), lua_touserdata(), and luaL_error().

Referenced by io_flush(), io_read(), and io_write().

static int io_close ( lua_State L  )  [static]

Definition at line 134 of file liolib.c.

References aux_close(), IO_OUTPUT, LUA_ENVIRONINDEX, lua_isnone, lua_rawgeti(), and tofile().

static int io_fclose ( lua_State L  )  [static]

Definition at line 119 of file liolib.c.

References pushresult(), and tofilep.

Referenced by luaopen_io().

static int io_flush ( lua_State L  )  [static]

Definition at line 467 of file liolib.c.

References getiofile(), IO_OUTPUT, and pushresult().

static int io_gc ( lua_State L  )  [static]

Definition at line 142 of file liolib.c.

References aux_close(), f(), and tofilep.

static int io_input ( lua_State L  )  [static]

Definition at line 221 of file liolib.c.

References g_iofile(), and IO_INPUT.

static int io_lines ( lua_State L  )  [static]
static int io_noclose ( lua_State L  )  [static]

Definition at line 98 of file liolib.c.

References lua_pushliteral, and lua_pushnil().

Referenced by luaopen_io().

static int io_open ( lua_State L  )  [static]

Definition at line 161 of file liolib.c.

References luaL_checkstring, luaL_optstring, newfile(), and pushresult().

static int io_output ( lua_State L  )  [static]

Definition at line 226 of file liolib.c.

References g_iofile(), and IO_OUTPUT.

static int io_pclose ( lua_State L  )  [static]

Definition at line 108 of file liolib.c.

References lua_pclose, pushresult(), and tofilep.

Referenced by luaopen_io().

static int io_popen ( lua_State L  )  [static]

Definition at line 174 of file liolib.c.

References lua_popen, luaL_checkstring, luaL_optstring, newfile(), and pushresult().

static int io_read ( lua_State L  )  [static]

Definition at line 378 of file liolib.c.

References g_read(), getiofile(), and IO_INPUT.

static int io_readline ( lua_State L  )  [static]
static int io_tmpfile ( lua_State L  )  [static]

Definition at line 183 of file liolib.c.

References newfile(), and pushresult().

static int io_tostring ( lua_State L  )  [static]

Definition at line 151 of file liolib.c.

References f(), lua_pushfstring(), lua_pushliteral, and tofilep.

static int io_type ( lua_State L  )  [static]
static int io_write ( lua_State L  )  [static]

Definition at line 429 of file liolib.c.

References g_write(), getiofile(), and IO_OUTPUT.

LUALIB_API int luaopen_io ( lua_State L  ) 
static void newfenv ( lua_State L,
lua_CFunction  cls 
) [static]

Definition at line 527 of file liolib.c.

References lua_createtable(), lua_pushcfunction, and lua_setfield().

Referenced by luaopen_io().

static FILE** newfile ( lua_State L  )  [static]
static int pushresult ( lua_State L,
int  i,
const char *  filename 
) [static]
static int read_chars ( lua_State L,
FILE *  f,
size_t  n 
) [static]

Definition at line 313 of file liolib.c.

References lua_objlen(), luaL_addsize, LUAL_BUFFERSIZE, luaL_buffinit(), luaL_prepbuffer(), and luaL_pushresult().

Referenced by g_read().

static int read_line ( lua_State L,
FILE *  f 
) [static]

Definition at line 291 of file liolib.c.

References lua_objlen(), luaL_addsize, LUAL_BUFFERSIZE, luaL_buffinit(), luaL_prepbuffer(), and luaL_pushresult().

Referenced by g_read(), and io_readline().

static int read_number ( lua_State L,
FILE *  f 
) [static]

Definition at line 273 of file liolib.c.

References d(), LUA_NUMBER_SCAN, and lua_pushnumber().

Referenced by g_read().

static int test_eof ( lua_State L,
FILE *  f 
) [static]

Definition at line 283 of file liolib.c.

References lua_pushlstring().

Referenced by g_read().

static FILE* tofile ( lua_State L  )  [static]

Definition at line 72 of file liolib.c.

References f(), luaL_error(), and tofilep.

Referenced by f_flush(), f_lines(), f_read(), f_seek(), f_setvbuf(), f_write(), g_iofile(), and io_close().


Variable Documentation

const luaL_Reg flib[] [static]
Initial value:
 {
  {"close", io_close},
  {"flush", f_flush},
  {"lines", f_lines},
  {"read", f_read},
  {"seek", f_seek},
  {"setvbuf", f_setvbuf},
  {"write", f_write},
  {"__gc", io_gc},
  {"__tostring", io_tostring},
  {NULL, NULL}
}

Definition at line 493 of file liolib.c.

const char* const fnames[] = {"input", "output"} [static]

Definition at line 27 of file liolib.c.

Referenced by getiofile().

const luaL_Reg iolib[] [static]
Initial value:
 {
  {"close", io_close},
  {"flush", io_flush},
  {"input", io_input},
  {"lines", io_lines},
  {"open", io_open},
  {"output", io_output},
  {"popen", io_popen},
  {"read", io_read},
  {"tmpfile", io_tmpfile},
  {"type", io_type},
  {"write", io_write},
  {NULL, NULL}
}

Definition at line 477 of file liolib.c.


ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:59 2011 by Doxygen 1.6.1