1 // Main entry point for the program.
3 // Copyright (c) 1996-2023 by the citadel.org team
5 // This program is open source software. Use, duplication, or
6 // disclosure are subject to the GNU General Public License v3.
8 #include "webcit.h" // All other headers are included from this header.
10 char *ctdl_dir = CTDL_DIR;
12 // Main entry point for the web server.
13 int main(int argc, char **argv) {
14 int webserver_port = WEBSERVER_PORT;
15 char *webserver_interface = WEBSERVER_INTERFACE;
16 int running_as_daemon = 0;
17 int webserver_protocol = WEBSERVER_HTTP;
19 char *pid_file = NULL;
22 while ((a = getopt(argc, argv, "u:h:i:p:t:T:B:x:g:dD:G:cfsS:Z:v:")) != EOF)
28 ctdl_dir = strdup(optarg);
31 running_as_daemon = 1;
34 running_as_daemon = 1;
35 pid_file = strdup(optarg);
38 // FIXME set up the default landing page
45 // The above options are no longer used, but ignored so old scripts don't break
48 webserver_interface = optarg;
51 webserver_port = atoi(optarg);
54 // FIXME when gzip is added, disable it if this flag is set
63 webserver_protocol = WEBSERVER_HTTPS;
67 webserver_protocol = WEBSERVER_HTTPS;
68 //ssl_cipher_list = strdup(optarg);
71 //DumpTemplateI18NStrings = 1;
72 //I18nDump = NewStrBufPlain(HKEY("int templatestrings(void)\n{\n"));
73 //I18nDumpFile = optarg;
76 fprintf(stderr, "usage:\nwebcit "
77 "[-i ip_addr] [-p http_port] "
79 "[-d] [-Z] [-G i18ndumpfile] "
80 "[-u uid] [-h homedirectory] "
81 "[-D daemonizepid] [-v] "
82 "[-g defaultlandingpage] [-B basesize] "
83 "[-s] [-S cipher_suites]"
84 "[-h citadel_server_directory]\n"
89 while (optind < argc) {
90 ctdl_dir = strdup(argv[optind++]);
94 openlog("webcit", (running_as_daemon ? (LOG_PID) : (LOG_PID | LOG_PERROR)), LOG_DAEMON);
96 // Tell 'em who's in da house
97 syslog(LOG_NOTICE, "MAKE WEBCIT GREAT AGAIN!");
98 syslog(LOG_NOTICE, "Copyright (C) 1996-2023 by the citadel.org team");
99 syslog(LOG_NOTICE, " ");
100 syslog(LOG_NOTICE, "This program is open source software: you can redistribute it and/or");
101 syslog(LOG_NOTICE, "modify it under the terms of the GNU General Public License, version 3.");
102 syslog(LOG_NOTICE, " ");
103 syslog(LOG_NOTICE, "This program is distributed in the hope that it will be useful,");
104 syslog(LOG_NOTICE, "but WITHOUT ANY WARRANTY; without even the implied warranty of");
105 syslog(LOG_NOTICE, "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the");
106 syslog(LOG_NOTICE, "GNU General Public License for more details.");
107 syslog(LOG_NOTICE, " ");
109 // Ensure that we are linked to the correct version of libcitadel
110 if (libcitadel_version_number() < LIBCITADEL_VERSION_NUMBER) {
111 syslog(LOG_INFO, " You are running libcitadel version %d", libcitadel_version_number());
112 syslog(LOG_INFO, "WebCit was compiled against version %d", LIBCITADEL_VERSION_NUMBER);
116 // Go into the background if we were asked to run as a daemon
117 if (running_as_daemon) {
119 if (pid_file != NULL) {
120 FILE *pfp = fopen(pid_file, "w");
122 fprintf(pfp, "%d\n", getpid());
128 return webserver(webserver_interface, webserver_port, webserver_protocol);