summaryrefslogtreecommitdiffstats
path: root/magic.c
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2011-11-18 10:05:25 +0100
committerNatanael Copa <ncopa@alpinelinux.org>2011-11-18 10:05:25 +0100
commitafc386a40f8572b785a4b154b5be5789f260de07 (patch)
tree84d8e3d86702503f6b1cb21fac75aab78fe564ae /magic.c
parenta4afecaeb9414535a4da21853c1de01c6d302728 (diff)
downloadlua-file-magic-afc386a40f8572b785a4b154b5be5789f260de07.tar.bz2
lua-file-magic-afc386a40f8572b785a4b154b5be5789f260de07.tar.xz
Implement magic_buffer()
Diffstat (limited to 'magic.c')
-rw-r--r--magic.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/magic.c b/magic.c
index 2078717..d138302 100644
--- a/magic.c
+++ b/magic.c
@@ -159,13 +159,22 @@ static int Pdescriptor(lua_State *L)
return 1;
}
+static int Pbuffer(lua_State *L)
+{
+ size_t size;
+ magic_t m = Pmagic_checkarg(L, 1);
+ const char *buf = luaL_checklstring(L, 2, &size);
+ lua_pushstring(L, magic_buffer(m, buf, size));
+ return 1;
+}
+
static const luaL_reg Pmagic_methods[] = {
{"open", Popen},
{"close", Pclose},
{"getpath", Ptodo},
{"file", Pfile},
{"descriptor", Pdescriptor},
- {"buffer", Ptodo},
+ {"buffer", Pbuffer},
{"error", Perror},
{"setflags", Psetflags},
{"load", Pload},