diff --git a/API.md b/API.md index 103c497..92b029d 100644 --- a/API.md +++ b/API.md @@ -2,6 +2,13 @@ ZMQ_CONSTANT_NAME in the C API turns into zmq.CONSTANT_NAME in Lua. +## version + +Reports 0MQ library version. +See [zmq_version[3]](http://api.zeromq.org/zmq_version.html). + +zmq.version() + ## init Initialises ØMQ context. diff --git a/zmq.c b/zmq.c index bd4ce90..05fb964 100644 --- a/zmq.c +++ b/zmq.c @@ -35,6 +35,29 @@ typedef struct { void *ptr; } zmq_ptr; +static int Lzmq_version(lua_State *L) +{ + int major, minor, patch; + + zmq_version(&major, &minor, &patch); + + lua_createtable(L, 3, 0); + + lua_pushinteger(L, 1); + lua_pushinteger(L, major); + lua_settable(L, -3); + + lua_pushinteger(L, 2); + lua_pushinteger(L, minor); + lua_settable(L, -3); + + lua_pushinteger(L, 3); + lua_pushinteger(L, patch); + lua_settable(L, -3); + + return 1; +} + static int Lzmq_init(lua_State *L) { int app_threads = luaL_checkint(L, 1); @@ -217,6 +240,7 @@ static int Lzmq_recv(lua_State *L) } static const luaL_reg zmqlib[] = { + {"version", Lzmq_version}, {"init", Lzmq_init}, {NULL, NULL} };