uhttpd: add manifest support
[project/uhttpd.git] / lua.c
diff --git a/lua.c b/lua.c
index 55efaaa..3efe22b 100644 (file)
--- a/lua.c
+++ b/lua.c
@@ -144,7 +144,7 @@ static lua_State *uh_lua_state_init(void)
        lua_State *L;
        int ret;
 
-       L = lua_open();
+       L = luaL_newstate();
        luaL_openlibs(L);
 
        /* build uhttpd api table */
@@ -222,6 +222,10 @@ static void lua_main(struct client *cl, struct path_info *pi, char *url)
                        pi->query = str + 1;
                path_len = str - url;
        }
+
+       if (prefix_len > 0 && conf.lua_prefix[prefix_len - 1] == '/')
+               prefix_len--;
+
        if (path_len > prefix_len) {
                lua_pushlstring(L, url + prefix_len,
                                path_len - prefix_len);
@@ -255,7 +259,7 @@ static void lua_main(struct client *cl, struct path_info *pi, char *url)
 
                printf("Status: 500 Internal Server Error\r\n\r\n"
               "Unable to launch the requested Lua program:\n"
-              "  %s: %s\n", pi->phys, strerror(errno));
+              "  %s: %s\n", pi->phys, error);
        }
 
        exit(0);
@@ -295,6 +299,6 @@ static int lua_plugin_init(const struct uhttpd_ops *o, struct config *c)
        return 0;
 }
 
-const struct uhttpd_plugin uhttpd_plugin = {
+struct uhttpd_plugin uhttpd_plugin = {
        .init = lua_plugin_init,
 };