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@\"
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';
nbspreviewptr = strstr(ptr, " ");
if (nbspreviewptr != NULL) {
- /* nbspreviewptr = '\0'; */
+ // nbspreviewptr = '\0';
linklen = nbspreviewptr - ptr;
}
if (ltreviewptr != 0)
ptr += linklen;
StrBufAppendPrintf(converted_msg, "</a>");
}
- } 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;
}
FreeStrBuf(&BodyArea); // from the original <body> 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, "<br>\n");
- /* Now give back the memory */
+ // Now give back the memory
FreeStrBuf(&converted_msg);
if ((msg != NULL) && (Source == NULL))
free(msg);
}
-/*
- * 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;
}
-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];
#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);
}
-/*
- * 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);
}
-/*
- * 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;
}
-/*
- * 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();
}
-/*
- * 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;
}
-/*
- * 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;
}
-/*
- * 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) {
#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);
}
- /* 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;
}
-/*
- * 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;
}
-/*
- * 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;
}
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;
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;
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];
#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;
}
-/*
- * 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;
}
-/*
- * 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);
}
-/*
- * 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);
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)) {
}
}
- /*
- * 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);
return;
}
- /*
- * DOOOOOO ITTTTT!!!
- */
+ // DOOOOOO ITTTTT!!!
if (!strcasecmp(h->method, "DELETE")) {
dav_delete_message(h, c, msgnum);
}
-/*
- * 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
}
-/*
- * 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");
}
-/*
- * 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;
StrBufAppendPrintf(Buf, "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<D:multistatus " "xmlns:D=\"DAV:\" " "xmlns:C=\"urn:ietf:params:xml:ns:caldav\"" ">");
- /* Transmit the collection resource */
+ // Transmit the collection resource
StrBufAppendPrintf(Buf, "<D:response>");
StrBufAppendPrintf(Buf, "<D:href>");
StrBufXMLEscAppend(Buf, NULL, h->site_prefix, strlen(h->site_prefix), 0);
break;
}
- /* FIXME get the mtime
- StrBufAppendPrintf(Buf, "<D:getlastmodified>");
- escputs(datestring);
- StrBufAppendPrintf(Buf, "</D:getlastmodified>");
- */
+ // FIXME get the mtime
+ // StrBufAppendPrintf(Buf, "<D:getlastmodified>");
+ // escputs(datestring);
+ // StrBufAppendPrintf(Buf, "</D:getlastmodified>");
StrBufAppendPrintf(Buf, "</D:prop>");
StrBufAppendPrintf(Buf, "</D:propstat>");
// 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));
}
-/*
- * 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.
}
-/*
- * 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];
}
-/*
- * 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];