aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormutantturkey <crazycal00@gmail.com>2011-01-02 12:27:49 -0500
committermutantturkey <crazycal00@gmail.com>2011-01-02 12:27:49 -0500
commit56671d969244928663cd0c99f890c668f12fc5e1 (patch)
treec868f4df4b8d2e9b58240bab879b7c82132c0804
parentd0040211935af2079bfc3d788cdd41036fa2e3a6 (diff)
--help added, defaulting to CWD when wwwroot not provided
-rw-r--r--CHANGELOG9
-rw-r--r--darkhttpd.c39
2 files changed, 31 insertions, 17 deletions
diff --git a/CHANGELOG b/CHANGELOG
new file mode 100644
index 0000000..f5de659
--- /dev/null
+++ b/CHANGELOG
@@ -0,0 +1,9 @@
+# changes made since fork
+
+01-01-2011: fork starts officially, shttpd is the decided name for "simple http daemon"
+01-02-2011: CHANGELOG: CHANGELOG created, format should be M-D-YEAR: MESSAGE
+01-02-2011: --help returns usage();
+01-02-2011: when used with no arguments defaults wwwroot directory the CWD
+
+
+
diff --git a/darkhttpd.c b/darkhttpd.c
index 7d4fd02..902df8c 100644
--- a/darkhttpd.c
+++ b/darkhttpd.c
@@ -977,7 +977,11 @@ static void usage(void)
"\t--pidfile filename (default: no pidfile)\n"
"\t\tWrite PID to the specified file. Note that if you are\n"
"\t\tusing --chroot, then the pidfile must be relative to,\n"
- "\t\tand inside the wwwroot.\n"
+ "\t\tand inside the wwwroot."
+ "\n");
+ printf(
+ "\t--help \n"
+ "\t\tprints this dialogue.\n"
"\n");
#ifdef __FreeBSD__
printf(
@@ -1012,24 +1016,25 @@ static void parse_commandline(const int argc, char *argv[])
{
int i;
- if ((argc < 2) || (argc == 2 && strcmp(argv[1], "--help") == 0))
- {
- usage(); /* no wwwroot given */
- exit(EXIT_FAILURE);
+
+ if(argc == 2 && strcmp(argv[1], "--help") == 0) {
+ usage();
+ exit(EXIT_FAILURE);
}
- if (strcmp(argv[1], "--version") == 0)
- {
- printf("%s "
-#ifdef NDEBUG
- "-debug"
-#else
- "+debug"
-#endif
- "\n", rcsid);
- exit(EXIT_FAILURE);
+ if (argc == 2 && strcmp(argv[1], "--version") == 0) {
+ printf("%s \n", rcsid);
+ exit(EXIT_FAILURE);
}
-
- wwwroot = xstrdup(argv[1]);
+
+ if (argc < 2) {
+ wwwroot = getcwd(NULL, PATH_MAX);
+ }
+ else {
+ wwwroot = xstrdup(argv[1]);
+ }
+
+ puts(wwwroot);
+
/* Strip ending slash. */
if (wwwroot[strlen(wwwroot)-1] == '/') wwwroot[strlen(wwwroot)-1] = '\0';