diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2011-11-17 15:46:47 +0100 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2011-11-17 15:46:47 +0100 |
commit | f51a53d36ec1fc90996b32e1da9cd25707536969 (patch) | |
tree | 6fb470427d1bb6f766e25e09ce301b2603e2d844 | |
parent | a93550134064b553e5e4a83606f14455301d8156 (diff) | |
download | lua-file-magic-f51a53d36ec1fc90996b32e1da9cd25707536969.tar.bz2 lua-file-magic-f51a53d36ec1fc90996b32e1da9cd25707536969.tar.xz |
Implement magic_file() and magic_error()
-rw-r--r-- | magic.c | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -96,14 +96,30 @@ static int Pclose(lua_State *L) return 0; } +static int Pfile(lua_State *L) +{ + magic_t m = Pmagic_checkarg(L, 1); + const char *filename = luaL_checkstring(L, 2); + + lua_pushstring(L, magic_file(m, filename)); + return 1; +} + +static int Perror(lua_State *L) +{ + magic_t m = Pmagic_checkarg(L, 1); + lua_pushstring(L, magic_error(m)); + return 1; +} + static const luaL_reg Pmagic_methods[] = { {"open", Popen}, {"close", Pclose}, {"getpath", Ptodo}, - {"file", Ptodo}, + {"file", Pfile}, {"descriptor", Ptodo}, {"buffer", Ptodo}, - {"error", Ptodo}, + {"error", Perror}, {"setflags", Ptodo}, {"load", Ptodo}, {"compile", Ptodo}, |