#include "psensor_json.h"
#include "url.h"
-#include "p_io.h"
#include "server.h"
static const char *program_name;
#define DEFAULT_PORT 3131
-#define PAGE_NOT_FOUND (_("<html><body><p>\
-Page not found - Go to <a href='/'>Main page</a>\
-</p></body>"))
+#define PAGE_NOT_FOUND (_("<html><body><p>"\
+"Page not found - Go to <a href='/'>Main page</a></p></body>"))
static struct option long_options[] = {
{"version", no_argument, 0, 'v'},
void print_version()
{
printf("psensor-server %s\n", VERSION);
- printf(_("Copyright (C) %s jeanfi@gmail.com\n\
-License GPLv2: GNU GPL version 2 or later \
-<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>\n\
-This is free software: you are free to change and redistribute it.\n\
-There is NO WARRANTY, to the extent permitted by law.\n"),
+ printf(_("Copyright (C) %s jeanfi@gmail.com\n"
+ "License GPLv2: GNU GPL version 2 or later "
+ "<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>\n"
+ "This is free software: you are free to change and redistribute it.\n"
+ "There is NO WARRANTY, to the extent permitted by law.\n"),
"2010-2011");
}
puts("");
puts("Options:");
- puts(_("\
- -h, --help display this help and exit\n\
- -v, --version display version information and exit"));
+ puts(_(" -h, --help display this help and exit\n"
+ " -v, --version display version information and exit"));
puts("");
- puts(_("\
- -d,--debug run in debug mode\n\
- -p,--port=PORT webserver port\n\
- -w,--wdir=DIR directory containing webserver pages"));
+ puts(_(" -d,--debug run in debug mode\n"
+ " -p,--port=PORT webserver port\n"
+ " -w,--wdir=DIR directory containing webserver pages"));
puts("");
char *page = NULL;
if (!strcmp(nurl, URL_BASE_API_1_0_SENSORS)) {
-
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);
} else if (!strcmp(nurl, URL_API_1_0_CPU_USAGE)) {
page = sensor_to_json_string(server_data.cpu_usage);
textdomain(PACKAGE);
#endif
- server_data.www_dir = DEFAULT_WWW_DIR;
+ server_data.www_dir = NULL;
server_data.psysinfo.interfaces = NULL;
while ((optc = getopt_long(argc, argv,
}
}
+ server_data.www_dir = strdup(DEFAULT_WWW_DIR);
+
if (!cmdok || optind != argc) {
fprintf(stderr, _("Try `%s --help' for more information.\n"),
program_name);