added command line interface

This commit is contained in:
Anselm R Garbe 2010-03-28 02:14:01 +00:00
parent a20243ea7c
commit 3e45a7c0ba
2 changed files with 43 additions and 11 deletions

View file

@ -1,14 +1,14 @@
/* quark configuration */
static const char servername[] = "192.168.1.66";
static const char serverport[] = "80";
static const char docroot[] = ".";
static const char docindex[] = "index.html";
static const char user[] = "nobody";
static const char group[] = "nobody";
static const char cgi_dir[] = "/var/www/werc-dev/bin";
static const char cgi_script[] = "./werc.rc";
static const int cgi_mode = 0;
static char *servername = "127.0.0.1";
static char *serverport = "80";
static char *docroot = ".";
static char *docindex = "index.html";
static char *user = "nobody";
static char *group = "nobody";
static char *cgi_dir = "/var/www/werc-dev/bin";
static char *cgi_script = "./werc.rc";
static int cgi_mode = 0;
static const MimeType servermimes[] = {
{ "html", "text/html; charset=UTF-8" },

36
quark.c
View file

@ -459,10 +459,42 @@ main(int argc, char *argv[]) {
/* arguments */
for(i = 1; i < argc; i++)
if(!strcmp(argv[i], "-v"))
if(!strcmp(argv[i], "-n")) {
if(++i < argc) servername = argv[i];
}
else if(!strcmp(argv[i], "-p")) {
if(++i < argc) serverport = argv[i];
}
else if(!strcmp(argv[i], "-r")) {
if(++i < argc) docroot = argv[i];
}
else if(!strcmp(argv[i], "-i")) {
if(++i < argc) docindex = argv[i];
}
else if(!strcmp(argv[i], "-u")) {
if(++i < argc) user = argv[i];
}
else if(!strcmp(argv[i], "-g")) {
if(++i < argc) group = argv[i];
}
else if(!strcmp(argv[i], "-c")) {
if(++i < argc) cgi_dir = argv[i];
if(++i < argc) {
cgi_script = argv[i];
cgi_mode = 1;
}
}
else if(!strcmp(argv[i], "-v"))
die("quark-"VERSION", © 2009-2010 Anselm R Garbe\n");
else
die("usage: quark [-v]\n");
die("usage: quark [-n <server-name>]\n"
" [-p <port>]\n"
" [-r <doc root>]\n"
" [-i <doc index>]\n"
" [-u <user>]\n"
" [-g <group>]\n"
" [-c <cgi dir> <cgi script>]\n"
" [-v]\n");
/* sanity checks */
if(!(upwd = getpwnam(user)))