static int server_stop_requested;
-void print_version()
+static void print_version()
{
printf("psensor-server %s\n", VERSION);
printf(_("Copyright (C) %s jeanfi@gmail.com\n"
"2010-2012");
}
-void print_help()
+static void print_help()
{
printf(_("Usage: %s [OPTION]...\n"), program_name);
puts(_(" -d, --debug=LEVEL "
"set the debug level, integer between 0 and 3"));
puts(_(" -l, --log-file=PATH set the log file to PATH"));
- puts(_(" -s, --sensor-log-file=PATH set the sensor log file to PATH"));
+ puts(_(" --sensor-log-file=PATH set the sensor log file to PATH"));
puts("");
printf(_("Report bugs to: %s\n"), PACKAGE_BUGREPORT);
}
/*
- Returns the file path corresponding to a given URL
-*/
-char *get_path(const char *url, const char *www_dir)
+ * Returns the file path corresponding to a given URL
+ */
+static char *get_path(const char *url, const char *www_dir)
{
const char *p;
char *res;
return fread(buf, 1, max, file);
}
-struct MHD_Response *
-create_response_api(const char *nurl,
- const char *method,
- unsigned int *rp_code)
+static struct MHD_Response *
+create_response_api(const char *nurl, const char *method, unsigned int *rp_code)
{
struct MHD_Response *resp;
struct psensor *s;
return NULL;
}
-struct MHD_Response *
-create_response_file(const char *nurl,
- const char *method,
- unsigned int *rp_code,
- const char *fpath)
+static struct MHD_Response *create_response_file(const char *nurl,
+ const char *method,
+ unsigned int *rp_code,
+ const char *fpath)
{
struct stat st;
int ret;
return NULL;
}
-struct MHD_Response *
+static struct MHD_Response *
create_response(const char *nurl, const char *method, unsigned int *rp_code)
{
struct MHD_Response *resp = NULL;
}
}
-static int
-cbk_http_request(void *cls,
- struct MHD_Connection *connection,
- const char *url,
- const char *method,
- const char *version,
- const char *upload_data,
- size_t *upload_data_size, void **ptr)
+static int cbk_http_request(void *cls,
+ struct MHD_Connection *connection,
+ const char *url,
+ const char *method,
+ const char *version,
+ const char *upload_data,
+ size_t *upload_data_size, void **ptr)
{
static int dummy;
struct MHD_Response *response;
int main(int argc, char *argv[])
{
struct MHD_Daemon *d;
- int port, opti, optc, cmdok;
+ int port, opti, optc, cmdok, ret;
char *log_file, *slog_file;
program_name = argv[0];
log_info(_("WWW directory: %s"), server_data.www_dir);
log_info(_("URL: http://localhost:%d"), port);
- if (slog_file)
- slog_init(slog_file, server_data.sensors);
+ if (slog_file) {
+ ret = slog_activate(slog_file, server_data.sensors, &mutex, 5);
+ if (!ret)
+ log_err(_("Failed to activate logging of sensors."));
+ }
while (!server_stop_requested) {
pthread_mutex_lock(&mutex);
psensor_log_measures(server_data.sensors);
- slog_write_sensors(server_data.sensors);
-
pthread_mutex_unlock(&mutex);
sleep(5);
}