[hackers] [quark] added command line interface || Anselm R Garbe

From: <hg_AT_suckless.org>
Date: Sun, 28 Mar 2010 02:14:34 +0000 (UTC)

changeset: 11:b6fe0a07d535
tag: tip
user: Anselm R Garbe <anselm_AT_garbe.us>
date: Sun Mar 28 02:14:01 2010 +0000
files: config.def.h quark.c
description:
added command line interface

diff -r a248f92acca2 -r b6fe0a07d535 config.def.h
--- a/config.def.h Sun Mar 28 01:57:44 2010 +0000
+++ b/config.def.h Sun Mar 28 02:14:01 2010 +0000
@@ -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" },
diff -r a248f92acca2 -r b6fe0a07d535 quark.c
--- a/quark.c Sun Mar 28 01:57:44 2010 +0000
+++ b/quark.c Sun Mar 28 02:14:01 2010 +0000
@@ -459,10 +459,42 @@
 
         /* 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)))
Received on Sun Mar 28 2010 - 02:14:34 UTC

This archive was generated by hypermail 2.2.0 : Sun Mar 28 2010 - 02:24:09 UTC