summaryrefslogtreecommitdiffstats
path: root/magic.c
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2011-11-18 10:17:33 +0100
committerNatanael Copa <ncopa@alpinelinux.org>2011-11-18 10:17:33 +0100
commit8d5f2af1495f8fcac4652d3939c859353c45498c (patch)
treeb80ebb14378ce2b4f73957b7bc2d2e3794f44428 /magic.c
parentafc386a40f8572b785a4b154b5be5789f260de07 (diff)
downloadlua-file-magic-8d5f2af1495f8fcac4652d3939c859353c45498c.tar.bz2
lua-file-magic-8d5f2af1495f8fcac4652d3939c859353c45498c.tar.xz
Implement magic_getpath
This function is not documented in libmagic(3) but it is available in magic.h
Diffstat (limited to 'magic.c')
-rw-r--r--magic.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/magic.c b/magic.c
index d138302..bf7e836 100644
--- a/magic.c
+++ b/magic.c
@@ -168,10 +168,20 @@ static int Pbuffer(lua_State *L)
return 1;
}
+static int Pgetpath(lua_State *L)
+{
+ // from file.h in 'file' sources
+ #define FILE_LOAD 0
+ const char *magicfile = luaL_optstring(L, 1, NULL);
+ lua_pushstring(L, magic_getpath(magicfile, FILE_LOAD));
+ return 1;
+ #undef FILE_LOAD
+}
+
static const luaL_reg Pmagic_methods[] = {
{"open", Popen},
{"close", Pclose},
- {"getpath", Ptodo},
+ {"getpath", Pgetpath},
{"file", Pfile},
{"descriptor", Pdescriptor},
{"buffer", Pbuffer},