removed lua support, monitoring page is now using jquery and json http requests
[psensor.git] / src / server / server.c
index da6b709..a40ff0a 100644 (file)
 #include "sysinfo.h"
 #endif
 
-#ifdef HAVE_LUA
-#include "server_lua.h"
-#endif
-
 #include "psensor_json.h"
 #include "plib/url.h"
 #include "plib/plib_io.h"
@@ -113,19 +109,6 @@ void print_help()
 }
 
 /*
-  Returns '1' if the path denotates a Lua file, otherwise returns 0.
- */
-int is_path_lua(const char *path)
-{
-       char *dot = rindex(path, '.');
-
-       if (dot && !strcasecmp(dot, ".lua"))
-               return 1;
-
-       return 0;
-}
-
-/*
   Returns the file path corresponding to a given URL
 */
 char *get_path(const char *url, const char *www_dir)
@@ -134,7 +117,7 @@ char *get_path(const char *url, const char *www_dir)
        char *res;
 
        if (!strlen(url) || !strcmp(url, ".") || !strcmp(url, "/"))
-               p = "/index.lua";
+               p = "/index.html";
        else
                p = url;
 
@@ -168,6 +151,11 @@ create_response_api(const char *nurl,
 
                page = sensors_to_json_string(server_data.sensors);
 
+#ifdef HAVE_GTOP
+       } else if (!strcmp(nurl, URL_API_1_0_SYSINFO)) {
+
+               page = sysinfo_to_json_string(&server_data.psysinfo);
+#endif
        } else if (!strncmp(nurl, URL_BASE_API_1_0_SENSORS,
                            strlen(URL_BASE_API_1_0_SENSORS))
                   && nurl[strlen(URL_BASE_API_1_0_SENSORS)] == '/') {
@@ -191,32 +179,12 @@ create_response_api(const char *nurl,
 
                resp = MHD_create_response_from_data(strlen(page), page,
                                                     MHD_YES, MHD_NO);
-               
+
                MHD_add_response_header(resp, MHD_HTTP_HEADER_CONTENT_TYPE,
                                        "application/json");
-               
-               return resp;
-       }
 
-       return NULL;
-}
-
-struct MHD_Response *
-create_response_lua(const char *nurl,
-                   const char *method,
-                   unsigned int *rp_code,
-                   const char *fpath)
-{
-#ifdef HAVE_LUA
-       char *page = lua_to_html_page(&server_data, fpath);
-
-       if (page) {
-               *rp_code = MHD_HTTP_OK;
-
-               return MHD_create_response_from_data
-                       (strlen(page), page, MHD_YES, MHD_NO);
+               return resp;
        }
-#endif
 
        return NULL;
 }
@@ -265,12 +233,7 @@ create_response(const char *nurl, const char *method, unsigned int *rp_code)
        } else {
                char *fpath = get_path(nurl, server_data.www_dir);
 
-               if (is_path_lua(fpath))
-                       resp = create_response_lua
-                               (nurl, method, rp_code, fpath);
-               else
-                       resp = create_response_file
-                               (nurl, method, rp_code, fpath);
+               resp = create_response_file(nurl, method, rp_code, fpath);
 
                free(fpath);
        }
@@ -351,6 +314,7 @@ int main(int argc, char *argv[])
 #endif
 
        server_data.www_dir = DEFAULT_WWW_DIR;
+       server_data.psysinfo.interfaces = NULL;
 
        while ((optc = getopt_long(argc, argv,
                                   "vhp:w:d", long_options, NULL)) != -1) {