2 * Main entry point for the program.
4 * Copyright (c) 1996-2019 by the citadel.org team
6 * This program is open source software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 3.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 #include "webcit.h" // All other headers are included from this header.
17 char *ctdlhost = CTDLHOST;
18 char *ctdlport = CTDLPORT;
21 * Main entry point for the web server.
23 int main(int argc, char **argv)
25 int webserver_port = WEBSERVER_PORT;
26 char *webserver_interface = WEBSERVER_INTERFACE;
27 int running_as_daemon = 0;
28 int webserver_protocol = WEBSERVER_HTTP;
30 char *pid_file = NULL;
32 /* Parse command line */
33 while ((a = getopt(argc, argv, "u:h:i:p:t:T:B:x:g:dD:G:cfsS:Z:v:")) != EOF)
41 running_as_daemon = 1;
44 running_as_daemon = 1;
45 pid_file = strdup(optarg);
48 // FIXME set up the default landing page
55 /* The above options are no longer used, but ignored so old scripts don't break */
58 webserver_interface = optarg;
61 webserver_port = atoi(optarg);
64 // FIXME when gzip is added, disable it if this flag is set
73 webserver_protocol = WEBSERVER_HTTPS;
77 webserver_protocol = WEBSERVER_HTTPS;
78 //ssl_cipher_list = strdup(optarg);
81 //DumpTemplateI18NStrings = 1;
82 //I18nDump = NewStrBufPlain(HKEY("int templatestrings(void)\n{\n"));
83 //I18nDumpFile = optarg;
86 fprintf(stderr, "usage:\nwebcit "
87 "[-i ip_addr] [-p http_port] "
89 "[-d] [-Z] [-G i18ndumpfile] "
90 "[-u uid] [-h homedirectory] "
91 "[-D daemonizepid] [-v] "
92 "[-g defaultlandingpage] [-B basesize] " "[-s] [-S cipher_suites]" "[remotehost [remoteport]]\n");
97 ctdlhost = argv[optind];
99 ctdlport = argv[optind];
102 /* Start the logger */
103 openlog("webcit", (running_as_daemon ? (LOG_PID) : (LOG_PID | LOG_PERROR)), LOG_DAEMON);
105 /* Tell 'em who's in da house */
106 syslog(LOG_NOTICE, "MAKE WEBCIT GREAT AGAIN!");
107 syslog(LOG_NOTICE, "Copyright (C) 1996-2019 by the citadel.org team");
108 syslog(LOG_NOTICE, " ");
109 syslog(LOG_NOTICE, "This program is open source software: you can redistribute it and/or");
110 syslog(LOG_NOTICE, "modify it under the terms of the GNU General Public License, version 3.");
111 syslog(LOG_NOTICE, " ");
112 syslog(LOG_NOTICE, "This program is distributed in the hope that it will be useful,");
113 syslog(LOG_NOTICE, "but WITHOUT ANY WARRANTY; without even the implied warranty of");
114 syslog(LOG_NOTICE, "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the");
115 syslog(LOG_NOTICE, "GNU General Public License for more details.");
116 syslog(LOG_NOTICE, " ");
118 /* Ensure that we are linked to the correct version of libcitadel */
119 if (libcitadel_version_number() < LIBCITADEL_VERSION_NUMBER) {
120 syslog(LOG_INFO, " You are running libcitadel version %d", libcitadel_version_number());
121 syslog(LOG_INFO, "WebCit was compiled against version %d", LIBCITADEL_VERSION_NUMBER);
125 /* Go into the background if we were asked to run as a daemon */
126 if (running_as_daemon) {
128 if (pid_file != NULL) {
129 FILE *pfp = fopen(pid_file, "w");
131 fprintf(pfp, "%d\n", getpid());
137 return webserver(webserver_interface, webserver_port, webserver_protocol);