mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-24 20:21:49 +00:00
introduced short option names
This commit is contained in:
1 parent
bb21ffec12
commit
97f2155239
3 files changed
+20
-24
No files matched your search
@@ -91,29 +91,22 @@ static int mg_edit_passwords(const char *fname, const char *domain,
|
|||||||
|
|
||||||
static void show_usage_and_exit(void) {
|
static void show_usage_and_exit(void) {
|
||||||
const char **names;
|
const char **names;
|
||||||
int i, len;
|
int i;
|
||||||
|
|
||||||
fprintf(stderr, "Mongoose version %s (c) Sergey Lyubka\n", mg_version());
|
fprintf(stderr, "Mongoose version %s (c) Sergey Lyubka\n", mg_version());
|
||||||
fprintf(stderr, "Usage:\n");
|
fprintf(stderr, "Usage:\n");
|
||||||
fprintf(stderr, " mongoose -A <htpasswd_file> <realm> <user> <passwd>\n");
|
fprintf(stderr, " mongoose -A <htpasswd_file> <realm> <user> <passwd>\n");
|
||||||
fprintf(stderr, " mongoose <config_file>\n");
|
fprintf(stderr, " mongoose <config_file>\n");
|
||||||
fprintf(stderr, " mongoose [-option value ...]\n");
|
fprintf(stderr, " mongoose [-option value ...]\n");
|
||||||
fprintf(stderr, "OPTIONS:\n ");
|
fprintf(stderr, "OPTIONS:\n");
|
||||||
|
|
||||||
names = mg_get_valid_option_names();
|
names = mg_get_valid_option_names();
|
||||||
len = 2;
|
for (i = 0; names[i] != NULL; i += 2) {
|
||||||
for (i = 0; names[i] != NULL; i++) {
|
fprintf(stderr, " -%s %s\n", names[i], names[i + 1]);
|
||||||
len += strlen(names[i]) + 1;
|
|
||||||
if (len >= 80) {
|
|
||||||
len = strlen(names[i]) + 3;
|
|
||||||
fprintf(stderr, "%s", "\n ");
|
|
||||||
}
|
|
||||||
fprintf(stderr, "%s%c", names[i], names[i + 1] == NULL ? '\n' : ',');
|
|
||||||
}
|
}
|
||||||
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");
|
||||||
fprintf(stderr, "Example:\n mongoose -listening_ports 80,443s "
|
fprintf(stderr, "Example:\n mongoose -s cert.pem -p 80,443s -d no\n");
|
||||||
"-enable_directory_listing no\n");
|
|
||||||
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-11
@@ -352,17 +352,19 @@ enum {
|
|||||||
CGI_INTERPRETER, CGI_ENVIRONMENT, SSI_EXTENSIONS, AUTHENTICATION_DOMAIN,
|
CGI_INTERPRETER, CGI_ENVIRONMENT, SSI_EXTENSIONS, AUTHENTICATION_DOMAIN,
|
||||||
URI_PROTECTION, GLOBAL_PASSWORDS_FILE, PUT_DELETE_PASSWORDS_FILE,
|
URI_PROTECTION, GLOBAL_PASSWORDS_FILE, PUT_DELETE_PASSWORDS_FILE,
|
||||||
ACCESS_LOG_FILE, ERROR_LOG_FILE, ACCESS_CONTROL_LIST, RUN_AS_USER,
|
ACCESS_LOG_FILE, ERROR_LOG_FILE, ACCESS_CONTROL_LIST, RUN_AS_USER,
|
||||||
EXTRA_MIME_TYPES, ENABLE_DIRECTORY_LISTING, ENABLE_KEEP_ALIVE, NUM_THREADS,
|
EXTRA_MIME_TYPES, ENABLE_DIRECTORY_LISTING, NUM_THREADS,
|
||||||
NUM_OPTIONS
|
NUM_OPTIONS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// There are two entries for each option: a short and a long version.
|
||||||
static const char *option_names[] = {
|
static const char *option_names[] = {
|
||||||
"document_root", "listening_ports", "index_files", "ssl_certificate",
|
"r", "document_root", "p", "listening_ports", "i", "index_files",
|
||||||
"cgi_extensions", "cgi_interpreter", "cgi_environment", "ssi_extensions",
|
"s", "ssl_certificate", "C", "cgi_extensions", "I", "cgi_interpreter",
|
||||||
"authentication_domain", "protect_uri", "global_passwords_file",
|
"E", "cgi_environment", "S", "ssi_extensions", "R", "authentication_domain",
|
||||||
"put_delete_passwords_file", "access_log_file", "error_log_file",
|
"P", "protect_uri", "g", "global_passwords_file",
|
||||||
"access_control_list", "run_as_user", "extra_mime_types",
|
"G", "put_delete_passwords_file", "a", "access_log_file",
|
||||||
"enable_directory_listing", "enable_keep_alive", "num_threads",
|
"e", "error_log_file", "l", "access_control_list", "u", "run_as_user",
|
||||||
|
"m", "extra_mime_types", "d", "enable_directory_listing", "t", "num_threads",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -410,9 +412,10 @@ static void *call_user(struct mg_connection *conn, enum mg_event event) {
|
|||||||
|
|
||||||
static int get_option_index(const char *name) {
|
static int get_option_index(const char *name) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; option_names[i] != NULL; i++) {
|
for (i = 0; option_names[i] != NULL; i += 2) {
|
||||||
if (strcmp(option_names[i], name) == 0) {
|
if (strcmp(option_names[i], name) == 0 ||
|
||||||
return i;
|
strcmp(option_names[i + 1], name) == 0) {
|
||||||
|
return i / 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@@ -3788,7 +3791,6 @@ struct mg_context *mg_start(mg_callback_t user_callback, const char **options) {
|
|||||||
ctx->config[DOCUMENT_ROOT] = mg_strdup(".");
|
ctx->config[DOCUMENT_ROOT] = mg_strdup(".");
|
||||||
ctx->config[LISTENING_PORTS] = mg_strdup("8080");
|
ctx->config[LISTENING_PORTS] = mg_strdup("8080");
|
||||||
ctx->config[ENABLE_DIRECTORY_LISTING] = mg_strdup("yes");
|
ctx->config[ENABLE_DIRECTORY_LISTING] = mg_strdup("yes");
|
||||||
ctx->config[ENABLE_KEEP_ALIVE] = mg_strdup("no");
|
|
||||||
ctx->config[AUTHENTICATION_DOMAIN] = mg_strdup("mydomain.com");
|
ctx->config[AUTHENTICATION_DOMAIN] = mg_strdup("mydomain.com");
|
||||||
ctx->config[INDEX_FILES] = mg_strdup("index.html,index.htm,index.cgi");
|
ctx->config[INDEX_FILES] = mg_strdup("index.html,index.htm,index.cgi");
|
||||||
ctx->config[CGI_EXTENSIONS] = mg_strdup(".cgi,.pl,.php");
|
ctx->config[CGI_EXTENSIONS] = mg_strdup(".cgi,.pl,.php");
|
||||||
|
|||||||
+2
-1
@@ -118,7 +118,8 @@ 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.
|
// Return array of valid configuration options. For each option, a short
|
||||||
|
// version and a long version is returned. Array is NULL terminated.
|
||||||
const char **mg_get_valid_option_names(void);
|
const char **mg_get_valid_option_names(void);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user