- struct sockaddr_in fsin; /* Data for master socket */
- int alen; /* Data for master socket */
- int ssock; /* Descriptor for master socket */
- pthread_t SessThread; /* Thread descriptor */
- pthread_attr_t attr; /* Thread attributes */
- int a, i; /* General-purpose variables */
- char convbuf[128];
-
+ pthread_t SessThread; /* Thread descriptor */
+ pthread_attr_t attr; /* Thread attributes */
+ int a, i; /* General-purpose variables */
+ int port = PORT_NUM; /* Port to listen on */
+ char tracefile[PATH_MAX];
+
+ /* Parse command line */
+#ifdef HAVE_OPENSSL
+ while ((a = getopt(argc, argv, "hp:t:cs")) != EOF)
+#else
+ while ((a = getopt(argc, argv, "hp:t:c")) != EOF)
+#endif
+ switch (a) {
+ case 'p':
+ port = atoi(optarg);
+ break;
+ case 't':
+ strcpy(tracefile, optarg);
+ freopen(tracefile, "w", stdout);
+ freopen(tracefile, "w", stderr);
+ freopen(tracefile, "r", stdin);
+ break;
+ case 'x':
+ verbosity = atoi(optarg);
+ 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) {
+ lprintf(2, "gethostname: %s\n",
+ strerror(errno));
+ free(server_cookie);
+ }
+ }
+ break;
+ case 's':
+ is_https = 1;
+ break;
+ default:
+ fprintf(stderr, "usage: webserver [-p localport] "
+ "[-t tracefile] [-c] "
+#ifdef HAVE_OPENSSL
+ "[-s] "
+#endif
+ "[remotehost [remoteport]]\n");
+ return 1;
+ }
+
+ if (optind < argc) {
+ ctdlhost = argv[optind];
+ if (++optind < argc)
+ ctdlport = argv[optind];
+ }