summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--magic.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/magic.c b/magic.c
index c41b4ed..5642103 100644
--- a/magic.c
+++ b/magic.c
@@ -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},