commit ef900f224c4afdc33e31ca39e95ae8d1ac9dfd3b
parent 3105febf9a6d79edfcd5cb50451cfa5a61016c76
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Fri, 11 Nov 2011 17:58:53 -0200
strutcture for file handles exported in 'lauxlib.h'
Diffstat:
2 files changed, 28 insertions(+), 7 deletions(-)
diff --git a/lauxlib.h b/lauxlib.h
@@ -1,5 +1,5 @@
/*
-** $Id: lauxlib.h,v 1.116 2011/04/08 19:17:36 roberto Exp roberto $
+** $Id: lauxlib.h,v 1.117 2011/06/16 14:10:12 roberto Exp roberto $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
@@ -163,6 +163,31 @@ LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz);
/* }====================================================== */
+
+/*
+** {======================================================
+** File handles for IO library
+** =======================================================
+*/
+
+/*
+** A file handle is a userdata with metatable 'LUA_FILEHANDLE' and
+** initial structure 'luaIO_Stream' (it may contain other fields
+** after that initial structure).
+*/
+
+#define LUA_FILEHANDLE "FILE*"
+
+
+typedef struct luaIO_Stream {
+ FILE *f; /* stream (NULL for incompletely created streams) */
+ lua_CFunction closef; /* to close stream (NULL for closed streams) */
+} luaIO_Stream;
+
+/* }====================================================== */
+
+
+
/* compatibility with old module system */
#if defined(LUA_COMPAT_MODULE)
diff --git a/liolib.c b/liolib.c
@@ -1,5 +1,5 @@
/*
-** $Id: liolib.c,v 2.104 2011/09/13 21:09:04 roberto Exp roberto $
+** $Id: liolib.c,v 2.105 2011/11/09 14:10:43 roberto Exp roberto $
** Standard I/O (and system) library
** See Copyright Notice in lua.h
*/
@@ -102,11 +102,7 @@
#define IO_OUTPUT (IO_PREFIX "output")
-typedef struct LStream {
- FILE *f; /* stream */
- lua_CFunction closef; /* to close stream (NULL for closed streams) */
-} LStream;
-
+typedef luaIO_Stream LStream;
#define tolstream(L) ((LStream *)luaL_checkudata(L, 1, LUA_FILEHANDLE))