# liolib.c File Reference

`#include <errno.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include "lua.h"`
`#include "lauxlib.h"`
`#include "lualib.h"`

## 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

#define IO_OUTPUT 2

#define liolib_c

#define LUA_LIB

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

## Function Documentation

static int aux_close | ( | lua_State * | L | ) | `[static]`

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

static void createmeta | ( | lua_State * | L | ) | `[static]`

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

static int f_flush | ( | lua_State * | L | ) | `[static]`

static int f_lines | ( | lua_State * | L | ) | `[static]`

static int f_read | ( | lua_State * | L | ) | `[static]`

static int f_seek | ( | lua_State * | L | ) | `[static]`

static int f_setvbuf | ( | lua_State * | L | ) | `[static]`

static int f_write | ( | lua_State * | L | ) | `[static]`

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

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]`

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

static int io_close | ( | lua_State * | L | ) | `[static]`

static int io_fclose | ( | lua_State * | L | ) | `[static]`

static int io_flush | ( | lua_State * | L | ) | `[static]`

static int io_gc | ( | lua_State * | L | ) | `[static]`

static int io_input | ( | lua_State * | L | ) | `[static]`

static int io_lines | ( | lua_State * | L | ) | `[static]`

static int io_noclose | ( | lua_State * | L | ) | `[static]`

static int io_open | ( | lua_State * | L | ) | `[static]`

static int io_output | ( | lua_State * | L | ) | `[static]`

static int io_pclose | ( | lua_State * | L | ) | `[static]`

static int io_popen | ( | lua_State * | L | ) | `[static]`

static int io_read | ( | lua_State * | L | ) | `[static]`

static int io_readline | ( | lua_State * | L | ) | `[static]`

static int io_tmpfile | ( | lua_State * | L | ) | `[static]`

static int io_tostring | ( | lua_State * | L | ) | `[static]`

static int io_type | ( | lua_State * | L | ) | `[static]`

static int io_write | ( | lua_State * | L | ) | `[static]`

LUALIB_API int luaopen_io | ( | lua_State * | L | ) |

static void newfenv | ( | lua_State * | L,
|  | lua_CFunction | cls |
| ) |  |  | `[static]`

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]`

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

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

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

static FILE* tofile | ( | lua_State * | L | ) | `[static]`

## 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}
    }

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

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}
    }