mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-18 19:31:02 +00:00
Add -S option
This commit is contained in:
1 parent
574c2954b3
commit
9e0f04dc8b
1 file changed
+7
-2
@@ -8,6 +8,7 @@ static const char *s_debug_level = "2";
|
|||||||
static const char *s_root_dir = "."; // Attention: avoid double-dots, `..` !
|
static const char *s_root_dir = "."; // Attention: avoid double-dots, `..` !
|
||||||
static const char *s_listening_address = "http://localhost:8000";
|
static const char *s_listening_address = "http://localhost:8000";
|
||||||
static const char *s_enable_hexdump = "no";
|
static const char *s_enable_hexdump = "no";
|
||||||
|
static const char *s_ssi_pattern = "#.html";
|
||||||
|
|
||||||
// Handle interrupts, like Ctrl-C
|
// Handle interrupts, like Ctrl-C
|
||||||
static int s_signo;
|
static int s_signo;
|
||||||
@@ -21,6 +22,7 @@ static void cb(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
|
|||||||
if (ev == MG_EV_HTTP_MSG) {
|
if (ev == MG_EV_HTTP_MSG) {
|
||||||
struct mg_http_serve_opts opts = {0};
|
struct mg_http_serve_opts opts = {0};
|
||||||
opts.root_dir = s_root_dir;
|
opts.root_dir = s_root_dir;
|
||||||
|
opts.ssi_pattern = s_ssi_pattern;
|
||||||
mg_http_serve_dir(c, ev_data, &opts);
|
mg_http_serve_dir(c, ev_data, &opts);
|
||||||
}
|
}
|
||||||
(void) fn_data;
|
(void) fn_data;
|
||||||
@@ -31,11 +33,12 @@ static void usage(const char *prog) {
|
|||||||
"Mongoose v.%s\n"
|
"Mongoose v.%s\n"
|
||||||
"Usage: %s OPTIONS\n"
|
"Usage: %s OPTIONS\n"
|
||||||
" -H yes|no - enable traffic hexdump, default: '%s'\n"
|
" -H yes|no - enable traffic hexdump, default: '%s'\n"
|
||||||
|
" -S PAT - SSI filename pattern, default: '%s'\n"
|
||||||
" -d DIR - directory to serve, default: '%s'\n"
|
" -d DIR - directory to serve, default: '%s'\n"
|
||||||
" -l ADDR - listening address, default: '%s'\n"
|
" -l ADDR - listening address, default: '%s'\n"
|
||||||
" -v LEVEL - debug level, from 0 to 4, default: '%s'\n",
|
" -v LEVEL - debug level, from 0 to 4, default: '%s'\n",
|
||||||
MG_VERSION, prog, s_enable_hexdump, s_root_dir, s_listening_address,
|
MG_VERSION, prog, s_enable_hexdump, s_ssi_pattern, s_root_dir,
|
||||||
s_debug_level);
|
s_listening_address, s_debug_level);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,6 +53,8 @@ int main(int argc, char *argv[]) {
|
|||||||
s_root_dir = argv[++i];
|
s_root_dir = argv[++i];
|
||||||
} else if (strcmp(argv[i], "-H") == 0) {
|
} else if (strcmp(argv[i], "-H") == 0) {
|
||||||
s_enable_hexdump = argv[++i];
|
s_enable_hexdump = argv[++i];
|
||||||
|
} else if (strcmp(argv[i], "-S") == 0) {
|
||||||
|
s_ssi_pattern = argv[++i];
|
||||||
} else if (strcmp(argv[i], "-l") == 0) {
|
} else if (strcmp(argv[i], "-l") == 0) {
|
||||||
s_listening_address = argv[++i];
|
s_listening_address = argv[++i];
|
||||||
} else if (strcmp(argv[i], "-v") == 0) {
|
} else if (strcmp(argv[i], "-v") == 0) {
|
||||||
|
|||||||
Reference in new issue
Block a user