Commit f105b74d authored by valenok's avatar valenok

experimental keep-alive, options defaults

parent fed9ffc1
...@@ -103,8 +103,9 @@ static void show_usage_and_exit(void) { ...@@ -103,8 +103,9 @@ static void show_usage_and_exit(void) {
fprintf(stderr, "OPTIONS:\n"); fprintf(stderr, "OPTIONS:\n");
names = mg_get_valid_option_names(); names = mg_get_valid_option_names();
for (i = 0; names[i] != NULL; i += 2) { for (i = 0; names[i] != NULL; i += 3) {
fprintf(stderr, " -%s %s\n", names[i], names[i + 1]); fprintf(stderr, " -%s %s (default: \"%s\")\n",
names[i], names[i + 1], names[i + 2] == NULL ? "" : names[i + 2]);
} }
fprintf(stderr, "See http://code.google.com/p/mongoose/wiki/MongooseManual" fprintf(stderr, "See http://code.google.com/p/mongoose/wiki/MongooseManual"
" for more details.\n"); " for more details.\n");
...@@ -164,6 +165,7 @@ static void process_command_line_arguments(char *argv[], char **options) { ...@@ -164,6 +165,7 @@ static void process_command_line_arguments(char *argv[], char **options) {
const char *config_file = NULL; const char *config_file = NULL;
char line[512], opt[512], val[512], path[PATH_MAX], *p; char line[512], opt[512], val[512], path[PATH_MAX], *p;
FILE *fp = NULL; FILE *fp = NULL;
struct stat st;
size_t i, line_no = 0; size_t i, line_no = 0;
/* Should we use a config file ? */ /* Should we use a config file ? */
...@@ -175,6 +177,9 @@ static void process_command_line_arguments(char *argv[], char **options) { ...@@ -175,6 +177,9 @@ static void process_command_line_arguments(char *argv[], char **options) {
snprintf(path, sizeof(path), "%.*s%s", snprintf(path, sizeof(path), "%.*s%s",
(int) (p - argv[0]) + 1, argv[0], CONFIG_FILE); (int) (p - argv[0]) + 1, argv[0], CONFIG_FILE);
} }
if (stat(path, &st) == 0) {
config_file = path;
}
} }
/* If config file was set in command line and open failed, exit */ /* If config file was set in command line and open failed, exit */
if (config_file != NULL && (fp = fopen(config_file, "r")) == NULL) { if (config_file != NULL && (fp = fopen(config_file, "r")) == NULL) {
......
This diff is collapsed.
...@@ -118,8 +118,9 @@ void mg_stop(struct mg_context *); ...@@ -118,8 +118,9 @@ void mg_stop(struct mg_context *);
const char *mg_get_option(const struct mg_context *ctx, const char *name); const char *mg_get_option(const struct mg_context *ctx, const char *name);
// Return array of valid configuration options. For each option, a short // Return array of strings that represent valid configuration options.
// version and a long version is returned. Array is NULL terminated. // For each option, a short name, long name, and default value is returned.
// Array is NULL terminated.
const char **mg_get_valid_option_names(void); const char **mg_get_valid_option_names(void);
......
...@@ -211,6 +211,9 @@ o("GET /$test_dir_uri/x/ HTTP/1.0\n\n", "Content-Type: text/html\r\n\r\n", ...@@ -211,6 +211,9 @@ o("GET /$test_dir_uri/x/ HTTP/1.0\n\n", "Content-Type: text/html\r\n\r\n",
'index.cgi execution'); 'index.cgi execution');
o("GET /ta/x/ HTTP/1.0\n\n", "SCRIPT_NAME=/ta/x/index.cgi", o("GET /ta/x/ HTTP/1.0\n\n", "SCRIPT_NAME=/ta/x/index.cgi",
'Aliases SCRIPT_NAME'); 'Aliases SCRIPT_NAME');
#o("GET /hello.txt HTTP/1.1\n\n GET /hello.txt HTTP/1.0\n\n",
# 'HTTP/1.1 200.+keep-alive.+HTTP/1.1 200.+close',
# 'Request pipelining', 2);
my $mime_types = { my $mime_types = {
html => 'text/html', html => 'text/html',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment