Software /
code /
prosody
Comparison
util-src/pposix.c @ 860:048aaec22b57
Added missing code.
author | Tobias Markmann <tm@ayena.de> |
---|---|
date | Sun, 22 Feb 2009 20:55:06 +0100 |
parent | 859:43f7e342135d |
child | 861:2a5373897128 |
comparison
equal
deleted
inserted
replaced
859:43f7e342135d | 860:048aaec22b57 |
---|---|
360 lua_pushboolean(L, 1); | 360 lua_pushboolean(L, 1); |
361 return 1; | 361 return 1; |
362 } | 362 } |
363 | 363 |
364 int lc_getrlimit(lua_State *L) { | 364 int lc_getrlimit(lua_State *L) { |
365 return 0; | 365 int arguments = lua_gettop(L); |
366 const char *resource = NULL; | |
367 int rid = -1; | |
368 rlimit lim; | |
369 | |
370 if (arguments != 1) { | |
371 lua_pushboolean(L, 0); | |
372 lua_pushstring(L, "I expect one argument only, the resource string."); | |
373 return 2; | |
374 } | |
375 | |
376 resource = luaL_checkstring(L, 1); | |
377 rid = string2resource(resource); | |
378 if (rid != -1) { | |
379 if (getrlimit(rid, &lim)) { | |
380 lua_pushboolean(L, 0); | |
381 lua_pushstring(L, "getrlimit() failed."); | |
382 return 2; | |
383 } | |
384 } else { | |
385 lua_pushboolean(L, 0); | |
386 lua_pushstring(L, "Unsupported resoucrce. Sorry I'm pretty limited by POSIX standard."); | |
387 return 2; | |
388 } | |
389 lua_pushboolean(L, 1); | |
390 lua_pushnumber(L, lim.rlim_cur); | |
391 lua_pushnumber(L, lim.rlim_max); | |
392 return 3; | |
366 } | 393 } |
367 | 394 |
368 /* Register functions */ | 395 /* Register functions */ |
369 | 396 |
370 int luaopen_util_pposix(lua_State *L) | 397 int luaopen_util_pposix(lua_State *L) |