2
0
Fork 0

[lua] export path_simplify

personal/stbuehler/wip
Stefan Bühler 2010-02-13 22:44:47 +01:00
parent 0a46134334
commit f43f70de6e
1 changed files with 22 additions and 0 deletions

View File

@ -211,6 +211,25 @@ static int li_lua_sha256(lua_State *L) {
return 1;
}
static int li_lua_path_simplify(lua_State *L) {
const char *s;
size_t len;
GString *str;
s = lua_tolstring(L, 1, &len);
if (!s) return 0;
str = g_string_new_len(s, len);
li_path_simplify(str);
lua_pushlstring(L, GSTR_LEN(str));
g_string_free(str, TRUE);
return 1;
}
static void lua_push_constants(lua_State *L, int ndx) {
lua_pushinteger(L, LI_HANDLER_GO_ON);
lua_setfield(L, ndx, "HANDLER_GO_ON");
@ -270,6 +289,9 @@ void li_lua_init(lua_State *L, liServer *srv, liWorker *wrk) {
lua_pushcclosure(L, li_lua_sha256, 0);
lua_setfield(L, -2, "sha256");
lua_pushcclosure(L, li_lua_path_simplify, 0);
lua_setfield(L, -2, "path_simplify");
lua_push_constants(L, -2);
lua_setfield(L, LUA_GLOBALSINDEX, "lighty");