diff options
author | Aki <please@ignore.pl> | 2021-02-24 23:05:00 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2021-02-24 23:05:00 +0100 |
commit | ffc14c05b5260166050397cfa50bb88299febea0 (patch) | |
tree | 1db69ffc70154062935d1e86fa66c66fdbf08835 | |
parent | 5363bb572b05d0ae136c8db5fc8d9370ecff1d1d (diff) | |
download | plop-ffc14c05b5260166050397cfa50bb88299febea0.zip plop-ffc14c05b5260166050397cfa50bb88299febea0.tar.gz plop-ffc14c05b5260166050397cfa50bb88299febea0.tar.bz2 |
Added default HANDLER argument
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | main.c | 14 |
2 files changed, 10 insertions, 6 deletions
@@ -4,9 +4,11 @@ LDLIBS+=-llua5.3 PREFIX?=/usr/local SHARE?=$(PREFIX)/share +PLOP_DEFAULT_HANDLER?=$(SHARE)/plop/default.lua plop: connection.o main.o plop.o stream.o response.o +main.o: CFLAGS+=-DPLOP_DEFAULT_HANDLER=\"$(PLOP_DEFAULT_HANDLER)\" main.o: plop.h plop.o: connection.h plop.h stream.h connection.o: connection.h @@ -11,8 +11,9 @@ static void usage(const char * const name) { dprintf(2, - "Usage: %s [-p PORT] HANDLER\n" - "Starts plop server listening on PORT and serving HANDLER.\n\n" + "Usage: %s [-p PORT] [HANDLER]\n" + "Starts plop server listening on PORT and serving HANDLER.\n" + "HANDLER defaults to '" PLOP_DEFAULT_HANDLER "'.\n\n" " -p\tstart listening on PORT (default: 8080)\n", name); } @@ -43,10 +44,11 @@ int main(int argc, char ** argv) } } - if (optind >= argc) + const char * handler_path = PLOP_DEFAULT_HANDLER; + + if (optind < argc) { - usage(argv[0]); - return 8; + handler_path = argv[optind]; } lua_State * L = plop_initialize_lua(); @@ -56,7 +58,7 @@ int main(int argc, char ** argv) return 9; } - if (LUA_OK != plop_load_handler(L, argv[optind])) + if (LUA_OK != plop_load_handler(L, handler_path)) { return 2; } |