#include "webcit.h"
-/*
- * /ctdl/a/login is called when a user is trying to log in
- */
-void try_login(struct http_transaction *h, struct ctdlsession *c)
-{
+// /ctdl/a/login is called when a user is trying to log in
+void try_login(struct http_transaction *h, struct ctdlsession *c) {
char buf[1024];
char auth[AUTH_MAX];
char username[256];
}
-/*
- * /ctdl/a/logout is called when a user is trying to log out. Don't use this as an ajax.
- */
-void logout(struct http_transaction *h, struct ctdlsession *c)
-{
+// /ctdl/a/logout is called when a user is trying to log out. Don't use this as an ajax.
+void logout(struct http_transaction *h, struct ctdlsession *c) {
char buf[1024];
char auth[AUTH_MAX];
char username[256];
}
-/*
- * /ctdl/a/whoami returns the name of the currently logged in user, or an empty string if not logged in
- */
-void whoami(struct http_transaction *h, struct ctdlsession *c)
-{
+// /ctdl/a/whoami returns the name of the currently logged in user, or an empty string if not logged in
+void whoami(struct http_transaction *h, struct ctdlsession *c) {
h->response_code = 200;
h->response_string = strdup("OK");
add_response_header(h, strdup("Content-type"), strdup("text/plain"));
}
-/*
- * Dispatcher for paths starting with /ctdl/a/
- */
-void ctdl_a(struct http_transaction *h, struct ctdlsession *c)
-{
+// Dispatcher for paths starting with /ctdl/a/
+void ctdl_a(struct http_transaction *h, struct ctdlsession *c) {
if (!strcasecmp(h->uri, "/ctdl/a/login")) { // log in
try_login(h, c);
return;
#include "webcit.h"
-/*
- * A CalDAV REPORT can only be one type. This is stored in the report_type member.
- */
+// A CalDAV REPORT can only be one type. This is stored in the report_type member.
enum cr_type {
cr_calendar_query,
cr_calendar_multiget,
};
-/*
- * Data type for CalDAV Report Parameters.
- * As we slog our way through the XML we learn what the client is asking for
- * and build up the contents of this data type.
- */
+// Data type for CalDAV Report Parameters.
+// As we slog our way through the XML we learn what the client is asking for
+// and build up the contents of this data type.
struct cr_parms {
int tag_nesting_level; // not needed, just kept for pretty-printing
enum cr_type report_type; // which RFC4791 section 7 REPORT are we generating
};
-/*
- * XML parser callback
- */
-void caldav_xml_start(void *data, const char *el, const char **attr)
-{
+// XML parser callback
+void caldav_xml_start(void *data, const char *el, const char **attr) {
struct cr_parms *crp = (struct cr_parms *) data;
int i;
}
-/*
- * XML parser callback
- */
-void caldav_xml_end(void *data, const char *el)
-{
+// XML parser callback
+void caldav_xml_end(void *data, const char *el) {
struct cr_parms *crp = (struct cr_parms *) data;
--crp->tag_nesting_level;
}
-/*
- * XML parser callback
- */
-void caldav_xml_chardata(void *data, const XML_Char * s, int len)
-{
+// XML parser callback
+void caldav_xml_chardata(void *data, const XML_Char * s, int len) {
struct cr_parms *crp = (struct cr_parms *) data;
if (crp->Chardata == NULL) {
}
-/*
- * Called by caldav_response() to fetch a message (by number) in the current room,
- * and return only the icalendar data as a StrBuf. Returns NULL if not found.
- *
- * NOTE: this function expects that "MSGP text/calendar" was issued at the beginning
- * of a REPORT operation to set our preferred MIME type to calendar data.
- */
-StrBuf *fetch_ical(struct ctdlsession * c, long msgnum)
-{
+// Called by caldav_response() to fetch a message (by number) in the current room,
+// and return only the icalendar data as a StrBuf. Returns NULL if not found.
+//
+// NOTE: this function expects that "MSGP text/calendar" was issued at the beginning
+// of a REPORT operation to set our preferred MIME type to calendar data.
+StrBuf *fetch_ical(struct ctdlsession * c, long msgnum) {
char buf[1024];
StrBuf *Buf = NULL;
}
-/*
- * Called by caldav_report() to output a single item.
- * Our policy is to throw away the list of properties the client asked for, and just send everything.
- */
-void caldav_response(struct http_transaction *h, struct ctdlsession *c, StrBuf * ReportOut, StrBuf * ThisHref)
-{
+// Called by caldav_report() to output a single item.
+// Our policy is to throw away the list of properties the client asked for, and just send everything.
+void caldav_response(struct http_transaction *h, struct ctdlsession *c, StrBuf * ReportOut, StrBuf * ThisHref) {
long msgnum;
StrBuf *Caldata = NULL;
char *euid;
}
-/*
- * Called by report_the_room_itself() in room_functions.c when a CalDAV REPORT method
- * is requested on a calendar room. We fire up an XML Parser to decode the request and
- * hopefully produce the correct output.
- */
-void caldav_report(struct http_transaction *h, struct ctdlsession *c)
-{
+// Called by report_the_room_itself() in room_functions.c when a CalDAV REPORT method
+// is requested on a calendar room. We fire up an XML Parser to decode the request and
+// hopefully produce the correct output.
+void caldav_report(struct http_transaction *h, struct ctdlsession *c) {
struct cr_parms crp;
char buf[1024];
crp.Chardata = NULL;
}
- /*
- * We're going to make a lot of MSG4 calls, and the preferred MIME type we want is "text/calendar".
- * The iCalendar standard is mature now, and we are no longer interested in text/x-vcal or application/ics.
- */
+ // We're going to make a lot of MSG4 calls, and the preferred MIME type we want is "text/calendar".
+ // The iCalendar standard is mature now, and we are no longer interested in text/x-vcal or application/ics.
ctdl_printf(c, "MSGP text/calendar");
ctdl_readline(c, buf, sizeof buf);
- /*
- * Now begin the REPORT.
- */
+ // Now begin the REPORT.
syslog(LOG_DEBUG, "CalDAV REPORT type is: %d", crp.report_type);
StrBuf *ReportOut = NewStrBuf();
StrBufAppendPrintf(ReportOut, "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
pthread_mutex_t cpool_mutex = PTHREAD_MUTEX_INITIALIZER; // Lock it before modifying
-/*
- * Read a specific number of bytes of binary data from the Citadel server.
- * Returns the number of bytes read or -1 for error.
- */
-int ctdl_read_binary(struct ctdlsession *ctdl, char *buf, int bytes_requested)
-{
+// Read a specific number of bytes of binary data from the Citadel server.
+// Returns the number of bytes read or -1 for error.
+int ctdl_read_binary(struct ctdlsession *ctdl, char *buf, int bytes_requested) {
int bytes_read = 0;
int c = 0;
}
-/*
- * Read a newline-terminated line of text from the Citadel server.
- * Returns the string length or -1 for error.
- */
-int ctdl_readline(struct ctdlsession *ctdl, char *buf, int maxbytes)
-{
+// Read a newline-terminated line of text from the Citadel server.
+// Returns the string length or -1 for error.
+int ctdl_readline(struct ctdlsession *ctdl, char *buf, int maxbytes) {
int len = 0;
int c = 0;
}
-/*
- * Read lines of text from the Citadel server until a 000 terminator is received.
- * Implemented in terms of ctdl_readline() and is therefore transparent...
- * Returns a newly allocated StrBuf or NULL for error.
- */
-StrBuf *ctdl_readtextmsg(struct ctdlsession * ctdl)
-{
+// Read lines of text from the Citadel server until a 000 terminator is received.
+// Implemented in terms of ctdl_readline() and is therefore transparent...
+// Returns a newly allocated StrBuf or NULL for error.
+StrBuf *ctdl_readtextmsg(struct ctdlsession * ctdl) {
char buf[1024];
StrBuf *sj = NewStrBuf();
if (!sj) {
}
-/*
- * Write to the Citadel server. For now we're just wrapping write() in case we
- * need to add anything else later.
- */
-ssize_t ctdl_write(struct ctdlsession * ctdl, const void *buf, size_t count)
-{
+// Write to the Citadel server. For now we're just wrapping write() in case we
+// need to add anything else later.
+ssize_t ctdl_write(struct ctdlsession * ctdl, const void *buf, size_t count) {
return write(ctdl->sock, buf, count);
}
-/*
- * printf() type function to send data to the Citadel Server.
- */
-void ctdl_printf(struct ctdlsession *ctdl, const char *format, ...)
-{
+// printf() type function to send data to the Citadel Server.
+void ctdl_printf(struct ctdlsession *ctdl, const char *format, ...) {
va_list arg_ptr;
StrBuf *Buf = NewStrBuf();
}
-/*
- * Client side - connect to a unix domain socket
- */
-int uds_connectsock(char *sockpath)
-{
+// Client side - connect to a unix domain socket
+int uds_connectsock(char *sockpath) {
struct sockaddr_un addr;
int s;
}
-/*
- * TCP client - connect to a host/port
- */
-int tcp_connectsock(char *host, char *service)
-{
+// TCP client - connect to a host/port
+int tcp_connectsock(char *host, char *service) {
struct in6_addr serveraddr;
struct addrinfo hints;
struct addrinfo *res = NULL;
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
- /*
- * Handle numeric IPv4 and IPv6 addresses
- */
+ // Handle numeric IPv4 and IPv6 addresses
rc = inet_pton(AF_INET, host, &serveraddr);
- if (rc == 1) { /* dotted quad */
+ if (rc == 1) { // dotted quad
hints.ai_family = AF_INET;
hints.ai_flags |= AI_NUMERICHOST;
} else {
rc = inet_pton(AF_INET6, host, &serveraddr);
- if (rc == 1) { /* IPv6 address */
+ if (rc == 1) { // IPv6 address
hints.ai_family = AF_INET6;
hints.ai_flags |= AI_NUMERICHOST;
}
}
- /* Begin the connection process */
+ // Begin the connection process
rc = getaddrinfo(host, service, &hints, &res);
if (rc != 0) {
return (-1);
}
- /*
- * Try all available addresses until we connect to one or until we run out.
- */
+ // Try all available addresses until we connect to one or until we run out.
for (ai = res; ai != NULL; ai = ai->ai_next) {
if (ai->ai_family == AF_INET)
}
-/*
- * Extract from the headers, the username and password the client is attempting to use.
- * This could be HTTP AUTH or it could be in the cookies.
- */
-void extract_auth(struct http_transaction *h, char *authbuf, int authbuflen)
-{
+// Extract from the headers, the username and password the client is attempting to use.
+// This could be HTTP AUTH or it could be in the cookies.
+void extract_auth(struct http_transaction *h, char *authbuf, int authbuflen) {
if (authbuf == NULL)
return;
authbuf[0] = 0;
}
-/*
- * Log in to the Citadel server. Returns 0 on success or nonzero on error.
- *
- * 'auth' should be a base64-encoded "username:password" combination (like in http-auth)
- *
- * If 'resultbuf' is not NULL, it should be a buffer of at least 1024 characters,
- * and will be filled with the result from a Citadel server command.
- */
-int login_to_citadel(struct ctdlsession *c, char *auth, char *resultbuf)
-{
+// Log in to the Citadel server. Returns 0 on success or nonzero on error.
+//
+// 'auth' should be a base64-encoded "username:password" combination (like in http-auth)
+//
+// If 'resultbuf' is not NULL, it should be a buffer of at least 1024 characters,
+// and will be filled with the result from a Citadel server command.
+int login_to_citadel(struct ctdlsession *c, char *auth, char *resultbuf) {
char localbuf[1024];
char *buf;
int buflen;
if (resultbuf != NULL) {
buf = resultbuf;
- } else {
+ }
+ else {
buf = localbuf;
}
}
-/*
- * Hunt for, or create, a connection to our Citadel Server
- */
-struct ctdlsession *connect_to_citadel(struct http_transaction *h)
-{
+// Hunt for, or create, a connection to our Citadel Server
+struct ctdlsession *connect_to_citadel(struct http_transaction *h) {
struct ctdlsession *cptr = NULL;
struct ctdlsession *my_session = NULL;
int is_new_session = 0;
}
-/*
- * Release our Citadel Server connection back into the pool.
- */
-void disconnect_from_citadel(struct ctdlsession *ctdl)
-{
+// Release our Citadel Server connection back into the pool.
+void disconnect_from_citadel(struct ctdlsession *ctdl) {
pthread_mutex_lock(&cpool_mutex);
ctdl->is_bound = 0;
pthread_mutex_unlock(&cpool_mutex);
#include "webcit.h"
-
-/*
- * Delete one or more messages from the connected Citadel server.
- * This function expects the session to already be "in" the room from which the messages will be deleted.
- */
-void ctdl_delete_msgs(struct ctdlsession *c, long *msgnums, int num_msgs)
-{
+// Delete one or more messages from the connected Citadel server.
+// This function expects the session to already be "in" the room from which the messages will be deleted.
+void ctdl_delete_msgs(struct ctdlsession *c, long *msgnums, int num_msgs) {
int i = 0;
char buf[1024];
// Commands we need to send to Citadel Server before we begin rendering forum view.
// These are common to flat and threaded views.
-//
-void setup_for_forum_view(struct ctdlsession *c)
-{
+void setup_for_forum_view(struct ctdlsession *c) {
char buf[1024];
ctdl_printf(c, "MSGP text/html|text/plain"); // Declare the MIME types we know how to render
ctdl_readline(c, buf, sizeof(buf)); // Ignore the response
// Fetch a single message and return it in JSON format for client-side rendering
-//
-void json_render_one_message(struct http_transaction *h, struct ctdlsession *c, long msgnum)
-{
+void json_render_one_message(struct http_transaction *h, struct ctdlsession *c, long msgnum) {
StrBuf *raw_msg = NULL;
StrBuf *sanitized_msg = NULL;
char buf[1024];
#include "webcit.h"
-/*
- * Strip surrounding single or double quotes from a string.
- */
-void stripquotes(char *s)
-{
+// Strip surrounding single or double quotes from a string.
+void stripquotes(char *s) {
int len;
if (!s)
}
-/*
- * Check to see if a META tag has overridden the declared MIME character set.
- *
- * charset Character set name (left unchanged if we don't do anything)
- * meta_http_equiv Content of the "http-equiv" portion of the META tag
- * meta_content Content of the "content" portion of the META tag
- */
-void extract_charset_from_meta(char *charset, char *meta_http_equiv, char *meta_content)
-{
+// Check to see if a META tag has overridden the declared MIME character set.
+//
+// charset Character set name (left unchanged if we don't do anything)
+// meta_http_equiv Content of the "http-equiv" portion of the META tag
+// meta_content Content of the "content" portion of the META tag
+void extract_charset_from_meta(char *charset, char *meta_http_equiv, char *meta_content) {
char *ptr;
char buf[64];
if (!strncasecmp(buf, "charset=", 8)) {
strcpy(charset, &buf[8]);
- /*
- * The brain-damaged webmail program in Microsoft Exchange declares
- * a charset of "unicode" when they really mean "UTF-8". GNU iconv
- * treats "unicode" as an alias for "UTF-16" so we have to manually
- * fix this here, otherwise messages generated in Exchange webmail
- * show up as a big pile of weird characters.
- */
+ // The brain-damaged webmail program in Microsoft Exchange declares
+ // a charset of "unicode" when they really mean "UTF-8". GNU iconv
+ // treats "unicode" as an alias for "UTF-16" so we have to manually
+ // fix this here, otherwise messages generated in Exchange webmail
+ // show up as a big pile of weird characters.
if (!strcasecmp(charset, "unicode")) {
strcpy(charset, "UTF-8");
}
- /* Remove wandering punctuation */
+ // Remove wandering punctuation
if ((ptr = strchr(charset, '\"')))
*ptr = 0;
striplt(charset);
}
-/*
- * Sanitize and enhance an HTML message for display.
- * Also convert weird character sets to UTF-8 if necessary.
- * Also fixup img src="cid:..." type inline images to fetch the image
- *
- */
-StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomname, long msgnum, StrBuf *Source)
-{
+// Sanitize and enhance an HTML message for display.
+// Also convert weird character sets to UTF-8 if necessary.
+// Also fixup img src="cid:..." type inline images to fetch the image
+StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomname, long msgnum, StrBuf *Source) {
char buf[SIZ];
char *msg;
char *ptr;
StrBuf *BodyArea = NULL;
iconv_t ic = (iconv_t) (-1);
- char *ibuf; /* Buffer of characters to be converted */
- char *obuf; /* Buffer for converted characters */
- size_t ibuflen; /* Length of input buffer */
- size_t obuflen; /* Length of output buffer */
- char *osav; /* Saved pointer to output buffer */
+ char *ibuf; // Buffer of characters to be converted
+ char *obuf; // Buffer for converted characters
+ size_t ibuflen; // Length of input buffer
+ size_t obuflen; // Length of output buffer
+ char *osav; // Saved pointer to output buffer
StrBuf *Target = NewStrBuf();
if (Target == NULL) {
msg = (char *) ChrPtr(Source);
buffer_length = content_length;
- /* Do a first pass to isolate the message body */
+ // Do a first pass to isolate the message body
ptr = msg + 1;
msgstart = msg;
msgend = &msg[content_length];
while (ptr < msgend) {
- /* Advance to next tag */
+ // Advance to next tag
ptr = strchr(ptr, '<');
if ((ptr == NULL) || (ptr >= msgend))
break;
if ((ptr == NULL) || (ptr >= msgend))
break;
- /*
- * Look for META tags. Some messages (particularly in
- * Asian locales) illegally declare a message's character
- * set in the HTML instead of in the MIME headers. This
- * is wrong but we have to work around it anyway.
- */
+ // Look for META tags. Some messages (particularly in
+ // Asian locales) illegally declare a message's character
+ // set in the HTML instead of in the MIME headers. This
+ // is wrong but we have to work around it anyway.
if (!strncasecmp(ptr, "META", 4)) {
char *meta_start;
}
}
- /*
- * Any of these tags cause everything up to and including
- * the tag to be removed.
- */
+ // Any of these tags cause everything up to and including
+ // the tag to be removed.
if ((!strncasecmp(ptr, "HTML", 4))
|| (!strncasecmp(ptr, "HEAD", 4))
|| (!strncasecmp(ptr, "/HEAD", 5))
while ((*cid_end != '"') && !isspace(*cid_end) && (cid_end < ptr))
cid_end++;
- /* copy tag and attributes up to src="cid: */
+ // copy tag and attributes up to src="cid:
StrBufAppendBufPlain(BodyArea, pBody, src - pBody, 0);
- /* add in /webcit/mimepart/<msgno>/CID/
- trailing / stops dumb URL filters getting excited */
+ // add in /webcit/mimepart/<msgno>/CID/
+ // trailing / stops dumb URL filters getting excited
StrBufAppendPrintf(BodyArea, "/webcit/mimepart/%ld/", msgnum);
StrBufAppendBufPlain(BodyArea, cid_start, cid_end - cid_start, 0);
msgstart = ptr;
}
- /*
- * Any of these tags cause everything including and following
- * the tag to be removed.
- */
+ // Any of these tags cause everything including and following
+ // the tag to be removed.
if ((!strncasecmp(ptr, "/HTML", 5)) || (!strncasecmp(ptr, "/BODY", 5))) {
--ptr;
msgend = ptr;
strcpy(msg, msgstart);
}
- /* Now go through the message, parsing tags as necessary. */
+ // Now go through the message, parsing tags as necessary.
converted_msg = NewStrBufPlain(NULL, content_length + 8192);
- /* Convert foreign character sets to UTF-8 if necessary. */
+ // Convert foreign character sets to UTF-8 if necessary
if ((strcasecmp(charset, "us-ascii"))
&& (strcasecmp(charset, "UTF-8"))
&& (strcasecmp(charset, ""))
StrBufConvert(Source, Buf, &ic);
FreeStrBuf(&Buf);
iconv_close(ic);
- msg = (char *) ChrPtr(Source); /* TODO: get rid of this. */
+ msg = (char *) ChrPtr(Source); // TODO: get rid of this.
}
}
- /*
- * At this point, the message has been stripped down to
- * only the content inside the <BODY></BODY> tags, and has
- * been converted to UTF-8 if it was originally in a foreign
- * character set. The text is also guaranteed to be null
- * terminated now.
- */
+ // At this point, the message has been stripped down to
+ // only the content inside the <BODY></BODY> tags, and has
+ // been converted to UTF-8 if it was originally in a foreign
+ // character set. The text is also guaranteed to be null
+ // terminated now.
if (converted_msg == NULL) {
StrBufAppendPrintf(Target, "Error %d: %s<br>%s:%d", errno, strerror(errno), __FILE__, __LINE__);
msgend = strchr(msg, 0);
while (ptr < msgend) {
- /* Try to sanitize the html of any rogue scripts */
+ // Try to sanitize the html of any rogue scripts
if (!strncasecmp(ptr, "<script", 7)) {
if (scriptlevel == 0) {
script_start_pos = StrLength(converted_msg);
--scriptlevel;
}
- /*
- * Change mailto: links to WebCit mail, by replacing the
- * link with one that points back to our mail room. Due to
- * the way we parse URL's, it'll even handle mailto: links
- * that have "?subject=" in them.
- */
+ // Change mailto: links to WebCit mail, by replacing the
+ // link with one that points back to our mail room. Due to
+ // the way we parse URL's, it'll even handle mailto: links
+ // that have "?subject=" in them.
+ // FIXME change URL syntax for webcit-ng
if (!strncasecmp(ptr, "<a href=\"mailto:", 16)) {
content_length += 64;
- StrBufAppendPrintf(converted_msg, "<a href=\"display_enter?force_room=_MAIL_?recp="); // FIXME make compatible with webcit-ng
+ StrBufAppendPrintf(converted_msg, "<a href=\"display_enter?force_room=_MAIL_?recp=");
ptr = &ptr[16];
++alevel;
++brak;
}
- /* Make external links open in a separate window */
+
+ // Make external links open in a separate window
else if (!strncasecmp(ptr, "<a href=\"", 9)) {
++alevel;
++brak;
if (((strchr(ptr, ':') < strchr(ptr, '/'))) && ((strchr(ptr, '/') < strchr(ptr, '>')))) {
- /* open external links to new window */
+ // open external links to new window
StrBufAppendPrintf(converted_msg, new_window);
ptr = &ptr[8];
} else if ((treat_as_wiki)
ptr = &ptr[9];
}
}
- /* Fixup <img src="cid:... ...> to fetch the mime part */
+
+ // Fixup <img src="cid:... ...> to fetch the mime part
else if (!strncasecmp(ptr, "<img ", 5)) {
char *cid_start, *cid_end;
char *tag_end = strchr(ptr, '>');
char *src;
- /* FIXME - handle this situation (maybe someone opened an <img cid...
- * and then ended the message)
- */
+ // FIXME - handle this situation (maybe someone opened an <img cid...
+ // and then ended the message)
if (!tag_end) {
syslog(LOG_DEBUG, "tag_end is null and ptr is:");
syslog(LOG_DEBUG, "%s", ptr);
&& (cid_end = strchr(cid_start, '"'))
&& (cid_end < tag_end)
) {
- /* copy tag and attributes up to src="cid: */
+ // copy tag and attributes up to src="cid:
StrBufAppendBufPlain(converted_msg, ptr, src - ptr, 0);
cid_start++;
- /* add in /webcit/mimepart/<msgnum>/CID/
- trailing / stops dumb URL filters getting excited */
+ // add in /webcit/mimepart/<msgnum>/CID/
+ // trailing / stops dumb URL filters getting excited
StrBufAppendPrintf(converted_msg, " src=\"/ctdl/r/");
StrBufXMLEscAppend(converted_msg, NULL, roomname, strlen(roomname), 0);
syslog(LOG_DEBUG, "room name is '%s'", roomname);
ptr = tag_end;
}
- /*
- * Turn anything that looks like a URL into a real link, as long
- * as it's not inside a tag already
- */
+ // Turn anything that looks like a URL into a real link, as long
+ // as it's not inside a tag already
else if ((brak == 0) && (alevel == 0) && ((!strncasecmp(ptr, "http://", 7)) || (!strncasecmp(ptr, "https://", 8)))) {
- /* Find the end of the link */
+ // Find the end of the link
int strlenptr;
linklen = 0;
|| (ptr[i] == '\'')
)
linklen = i;
- /* entity tag? */
+ // entity tag?
if (ptr[i] == '&') {
if ((ptr[i + 2] == ';') ||
(ptr[i + 3] == ';') ||
char *ctdlhost = CTDLHOST;
char *ctdlport = CTDLPORT;
-/*
- * Main entry point for the web server.
- */
-int main(int argc, char **argv)
-{
+// Main entry point for the web server.
+int main(int argc, char **argv) {
int webserver_port = WEBSERVER_PORT;
char *webserver_interface = WEBSERVER_INTERFACE;
int running_as_daemon = 0;
int a;
char *pid_file = NULL;
- /* Parse command line */
+ // Parse command line
while ((a = getopt(argc, argv, "u:h:i:p:t:T:B:x:g:dD:G:cfsS:Z:v:")) != EOF)
switch (a) {
case 'u':
case 'x':
case 'T':
case 'v':
- /* The above options are no longer used, but ignored so old scripts don't break */
+ // The above options are no longer used, but ignored so old scripts don't break
break;
case 'i':
webserver_interface = optarg;
ctdlport = argv[optind];
}
- /* Start the logger */
+ // Start the logger
openlog("webcit", (running_as_daemon ? (LOG_PID) : (LOG_PID | LOG_PERROR)), LOG_DAEMON);
- /* Tell 'em who's in da house */
+ // Tell 'em who's in da house
syslog(LOG_NOTICE, "MAKE WEBCIT GREAT AGAIN!");
- syslog(LOG_NOTICE, "Copyright (C) 1996-2020 by the citadel.org team");
+ syslog(LOG_NOTICE, "Copyright (C) 1996-2021 by the citadel.org team");
syslog(LOG_NOTICE, " ");
syslog(LOG_NOTICE, "This program is open source software: you can redistribute it and/or");
syslog(LOG_NOTICE, "modify it under the terms of the GNU General Public License, version 3.");
syslog(LOG_NOTICE, "GNU General Public License for more details.");
syslog(LOG_NOTICE, " ");
- /* Ensure that we are linked to the correct version of libcitadel */
+ // Ensure that we are linked to the correct version of libcitadel
if (libcitadel_version_number() < LIBCITADEL_VERSION_NUMBER) {
syslog(LOG_INFO, " You are running libcitadel version %d", libcitadel_version_number());
syslog(LOG_INFO, "WebCit was compiled against version %d", LIBCITADEL_VERSION_NUMBER);
return (1);
}
- /* Go into the background if we were asked to run as a daemon */
+ // Go into the background if we were asked to run as a daemon
if (running_as_daemon) {
daemon(1, 0);
if (pid_file != NULL) {
-/*
- * webcit.h - "header of headers"
- *
- * Copyright (c) 1996-2018 by the citadel.org team
- *
- * This program is open source software. You can redistribute it and/or
- * modify it under the terms of the GNU General Public License, version 3.
- */
+// webcit.h - "header of headers"
+//
+// Copyright (c) 1996-2021 by the citadel.org team
+//
+// This program is open source software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License, version 3.
#define SHOW_ME_VAPPEND_PRINTF
#define _(x) x // temporary hack until we add i18n back in
//#define DEBUG_HTTP // uncomment to debug HTTP headers
-/* XML_StopParser is present in expat 2.x */
+// XML_StopParser is present in expat 2.x
#if XML_MAJOR_VERSION > 1
#define HAVE_XML_STOPPARSER
#endif