aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2009-02-22 20:55:06 +0100
committerTobias Markmann <tm@ayena.de>2009-02-22 20:55:06 +0100
commit70e434d50562f3bb32dfc9fb06d6a4157419486d (patch)
tree0af4bf17793f65bda57de9cdc981ce35cf0e8a6c
parent57ad1b3a49b136dd282627b0fa68b987ee35ec7f (diff)
downloadprosody-70e434d50562f3bb32dfc9fb06d6a4157419486d.tar.gz
prosody-70e434d50562f3bb32dfc9fb06d6a4157419486d.zip
Added missing code.
-rw-r--r--util-src/pposix.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/util-src/pposix.c b/util-src/pposix.c
index 15ad8641..fc97b853 100644
--- a/util-src/pposix.c
+++ b/util-src/pposix.c
@@ -362,7 +362,34 @@ int lc_setrlimit(lua_State *L) {
}
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 */