summaryrefslogtreecommitdiffstats
path: root/modules/lua/lua_apr.c
diff options
context:
space:
mode:
Diffstat (limited to 'modules/lua/lua_apr.c')
-rw-r--r--modules/lua/lua_apr.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/modules/lua/lua_apr.c b/modules/lua/lua_apr.c
index b744ea0900..c3b4fb753d 100644
--- a/modules/lua/lua_apr.c
+++ b/modules/lua/lua_apr.c
@@ -32,32 +32,36 @@
#endif
-apr_table_t* check_apr_table(lua_State* L, int index) {
+apr_table_t *check_apr_table(lua_State *L, int index)
+{
luaL_checkudata(L, index, "Apr.Table");
- apr_table_t* t = (apr_table_t*)lua_unboxpointer(L, index);
+ apr_table_t *t = (apr_table_t *) lua_unboxpointer(L, index);
return t;
}
-void apl_push_apr_table(lua_State* L, const char *name, apr_table_t *t) {
- lua_boxpointer(L, t);
+void apl_push_apr_table(lua_State *L, const char *name, apr_table_t *t)
+{
+ lua_boxpointer(L, t);
luaL_getmetatable(L, "Apr.Table");
lua_setmetatable(L, -2);
lua_setfield(L, -2, name);
}
-static int lua_table_set(lua_State* L) {
+static int lua_table_set(lua_State *L)
+{
apr_table_t *t = check_apr_table(L, 1);
- const char* key = luaL_checkstring(L, 2);
- const char* val = luaL_checkstring(L, 3);
+ const char *key = luaL_checkstring(L, 2);
+ const char *val = luaL_checkstring(L, 3);
apr_table_set(t, key, val);
return 0;
}
-static int lua_table_get(lua_State* L) {
+static int lua_table_get(lua_State *L)
+{
apr_table_t *t = check_apr_table(L, 1);
- const char* key = luaL_checkstring(L, 2);
+ const char *key = luaL_checkstring(L, 2);
const char *val = apr_table_get(t, key);
lua_pushstring(L, val);
return 1;
@@ -70,7 +74,8 @@ static const luaL_reg lua_table_methods[] = {
};
-int apr_lua_init(lua_State *L, apr_pool_t *p) {
+int apr_lua_init(lua_State *L, apr_pool_t *p)
+{
luaL_newmetatable(L, "Apr.Table");
luaL_openlib(L, "apr_table", lua_table_methods, 0);
lua_pushstring(L, "__index");
@@ -82,7 +87,6 @@ int apr_lua_init(lua_State *L, apr_pool_t *p) {
lua_pushstring(L, "set");
lua_gettable(L, 2);
lua_settable(L, 1);
-
+
return 0;
}
-