#include <errno.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include "lua.h"#include "lauxlib.h"#include "lualib.h"
Go to the source code of this file.
Defines | |
| #define | _FILE_OFFSET_BITS 64 |
| #define | liolib_c |
| #define | LUA_LIB |
| #define | lua_popen(L, c, m) |
| #define | lua_pclose(L, file) ((void)((void)L, file), -1) |
| #define | l_fseek(f, o, w) fseek(f,o,w) |
| #define | l_ftell(f) ftell(f) |
| #define | l_seeknum long |
| #define | IO_PREFIX "_IO_" |
| #define | IO_INPUT (IO_PREFIX "input") |
| #define | IO_OUTPUT (IO_PREFIX "output") |
| #define | tolstream(L) ((LStream *)luaL_checkudata(L, 1, LUA_FILEHANDLE)) |
| #define | isclosed(p) ((p)->closef == NULL) |
| #define | MAX_SIZE_T (~(size_t)0) |
Typedefs | |
| typedef luaL_Stream | LStream |
Functions | |
| static int | io_type (lua_State *L) |
| static int | f_tostring (lua_State *L) |
| static FILE * | tofile (lua_State *L) |
| static LStream * | newprefile (lua_State *L) |
| static int | aux_close (lua_State *L) |
| static int | io_close (lua_State *L) |
| static int | f_gc (lua_State *L) |
| static int | io_fclose (lua_State *L) |
| static LStream * | newfile (lua_State *L) |
| static void | opencheck (lua_State *L, const char *fname, const char *mode) |
| static int | io_open (lua_State *L) |
| static int | io_pclose (lua_State *L) |
| static int | io_popen (lua_State *L) |
| static int | io_tmpfile (lua_State *L) |
| static FILE * | getiofile (lua_State *L, const char *findex) |
| static int | g_iofile (lua_State *L, const char *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 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, int chop) |
| static void | read_all (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 int | io_noclose (lua_State *L) |
| static void | createstdfile (lua_State *L, FILE *f, const char *k, const char *fname) |
| LUAMOD_API int | luaopen_io (lua_State *L) |
Variables | |
| static const luaL_Reg | iolib [] |
| static const luaL_Reg | flib [] |
| #define IO_INPUT (IO_PREFIX "input") |
Definition at line 103 of file liolib.c.
Referenced by io_input(), io_lines(), io_read(), and luaopen_io().
| #define IO_OUTPUT (IO_PREFIX "output") |
Definition at line 104 of file liolib.c.
Referenced by io_close(), io_flush(), io_output(), io_write(), and luaopen_io().
| #define IO_PREFIX "_IO_" |
Definition at line 102 of file liolib.c.
Referenced by getiofile().
| #define isclosed | ( | p | ) | ((p)->closef == NULL) |
Definition at line 112 of file liolib.c.
Referenced by f_gc(), f_tostring(), getiofile(), io_readline(), io_type(), and tofile().
| #define lua_pclose | ( | L, | ||
| file | ||||
| ) | ((void)((void)L, file), -1) |
Definition at line 57 of file liolib.c.
Referenced by io_pclose().
| #define lua_popen | ( | L, | ||
| c, | ||||
| m | ||||
| ) |
((void)((void)c, m), \ luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0)
Definition at line 55 of file liolib.c.
Referenced by io_popen().
| #define MAX_SIZE_T (~(size_t)0) |
Definition at line 384 of file liolib.c.
Referenced by read_all().
| #define tolstream | ( | L | ) | ((LStream *)luaL_checkudata(L, 1, LUA_FILEHANDLE)) |
Definition at line 110 of file liolib.c.
Referenced by aux_close(), f_gc(), f_tostring(), io_fclose(), io_noclose(), io_pclose(), and tofile().
| typedef luaL_Stream LStream |
| static int aux_close | ( | lua_State * | L | ) | [static] |
Definition at line 161 of file liolib.c.
References luaL_Stream::closef, and tolstream.
Referenced by f_gc(), io_close(), and io_readline().

| static void aux_lines | ( | lua_State * | L, | |
| int | toclose | |||
| ) | [static] |
Definition at line 294 of file liolib.c.
References io_readline(), lua_gettop(), LUA_MINSTACK, lua_pushboolean(), lua_pushcclosure(), lua_pushinteger(), lua_pushvalue(), and luaL_argcheck.
Referenced by f_lines(), and io_lines().


| static void createmeta | ( | lua_State * | L | ) | [static] |
Definition at line 614 of file liolib.c.
References LUA_FILEHANDLE, lua_pop, lua_pushvalue(), lua_setfield(), luaL_newmetatable(), and luaL_setfuncs().
Referenced by luaopen_io().


| static void createstdfile | ( | lua_State * | L, | |
| FILE * | f, | |||
| const char * | k, | |||
| const char * | fname | |||
| ) | [static] |
Definition at line 635 of file liolib.c.
References luaL_Stream::closef, luaL_Stream::f, lua_pushvalue(), LUA_REGISTRYINDEX, lua_setfield(), and newprefile().
Referenced by luaopen_io().


| static int f_flush | ( | lua_State * | L | ) | [static] |
Definition at line 573 of file liolib.c.
References luaL_fileresult(), and tofile().

| static int f_gc | ( | lua_State * | L | ) | [static] |
Definition at line 177 of file liolib.c.
References aux_close(), luaL_Stream::f, isclosed, and tolstream.

| static int f_lines | ( | lua_State * | L | ) | [static] |
Definition at line 307 of file liolib.c.
References aux_lines(), and tofile().

| static int f_read | ( | lua_State * | L | ) | [static] |
| static int f_seek | ( | lua_State * | L | ) | [static] |
Definition at line 537 of file liolib.c.
References l_fseek, l_ftell, l_seeknum, lua_pushnumber(), luaL_argcheck, luaL_checkoption(), luaL_fileresult(), luaL_optnumber(), and tofile().

| static int f_setvbuf | ( | lua_State * | L | ) | [static] |
Definition at line 556 of file liolib.c.
References LUAL_BUFFERSIZE, luaL_checkoption(), luaL_fileresult(), luaL_optinteger(), and tofile().

| static int f_tostring | ( | lua_State * | L | ) | [static] |
Definition at line 129 of file liolib.c.
References luaL_Stream::f, isclosed, lua_pushfstring(), lua_pushliteral, and tolstream.

| static int f_write | ( | lua_State * | L | ) | [static] |
Definition at line 530 of file liolib.c.
References g_write(), lua_pushvalue(), and tofile().

| static int g_iofile | ( | lua_State * | L, | |
| const char * | f, | |||
| const char * | mode | |||
| ) | [static] |
Definition at line 264 of file liolib.c.
References lua_getfield(), lua_isnoneornil, lua_pushvalue(), LUA_REGISTRYINDEX, lua_setfield(), lua_tostring, opencheck(), and tofile().
Referenced by io_input(), and io_output().


| static int g_read | ( | lua_State * | L, | |
| FILE * | f, | |||
| int | first | |||
| ) | [static] |
Definition at line 415 of file liolib.c.
References lua_gettop(), LUA_MINSTACK, lua_pop, lua_pushnil(), LUA_TNUMBER, lua_tointeger, lua_tostring, lua_type(), luaL_argcheck, luaL_argerror(), luaL_checkstack(), luaL_fileresult(), read_all(), read_chars(), read_line(), read_number(), and test_eof().
Referenced by f_read(), io_read(), and io_readline().


| static int g_write | ( | lua_State * | L, | |
| FILE * | f, | |||
| int | arg | |||
| ) | [static] |
Definition at line 505 of file liolib.c.
References lua_gettop(), LUA_NUMBER_FMT, LUA_TNUMBER, lua_tonumber, lua_type(), luaL_checklstring(), and luaL_fileresult().
Referenced by f_write(), and io_write().


| static FILE* getiofile | ( | lua_State * | L, | |
| const char * | findex | |||
| ) | [static] |
Definition at line 254 of file liolib.c.
References luaL_Stream::f, IO_PREFIX, isclosed, lua_getfield(), LUA_REGISTRYINDEX, 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 169 of file liolib.c.
References aux_close(), IO_OUTPUT, lua_getfield(), lua_isnone, LUA_REGISTRYINDEX, and tofile().

| static int io_fclose | ( | lua_State * | L | ) | [static] |
Definition at line 188 of file liolib.c.
References luaL_Stream::f, luaL_fileresult(), and tolstream.

| static int io_flush | ( | lua_State * | L | ) | [static] |
Definition at line 568 of file liolib.c.
References getiofile(), IO_OUTPUT, and luaL_fileresult().

| static int io_input | ( | lua_State * | L | ) | [static] |
Definition at line 281 of file liolib.c.
References g_iofile(), and IO_INPUT.

| static int io_lines | ( | lua_State * | L | ) | [static] |
Definition at line 314 of file liolib.c.
References aux_lines(), IO_INPUT, lua_getfield(), lua_isnil, lua_isnone, lua_pushnil(), LUA_REGISTRYINDEX, lua_replace(), luaL_checkstring, opencheck(), and tofile().

| static int io_noclose | ( | lua_State * | L | ) | [static] |
Definition at line 626 of file liolib.c.
References luaL_Stream::closef, lua_pushliteral, lua_pushnil(), and tolstream.

| static int io_open | ( | lua_State * | L | ) | [static] |
Definition at line 211 of file liolib.c.
References luaL_Stream::f, LUA_QL, LUA_QS, luaL_checkstring, luaL_error(), luaL_fileresult(), luaL_optstring, and newfile().

| static int io_output | ( | lua_State * | L | ) | [static] |
Definition at line 286 of file liolib.c.
References g_iofile(), and IO_OUTPUT.

| static int io_pclose | ( | lua_State * | L | ) | [static] |
Definition at line 231 of file liolib.c.
References luaL_Stream::f, lua_pclose, luaL_execresult(), and tolstream.

| static int io_popen | ( | lua_State * | L | ) | [static] |
Definition at line 237 of file liolib.c.
References luaL_Stream::closef, luaL_Stream::f, lua_popen, luaL_checkstring, luaL_fileresult(), luaL_optstring, and newprefile().

| static int io_read | ( | lua_State * | L | ) | [static] |
Definition at line 465 of file liolib.c.
References g_read(), getiofile(), and IO_INPUT.

| static int io_readline | ( | lua_State * | L | ) | [static] |
Definition at line 475 of file liolib.c.
References aux_close(), luaL_Stream::f, g_read(), isclosed, lua_assert, lua_isnil, lua_pushvalue(), lua_settop(), lua_toboolean(), lua_tointeger, lua_tostring, lua_touserdata(), lua_upvalueindex, and luaL_error().
Referenced by aux_lines().


| static int io_tmpfile | ( | lua_State * | L | ) | [static] |
Definition at line 247 of file liolib.c.
References luaL_Stream::f, luaL_fileresult(), and newfile().

| static int io_type | ( | lua_State * | L | ) | [static] |
Definition at line 115 of file liolib.c.
References isclosed, LUA_FILEHANDLE, lua_pushliteral, lua_pushnil(), luaL_checkany(), and luaL_testudata().

| static int io_write | ( | lua_State * | L | ) | [static] |
Definition at line 525 of file liolib.c.
References g_write(), getiofile(), and IO_OUTPUT.

| LUAMOD_API int luaopen_io | ( | lua_State * | L | ) |
Definition at line 648 of file liolib.c.
References createmeta(), createstdfile(), IO_INPUT, IO_OUTPUT, and luaL_newlib.

Definition at line 195 of file liolib.c.
References luaL_Stream::closef, luaL_Stream::f, and newprefile().
Referenced by io_open(), io_tmpfile(), and opencheck().


Definition at line 153 of file liolib.c.
References luaL_Stream::closef, LUA_FILEHANDLE, lua_newuserdata(), and luaL_setmetatable().
Referenced by createstdfile(), io_popen(), and newfile().


| static void opencheck | ( | lua_State * | L, | |
| const char * | fname, | |||
| const char * | mode | |||
| ) | [static] |
Definition at line 203 of file liolib.c.
References luaL_Stream::f, LUA_QS, luaL_error(), and newfile().
Referenced by g_iofile(), and io_lines().


| static void read_all | ( | lua_State * | L, | |
| FILE * | f | |||
| ) | [static] |
Definition at line 386 of file liolib.c.
References luaL_addsize, luaL_buffinit(), luaL_prepbuffsize(), luaL_pushresult(), and MAX_SIZE_T.
Referenced by g_read().


| static int read_chars | ( | lua_State * | L, | |
| FILE * | f, | |||
| size_t | n | |||
| ) | [static] |
Definition at line 402 of file liolib.c.
References luaL_addsize, luaL_buffinit(), luaL_prepbuffsize(), and luaL_pushresult().
Referenced by g_read().


| static int read_line | ( | lua_State * | L, | |
| FILE * | f, | |||
| int | chop | |||
| ) | [static] |
Definition at line 362 of file liolib.c.
References lua_rawlen(), luaL_addsize, LUAL_BUFFERSIZE, luaL_buffinit(), luaL_prepbuffer, and luaL_pushresult().
Referenced by g_read().


| static int read_number | ( | lua_State * | L, | |
| FILE * | f | |||
| ) | [static] |
Definition at line 341 of file liolib.c.
References LUA_NUMBER_SCAN, lua_pushnil(), and lua_pushnumber().
Referenced by g_read().


| static int test_eof | ( | lua_State * | L, | |
| FILE * | f | |||
| ) | [static] |
Definition at line 354 of file liolib.c.
References lua_pushlstring().
Referenced by g_read().


| static FILE* tofile | ( | lua_State * | L | ) | [static] |
Definition at line 139 of file liolib.c.
References luaL_Stream::f, isclosed, lua_assert, luaL_error(), and tolstream.
Referenced by f_flush(), f_lines(), f_read(), f_seek(), f_setvbuf(), f_write(), g_iofile(), io_close(), and io_lines().


| Generated by doxygen 1.7.1 on Fri May 25 2012 01:07:09 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |