1 // Main entry point for the program.
3 // Copyright (c) 1996-2024 by the citadel.org team
5 // This program is open source software. Use, duplication, or disclosure is subject to the GNU General Public License v3.
7 #include "webcit.h" // All other headers are included from this header.
9 char *ctdl_dir = CTDL_DIR;
11 // Main entry point for the web server.
12 int main(int argc, char **argv) {
13 int webserver_port = WEBSERVER_PORT;
14 char *webserver_interface = WEBSERVER_INTERFACE;
15 int running_as_daemon = 0;
16 int webserver_protocol = WEBSERVER_HTTP;
18 char *pid_file = NULL;
21 while ((a = getopt(argc, argv, "u:h:i:p:t:T:B:x:g:dD:G:cfsS:Z:v:")) != EOF)
27 ctdl_dir = strdup(optarg);
30 running_as_daemon = 1;
33 running_as_daemon = 1;
34 pid_file = strdup(optarg);
37 // FIXME set up the default landing page
44 // The above options are no longer used, but ignored so old scripts don't break
47 webserver_interface = optarg;
50 webserver_port = atoi(optarg);
53 // FIXME when gzip is added, disable it if this flag is set
62 webserver_protocol = WEBSERVER_HTTPS;
66 webserver_protocol = WEBSERVER_HTTPS;
67 //ssl_cipher_list = strdup(optarg);
70 //DumpTemplateI18NStrings = 1;
71 //I18nDump = NewStrBufPlain(HKEY("int templatestrings(void)\n{\n"));
72 //I18nDumpFile = optarg;
75 fprintf(stderr, "usage:\nwebcit "
76 "[-i ip_addr] [-p http_port] "
78 "[-d] [-Z] [-G i18ndumpfile] "
79 "[-u uid] [-h homedirectory] "
80 "[-D daemonizepid] [-v] "
81 "[-g defaultlandingpage] [-B basesize] "
82 "[-s] [-S cipher_suites]"
83 "[-h citadel_server_directory]\n"
88 while (optind < argc) {
89 ctdl_dir = strdup(argv[optind++]);
93 openlog("webcit", (running_as_daemon ? (LOG_PID) : (LOG_PID | LOG_PERROR)), LOG_DAEMON);
95 // Tell 'em who's in da house
96 syslog(LOG_NOTICE, "MAKE WEBCIT GREAT AGAIN!");
97 syslog(LOG_NOTICE, "Copyright (C) 1996-2024 by the citadel.org team");
98 syslog(LOG_NOTICE, " ");
99 syslog(LOG_NOTICE, "This program is open source software. Use, duplication, or");
100 syslog(LOG_NOTICE, "disclosure is subject to the GNU General Public License v3.");
101 syslog(LOG_NOTICE, " ");
103 // Ensure that we are linked to the correct version of libcitadel
104 if (libcitadel_version_number() < LIBCITADEL_VERSION_NUMBER) {
105 syslog(LOG_INFO, " You are running libcitadel version %d", libcitadel_version_number());
106 syslog(LOG_INFO, "WebCit was compiled against version %d", LIBCITADEL_VERSION_NUMBER);
110 // Go into the background if we were asked to run as a daemon
111 if (running_as_daemon) {
113 if (pid_file != NULL) {
114 FILE *pfp = fopen(pid_file, "w");
116 fprintf(pfp, "%d\n", getpid());
122 return webserver(webserver_interface, webserver_port, webserver_protocol);