diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2011-11-18 10:05:25 +0100 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2011-11-18 10:05:25 +0100 |
commit | afc386a40f8572b785a4b154b5be5789f260de07 (patch) | |
tree | 84d8e3d86702503f6b1cb21fac75aab78fe564ae /magic.c | |
parent | a4afecaeb9414535a4da21853c1de01c6d302728 (diff) | |
download | lua-file-magic-afc386a40f8572b785a4b154b5be5789f260de07.tar.bz2 lua-file-magic-afc386a40f8572b785a4b154b5be5789f260de07.tar.xz |
Implement magic_buffer()
Diffstat (limited to 'magic.c')
-rw-r--r-- | magic.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -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}, |