summaryrefslogtreecommitdiffstats
path: root/magic.c
diff options
context:
space:
mode:
Diffstat (limited to 'magic.c')
-rw-r--r--magic.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/magic.c b/magic.c
index 7697773..2078717 100644
--- a/magic.c
+++ b/magic.c
@@ -151,12 +151,20 @@ static int Psetflags(lua_State *L)
}
}
+static int Pdescriptor(lua_State *L)
+{
+ magic_t m = Pmagic_checkarg(L, 1);
+ int fd = luaL_checknumber(L, 2);
+ lua_pushstring(L, magic_descriptor(m, fd));
+ return 1;
+}
+
static const luaL_reg Pmagic_methods[] = {
{"open", Popen},
{"close", Pclose},
{"getpath", Ptodo},
{"file", Pfile},
- {"descriptor", Ptodo},
+ {"descriptor", Pdescriptor},
{"buffer", Ptodo},
{"error", Perror},
{"setflags", Psetflags},