From 8c32e9765e730146f2b8a1b25b48f38c09455a4e Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 27 Sep 2021 22:37:00 -0400 Subject: [PATCH] more boring style cleanup --- citadel/Makefile.in | 2 +- webcit-ng/html2html.c | 37 +++++++-------- webcit-ng/http.c | 44 ++++++------------ webcit-ng/messages.c | 55 ++++++++-------------- webcit-ng/room_functions.c | 93 ++++++++++++-------------------------- 5 files changed, 80 insertions(+), 151 deletions(-) diff --git a/citadel/Makefile.in b/citadel/Makefile.in index 83d2bcb1c..64407e4d1 100644 --- a/citadel/Makefile.in +++ b/citadel/Makefile.in @@ -44,7 +44,7 @@ ACLOCAL=@ACLOCAL@ AUTOCONF=@AUTOCONF@ chkpwd_LIBS=@chkpwd_LIBS@ CC=@CC@ -CFLAGS=@CFLAGS@ -I. +CFLAGS=@CFLAGS@ -I. -Wno-format-truncation CPPFLAGS=@CPPFLAGS@ -I. DATABASE=@DATABASE@ DEFS=@DEFS@ -DDIFF=\"@DIFF@\" -DPATCH=\"@PATCH@\" diff --git a/webcit-ng/html2html.c b/webcit-ng/html2html.c index 4eaca438c..7518a29bf 100644 --- a/webcit-ng/html2html.c +++ b/webcit-ng/html2html.c @@ -433,7 +433,7 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam len = linklen; linkedchar = ptr[len]; ptr[len] = '\0'; - /* spot for some subject strings tinymce tends to give us. */ + // spot for some subject strings tinymce tends to give us. ltreviewptr = strchr(ptr, '<'); if (ltreviewptr != NULL) { *ltreviewptr = '\0'; @@ -442,7 +442,7 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam nbspreviewptr = strstr(ptr, " "); if (nbspreviewptr != NULL) { - /* nbspreviewptr = '\0'; */ + // nbspreviewptr = '\0'; linklen = nbspreviewptr - ptr; } if (ltreviewptr != 0) @@ -458,17 +458,16 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam ptr += linklen; StrBufAppendPrintf(converted_msg, ""); } - } else { + } + else { StrBufAppendBufPlain(converted_msg, ptr, 1, 0); ptr++; } if ((ptr >= msg) && (ptr <= msgend)) { - /* - * We need to know when we're inside a tag, - * so we don't turn things that look like URL's into - * links, when they're already links - or image sources. - */ + // We need to know when we're inside a tag, + // so we don't turn things that look like URL's into + // links, when they're already links - or image sources. if ((ptr > msg) && (*(ptr - 1) == '<')) { ++brak; } @@ -489,17 +488,17 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam FreeStrBuf(&BodyArea); // from the original tag } - /* uncomment these two lines to override conversion */ - /* memcpy(converted_msg, msg, content_length); */ - /* output_length = content_length; */ + // uncomment these two lines to override conversion + // memcpy(converted_msg, msg, content_length); + // output_length = content_length; /* Output our big pile of markup */ StrBufAppendBuf(Target, converted_msg, 0); - BAIL: /* A little trailing vertical whitespace... */ + BAIL: // A little trailing vertical whitespace... StrBufAppendPrintf(Target, "
\n"); - /* Now give back the memory */ + // Now give back the memory FreeStrBuf(&converted_msg); if ((msg != NULL) && (Source == NULL)) free(msg); @@ -507,12 +506,9 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam } -/* - * Look for URL's embedded in a buffer and make them linkable. We use a - * target window in order to keep the Citadel session in its own window. - */ -void UrlizeText(StrBuf * Target, StrBuf * Source, StrBuf * WrkBuf) -{ +// Look for URL's embedded in a buffer and make them linkable. We use a +// target window in order to keep the Citadel session in its own window. +void UrlizeText(StrBuf * Target, StrBuf * Source, StrBuf * WrkBuf) { int len, UrlLen, Offset, TrailerLen; const char *start, *end, *pos; @@ -568,8 +564,7 @@ void UrlizeText(StrBuf * Target, StrBuf * Source, StrBuf * WrkBuf) } -void url(char *buf, size_t bufsize) -{ +void url(char *buf, size_t bufsize) { int len, UrlLen, Offset, TrailerLen, outpos; char *start, *end, *pos; char urlbuf[SIZ]; diff --git a/webcit-ng/http.c b/webcit-ng/http.c index 0dd762365..36ca13052 100644 --- a/webcit-ng/http.c +++ b/webcit-ng/http.c @@ -15,9 +15,7 @@ #include "webcit.h" -/* - * Write data to the HTTP client. Encrypt if necessary. - */ +// Write data to the HTTP client. Encrypt if necessary. int client_write(struct client_handle *ch, char *buf, int nbytes) { if (is_https) { return client_write_ssl(ch, buf, nbytes); @@ -28,10 +26,8 @@ int client_write(struct client_handle *ch, char *buf, int nbytes) { } -/* - * Read data from the HTTP client. Decrypt if necessary. - * Returns number of bytes read, or -1 to indicate an error. - */ +// Read data from the HTTP client. Decrypt if necessary. +// Returns number of bytes read, or -1 to indicate an error. int client_read(struct client_handle *ch, char *buf, int nbytes) { if (is_https) { return client_read_ssl(ch, buf, nbytes); @@ -51,11 +47,9 @@ int client_read(struct client_handle *ch, char *buf, int nbytes) { } -/* - * Read a newline-terminated line of text from the client. - * Implemented in terms of client_read() and is therefore transparent... - * Returns the string length or -1 for error. - */ +// Read a newline-terminated line of text from the client. +// Implemented in terms of client_read() and is therefore transparent... +// Returns the string length or -1 for error. int client_readline(struct client_handle *ch, char *buf, int maxbytes) { int len = 0; int c = 0; @@ -83,9 +77,7 @@ int client_readline(struct client_handle *ch, char *buf, int maxbytes) { } -/* - * printf() type function to send data to the web client. - */ +// printf() type function to send data to the web client. void client_printf(struct client_handle *ch, const char *format, ...) { va_list arg_ptr; StrBuf *Buf = NewStrBuf(); @@ -99,10 +91,8 @@ void client_printf(struct client_handle *ch, const char *format, ...) { } -/* - * Push one new header into the response of an HTTP request. - * When completed, the HTTP transaction now owns the memory allocated for key and val. - */ +// Push one new header into the response of an HTTP request. +// When completed, the HTTP transaction now owns the memory allocated for key and val. void add_response_header(struct http_transaction *h, char *key, char *val) { struct http_header *new_response_header = malloc(sizeof(struct http_header)); new_response_header->key = key; @@ -112,10 +102,8 @@ void add_response_header(struct http_transaction *h, char *key, char *val) { } -/* - * Entry point for this layer. Socket is connected. If running as an HTTPS - * server, SSL has already been negotiated. Now perform one transaction. - */ +// Entry point for this layer. Socket is connected. If running as an HTTPS +// server, SSL has already been negotiated. Now perform one transaction. void perform_one_http_transaction(struct client_handle *ch) { char buf[1024]; int len; @@ -269,12 +257,10 @@ void perform_one_http_transaction(struct client_handle *ch) { } -/* - * Utility function to fetch a specific header from a completely read-in request. - * Returns the value of the requested header, or NULL if the specified header was not sent. - * The caller does NOT own the memory of the returned pointer, but can count on the pointer - * to still be valid through the end of the transaction. - */ +// Utility function to fetch a specific header from a completely read-in request. +// Returns the value of the requested header, or NULL if the specified header was not sent. +// The caller does NOT own the memory of the returned pointer, but can count on the pointer +// to still be valid through the end of the transaction. char *header_val(struct http_transaction *h, char *requested_header) { struct http_header *clh; // general purpose iterator variable for (clh = h->request_headers; clh != NULL; clh = clh->next) { diff --git a/webcit-ng/messages.c b/webcit-ng/messages.c index 342ba4f7a..b33cdf0c3 100644 --- a/webcit-ng/messages.c +++ b/webcit-ng/messages.c @@ -16,14 +16,10 @@ #include "webcit.h" -/* - * Given an encoded UID, translate that to an unencoded Citadel EUID and - * then search for it in the current room. Return a message number or -1 - * if not found. - * - */ -long locate_message_by_uid(struct ctdlsession *c, char *uid) -{ +// Given an encoded UID, translate that to an unencoded Citadel EUID and +// then search for it in the current room. Return a message number or -1 +// if not found. +long locate_message_by_uid(struct ctdlsession *c, char *uid) { char buf[1024]; ctdl_printf(c, "EUID %s", uid); @@ -33,7 +29,7 @@ long locate_message_by_uid(struct ctdlsession *c, char *uid) } - /* Ugly hack to handle Mozilla Thunderbird, try stripping ".ics" if present */ + // Ugly hack to handle Mozilla Thunderbird, try stripping ".ics" if present if (!strcasecmp(&uid[strlen(uid) - 4], ".ics")) { safestrncpy(buf, uid, sizeof buf); buf[strlen(buf) - 4] = 0; @@ -49,22 +45,16 @@ long locate_message_by_uid(struct ctdlsession *c, char *uid) } -/* - * DAV delete an object in a room. - */ -void dav_delete_message(struct http_transaction *h, struct ctdlsession *c, long msgnum) -{ +// DAV delete an object in a room. +void dav_delete_message(struct http_transaction *h, struct ctdlsession *c, long msgnum) { ctdl_delete_msgs(c, &msgnum, 1); h->response_code = 204; h->response_string = strdup("no content"); } -/* - * GET method directly on a message in a room - */ -void dav_get_message(struct http_transaction *h, struct ctdlsession *c, long msgnum) -{ +// GET method directly on a message in a room +void dav_get_message(struct http_transaction *h, struct ctdlsession *c, long msgnum) { char buf[1024]; int in_body = 0; int encoding = 0; @@ -136,11 +126,8 @@ void dav_get_message(struct http_transaction *h, struct ctdlsession *c, long msg } -/* - * PUT a message into a room - */ -void dav_put_message(struct http_transaction *h, struct ctdlsession *c, char *euid, long old_msgnum) -{ +// PUT a message into a room +void dav_put_message(struct http_transaction *h, struct ctdlsession *c, char *euid, long old_msgnum) { char buf[1024]; char *content_type = NULL; int n; @@ -173,9 +160,7 @@ void dav_put_message(struct http_transaction *h, struct ctdlsession *c, char *eu } ctdl_printf(c, "000"); - /* - * Now handle the response from the Citadel server. - */ + // Now handle the response from the Citadel server. n = 0; new_msgnum = 0; @@ -198,9 +183,9 @@ void dav_put_message(struct http_transaction *h, struct ctdlsession *c, char *eu break; } - /* Tell the client what happened. */ + // Tell the client what happened. - /* Citadel failed in some way? */ + // Citadel failed in some way? char *new_location = malloc(1024); if ((new_msgnum < 0L) || (new_location == NULL)) { h->response_code = 502; @@ -231,20 +216,16 @@ void dav_put_message(struct http_transaction *h, struct ctdlsession *c, char *eu h->response_code = 204; // We modified an existing item. h->response_string = strdup("no content"); - /* The item we replaced has probably already been deleted by - * the Citadel server, but we'll do this anyway, just in case. - */ + // The item we replaced has probably already been deleted by + // the Citadel server, but we'll do this anyway, just in case. ctdl_delete_msgs(c, &old_msgnum, 1); } } -/* - * Download a single component of a MIME-encoded message - */ -void download_mime_component(struct http_transaction *h, struct ctdlsession *c, long msgnum, char *partnum) -{ +// Download a single component of a MIME-encoded message +void download_mime_component(struct http_transaction *h, struct ctdlsession *c, long msgnum, char *partnum) { char buf[1024]; char content_type[1024]; diff --git a/webcit-ng/room_functions.c b/webcit-ng/room_functions.c index 9bf9c58be..416066a85 100644 --- a/webcit-ng/room_functions.c +++ b/webcit-ng/room_functions.c @@ -16,10 +16,8 @@ #include "webcit.h" -/* - * Return a "zero-terminated" array of message numbers in the current room. - * Caller owns the memory and must free it. Returns NULL if any problems. - */ +// Return a "zero-terminated" array of message numbers in the current room. +// Caller owns the memory and must free it. Returns NULL if any problems. long *get_msglist(struct ctdlsession *c, char *which_msgs) { char buf[1024]; long *msglist = NULL; @@ -47,11 +45,9 @@ long *get_msglist(struct ctdlsession *c, char *which_msgs) { } -/* - * Supplied with a list of potential matches from an If-Match: or If-None-Match: header, and - * a message number (which we always use as the entity tag in Citadel), return nonzero if the - * message number matches any of the supplied tags in the string. - */ +// Supplied with a list of potential matches from an If-Match: or If-None-Match: header, and +// a message number (which we always use as the entity tag in Citadel), return nonzero if the +// message number matches any of the supplied tags in the string. int match_etags(char *taglist, long msgnum) { int num_tags = num_tokens(taglist, ','); int i = 0; @@ -84,9 +80,7 @@ int match_etags(char *taglist, long msgnum) { } -/* - * Client is requesting a message list - */ +// Client is requesting a message list void json_msglist(struct http_transaction *h, struct ctdlsession *c, char *which) { int i = 0; long *msglist = get_msglist(c, which); @@ -111,9 +105,7 @@ void json_msglist(struct http_transaction *h, struct ctdlsession *c, char *which } -/* - * Client requested an object in a room. - */ +// Client requested an object in a room. void object_in_room(struct http_transaction *h, struct ctdlsession *c) { char buf[1024]; long msgnum = (-1); @@ -147,27 +139,22 @@ void object_in_room(struct http_transaction *h, struct ctdlsession *c) { safestrncpy(unescaped_euid, buf, sizeof unescaped_euid); unescape_input(unescaped_euid); msgnum = locate_message_by_uid(c, unescaped_euid); - } else { + } + else { msgnum = atol(buf); } - /* - * All methods except PUT require the message to already exist - */ + // All methods except PUT require the message to already exist if ((msgnum <= 0) && (strcasecmp(h->method, "PUT"))) { do_404(h); } - /* - * If we get to this point we have a valid message number in an accessible room. - */ + // If we get to this point we have a valid message number in an accessible room. syslog(LOG_DEBUG, "msgnum is %ld, method is %s", msgnum, h->method); - /* - * A sixth component in the URL can be one of two things: - * (1) a MIME part specifier, in which case the client wants to download that component within the message - * (2) a content-type, in which ase the client wants us to try to render it a certain way - */ + // A sixth component in the URL can be one of two things: + // (1) a MIME part specifier, in which case the client wants to download that component within the message + // (2) a content-type, in which ase the client wants us to try to render it a certain way if (num_tokens(h->uri, '/') == 6) { extract_token(buf, h->uri, 5, '/', sizeof buf); if (!IsEmptyStr(buf)) { @@ -180,9 +167,7 @@ void object_in_room(struct http_transaction *h, struct ctdlsession *c) { } } - /* - * Ok, we want a full message, but first let's check for the if[-none]-match headers. - */ + // Ok, we want a full message, but first let's check for the if[-none]-match headers. char *if_match = header_val(h, "If-Match"); if ((if_match != NULL) && (!match_etags(if_match, msgnum))) { do_412(h); @@ -195,9 +180,7 @@ void object_in_room(struct http_transaction *h, struct ctdlsession *c) { return; } - /* - * DOOOOOO ITTTTT!!! - */ + // DOOOOOO ITTTTT!!! if (!strcasecmp(h->method, "DELETE")) { dav_delete_message(h, c, msgnum); @@ -215,9 +198,7 @@ void object_in_room(struct http_transaction *h, struct ctdlsession *c) { } -/* - * Called by the_room_itself() when the HTTP method is REPORT - */ +// Called by the_room_itself() when the HTTP method is REPORT void report_the_room_itself(struct http_transaction *h, struct ctdlsession *c) { if (c->room_default_view == VIEW_CALENDAR) { caldav_report(h, c); // CalDAV REPORTs ... fmgwac @@ -228,9 +209,7 @@ void report_the_room_itself(struct http_transaction *h, struct ctdlsession *c) { } -/* - * Called by the_room_itself() when the HTTP method is OPTIONS - */ +// Called by the_room_itself() when the HTTP method is OPTIONS void options_the_room_itself(struct http_transaction *h, struct ctdlsession *c) { h->response_code = 200; h->response_string = strdup("OK"); @@ -247,9 +226,7 @@ void options_the_room_itself(struct http_transaction *h, struct ctdlsession *c) } -/* - * Called by the_room_itself() when the HTTP method is PROPFIND - */ +// Called by the_room_itself() when the HTTP method is PROPFIND void propfind_the_room_itself(struct http_transaction *h, struct ctdlsession *c) { char *e; long timestamp; @@ -260,7 +237,7 @@ void propfind_the_room_itself(struct http_transaction *h, struct ctdlsession *c) StrBufAppendPrintf(Buf, "" ""); - /* Transmit the collection resource */ + // Transmit the collection resource StrBufAppendPrintf(Buf, ""); StrBufAppendPrintf(Buf, ""); StrBufXMLEscAppend(Buf, NULL, h->site_prefix, strlen(h->site_prefix), 0); @@ -309,11 +286,10 @@ void propfind_the_room_itself(struct http_transaction *h, struct ctdlsession *c) break; } - /* FIXME get the mtime - StrBufAppendPrintf(Buf, ""); - escputs(datestring); - StrBufAppendPrintf(Buf, ""); - */ + // FIXME get the mtime + // StrBufAppendPrintf(Buf, ""); + // escputs(datestring); + // StrBufAppendPrintf(Buf, ""); StrBufAppendPrintf(Buf, ""); StrBufAppendPrintf(Buf, ""); @@ -412,11 +388,8 @@ void propfind_the_room_itself(struct http_transaction *h, struct ctdlsession *c) // http://blogs.nologin.es/rickyepoderi/index.php?/archives/14-Introducing-CalDAV-Part-I.html -/* - * Called by the_room_itself() when the HTTP method is PROPFIND - */ -void get_the_room_itself(struct http_transaction *h, struct ctdlsession *c) -{ +// Called by the_room_itself() when the HTTP method is PROPFIND +void get_the_room_itself(struct http_transaction *h, struct ctdlsession *c) { JsonValue *j = NewJsonObject(HKEY("gotoroom")); JsonObjectAppend(j, NewJsonPlainString(HKEY("name"), c->room, -1)); @@ -438,10 +411,8 @@ void get_the_room_itself(struct http_transaction *h, struct ctdlsession *c) } -/* - * Handle REST/DAV requests for the room itself (such as /ctdl/r/roomname - * or /ctdl/r/roomname/ but *not* specific objects within the room) - */ +// Handle REST/DAV requests for the room itself (such as /ctdl/r/roomname +// or /ctdl/r/roomname/ but *not* specific objects within the room) void the_room_itself(struct http_transaction *h, struct ctdlsession *c) { // OPTIONS method on the room itself usually is a DAV client assessing what's here. @@ -473,9 +444,7 @@ void the_room_itself(struct http_transaction *h, struct ctdlsession *c) { } -/* - * Dispatcher for "/ctdl/r" and "/ctdl/r/" for the room list - */ +// Dispatcher for "/ctdl/r" and "/ctdl/r/" for the room list void room_list(struct http_transaction *h, struct ctdlsession *c) { char buf[1024]; char roomname[1024]; @@ -520,9 +489,7 @@ void room_list(struct http_transaction *h, struct ctdlsession *c) { } -/* - * Dispatcher for paths starting with /ctdl/r/ - */ +// Dispatcher for paths starting with /ctdl/r/ void ctdl_r(struct http_transaction *h, struct ctdlsession *c) { char requested_roomname[128]; char buf[1024]; -- 2.39.2