]> code.citadel.org Git - citadel.git/blobdiff - webcit/webserver.c
* crypto.c: keys/ directory is relative to the directory from which WebCit
[citadel.git] / webcit / webserver.c
index ef9733141e353d134f92d194f2c69dee5056965e..16dbef92438aa9eae7c8d3d3ebf4f6a0d3275edb 100644 (file)
@@ -7,10 +7,6 @@
  *
  */
 
-/*
- * Uncomment to dump an HTTP trace to stderr
-#define HTTP_TRACING 1
- */
 
 #include <ctype.h>
 #include <stdlib.h>
 #include "webcit.h"
 #include "webserver.h"
 
-#ifdef HAVE_ZLIB
-#include <zlib.h>
-#endif
-
 #ifndef HAVE_SNPRINTF
 int vsnprintf(char *buf, size_t max, const char *fmt, va_list argp);
 #endif
@@ -65,6 +57,8 @@ char *server_cookie = NULL;
 
 char *ctdlhost = DEFAULT_HOST;
 char *ctdlport = DEFAULT_PORT;
+int setup_wizard = 0;
+char wizard_filename[PATH_MAX];
 
 /*
  * This is a generic function to set up a master socket for listening on
@@ -289,7 +283,7 @@ void end_burst(void)
                if (compress_gzip((Bytef *) compressed_data,
                                  &compressed_len,
                                  (Bytef *) the_data,
-                                 (uLongf) the_len, 9) == Z_OK) {
+                                 (uLongf) the_len, Z_BEST_SPEED) == Z_OK) {
                        wprintf("Content-encoding: gzip\r\n");
                        free(the_data);
                        the_data = compressed_data;
@@ -414,22 +408,26 @@ int main(int argc, char **argv)
        int port = PORT_NUM;    /* Port to listen on */
        char tracefile[PATH_MAX];
        char ip_addr[256];
+       char *webcitdir = WEBCITDIR;
 
        /* Parse command line */
 #ifdef HAVE_OPENSSL
-       while ((a = getopt(argc, argv, "hi:p:t:cs")) != EOF)
+       while ((a = getopt(argc, argv, "h:i:p:t:x:cs")) != EOF)
 #else
-       while ((a = getopt(argc, argv, "hi:p:t:c")) != EOF)
+       while ((a = getopt(argc, argv, "h:i:p:t:x:c")) != EOF)
 #endif
                switch (a) {
+               case 'h':
+                       webcitdir = strdup(optarg);
+                       break;
                case 'i':
-                       strcpy(ip_addr, optarg);
+                       safestrncpy(ip_addr, optarg, sizeof ip_addr);
                        break;
                case 'p':
                        port = atoi(optarg);
                        break;
                case 't':
-                       strcpy(tracefile, optarg);
+                       safestrncpy(tracefile, optarg, sizeof tracefile);
                        freopen(tracefile, "w", stdout);
                        freopen(tracefile, "w", stderr);
                        freopen(tracefile, "r", stdin);
@@ -438,10 +436,11 @@ int main(int argc, char **argv)
                        verbosity = atoi(optarg);
                        break;
                case 'c':
-                       server_cookie = malloc(SIZ);
+                       server_cookie = malloc(256);
                        if (server_cookie != NULL) {
-                               strcpy(server_cookie,
-                                      "Set-cookie: wcserver=");
+                               safestrncpy(server_cookie,
+                                      "Set-cookie: wcserver=",
+                                       256);
                                if (gethostname
                                    (&server_cookie[strlen(server_cookie)],
                                     200) != 0) {
@@ -472,12 +471,15 @@ int main(int argc, char **argv)
        }
        /* Tell 'em who's in da house */
        lprintf(1, SERVER "\n"
-               "Copyright (C) 1996-2005 by the Citadel/UX development team.\n"
-               "This software is distributed under the terms of the GNU General Public\n"
-               "License.  If you paid for this software, someone is ripping you off.\n\n");
+               "Copyright (C) 1996-2005 by the Citadel development team.\n"
+               "This software is distributed under the terms of the "
+               "GNU General Public License.\n\n"
+       );
 
-       if (chdir(WEBCITDIR) != 0)
+       lprintf(9, "Changing directory to %s\n", webcitdir);
+       if (chdir(webcitdir) != 0) {
                perror("chdir");
+       }
 
        /*
         * Set up a place to put thread-specific data.