]> code.citadel.org Git - citadel.git/blobdiff - webcit/webserver.c
* Brought over the newer string tokenizer from Citadel
[citadel.git] / webcit / webserver.c
index 5e1284eeafe8eecb918e7a603dc2728f00ff387a..266cd692998c77e3b88cf1700b943888fd38c329 100644 (file)
@@ -48,7 +48,7 @@ extern pthread_mutex_t SessionListMutex;
 extern pthread_key_t MyConKey;
 
 
-
+char *server_cookie = NULL;
 
 
 char *defaulthost = DEFAULT_HOST;
@@ -228,7 +228,7 @@ int main(int argc, char **argv)
        char tracefile[PATH_MAX];
 
        /* Parse command line */
-       while ((a = getopt(argc, argv, "hp:t:")) != EOF)
+       while ((a = getopt(argc, argv, "hp:t:c")) != EOF)
                switch (a) {
                case 'p':
                        port = atoi(optarg);
@@ -239,9 +239,22 @@ int main(int argc, char **argv)
                        freopen(tracefile, "w", stderr);
                        freopen(tracefile, "r", stdin);
                        break;
+               case 'c':
+                       server_cookie = malloc(SIZ);
+                       if (server_cookie != NULL) {
+                               strcpy(server_cookie, "Set-cookie: wcserver=");
+                               if (gethostname(
+                                  &server_cookie[strlen(server_cookie)],
+                                  200) != 0) {
+                                       fprintf(stderr, "gethostname: %s\n",
+                                               strerror(errno));
+                                       free(server_cookie);
+                               }
+                       }
+                       break;
                default:
                        fprintf(stderr, "usage: webserver [-p localport] "
-                               "[-t tracefile] "
+                               "[-t tracefile] [-c] "
                                "[remotehost [remoteport]]\n");
                        return 1;
                }
@@ -253,7 +266,7 @@ int main(int argc, char **argv)
        }
        /* Tell 'em who's in da house */
        fprintf(stderr, SERVER "\n"
-               "Copyright (C) 1996-2000\n"
+               "Copyright (C) 1996-2001\n"
                "This software is distributed under the terms of the GNU\n"
                "General Public License.  All other rights reserved.\n\n");
 
@@ -292,12 +305,12 @@ int main(int argc, char **argv)
 
 
        /* Start a few initial worker threads */
-       for (i=0; i<(INITIAL_WORKER_THREADS-1); ++i) {
+       for (i=0; i<(INITIAL_WORKER_THREADS); ++i) {
                spawn_another_worker_thread();
        }
 
-       /* now the original thread becomes an ordinary worker thread */
-       worker_entry();
+       /* now the original thread can go away. */
+       pthread_exit(NULL);
        return 0;
 }