You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.6 KiB
65 lines
1.6 KiB
#include <stdio.h>
|
|
#include <string.h>
|
|
#include "configuration.h"
|
|
#include "miniwebcam.h"
|
|
|
|
Configuration config;
|
|
|
|
/*
|
|
* Setup default values for all configuration options
|
|
*/
|
|
Configuration::Configuration() {
|
|
http_port = DEFAULT_HTTP_PORT;
|
|
https_port = DEFAULT_HTTPS_PORT;
|
|
runasdaemon = 0;
|
|
|
|
initflags = 0;
|
|
};
|
|
|
|
Configuration::~Configuration() {
|
|
};
|
|
|
|
|
|
/*
|
|
* print current configuration
|
|
*/
|
|
int Configuration::Print() {
|
|
printf ("#\n# default ports for http and https\n");
|
|
if (http_port == DEFAULT_HTTP_PORT) printf ("# ");
|
|
printf ("http_port %d\n", http_port);
|
|
if (https_port == DEFAULT_HTTPS_PORT) printf ("# ");
|
|
printf ("https_port %d\n", https_port);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int Configuration::LoadArgs(int argc, char **argv) {
|
|
for (int i = 1; i < argc; i++) {
|
|
if (strcmp(argv[i], "-F") == 0) runasdaemon = 0;
|
|
if (strcmp(argv[i], "-D") == 0) runasdaemon = 1;
|
|
|
|
if (strcmp(argv[i], "-dump_config") == 0) initflags |= CONF_INITFLAGS_PRINT;
|
|
if (strcmp(argv[i], "-h") == 0) initflags |= CONF_INITFLAGS_HELP;
|
|
|
|
if (strcmp(argv[i], "-http_port") == 0) {
|
|
if (++i < argc) {
|
|
}
|
|
else
|
|
ErrorExit("missing port parameter", -1);
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
void Configuration::Help() {
|
|
printf ("Parameters:\n");
|
|
printf (" -F run in foreground\n");
|
|
printf (" -D run as daemon\n");
|
|
printf ("\n");
|
|
printf (" -dump_config print the config file\n");
|
|
printf ("\n");
|
|
printf (" -H print this help\n");
|
|
}
|
|
|