Software /
code /
prosody
Changeset
860:048aaec22b57
Added missing code.
author | Tobias Markmann <tm@ayena.de> |
---|---|
date | Sun, 22 Feb 2009 20:55:06 +0100 |
parents | 859:43f7e342135d |
children | 861:2a5373897128 |
files | util-src/pposix.c |
diffstat | 1 files changed, 28 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/util-src/pposix.c Sun Feb 22 20:35:41 2009 +0100 +++ b/util-src/pposix.c Sun Feb 22 20:55:06 2009 +0100 @@ -362,7 +362,34 @@ } int lc_getrlimit(lua_State *L) { - return 0; + int arguments = lua_gettop(L); + const char *resource = NULL; + int rid = -1; + rlimit lim; + + if (arguments != 1) { + lua_pushboolean(L, 0); + lua_pushstring(L, "I expect one argument only, the resource string."); + return 2; + } + + resource = luaL_checkstring(L, 1); + rid = string2resource(resource); + if (rid != -1) { + if (getrlimit(rid, &lim)) { + lua_pushboolean(L, 0); + lua_pushstring(L, "getrlimit() failed."); + return 2; + } + } else { + lua_pushboolean(L, 0); + lua_pushstring(L, "Unsupported resoucrce. Sorry I'm pretty limited by POSIX standard."); + return 2; + } + lua_pushboolean(L, 1); + lua_pushnumber(L, lim.rlim_cur); + lua_pushnumber(L, lim.rlim_max); + return 3; } /* Register functions */