}
-/**
+/*
* use strbuf as wrapper for a string constant for easy handling
* StringConstant a string to wrap
* SizeOfStrConstant should be sizeof(StringConstant)-1
}
-/**
+/*
* flush the content of a Buf; keep its struct
* buf Buffer to flush
*/
return 0;
}
-/**
+/*
* wipe the content of a Buf thoroughly (overwrite it -> expensive); keep its struct
* buf Buffer to wipe
*/
#ifdef SIZE_DEBUG
int hFreeDbglog = -1;
#endif
-/**
+/*
* Release a Buffer
* Its a double pointer, so it can NULL your pointer
* so fancy SIG11 appear instead of random results
* Simple string transformations *
*******************************************************************************/
-/**
+/*
* Wrapper around atol
*/
long StrTol(const StrBuf *Buf)
return 0;
}
-/**
+/*
* Wrapper around atoi
*/
int StrToi(const StrBuf *Buf)
return 0;
}
-/**
+/*
* Checks to see if the string is a pure number
* Buf The buffer to inspect
* @returns 1 if its a pure number, 0, if not.
* ch the char to search
* returns the number of times ch appears in st
*/
-int haschar(const char *st, int ch)
-{
+int haschar(const char *st, int ch) {
const char *ptr;
int b;
b = 0;
* Determine whether the specified message number is contained within the
* specified sequence set.
*/
-int is_msg_in_sequence_set(const char *mset, long msgnum)
-{
+int is_msg_in_sequence_set(const char *mset, long msgnum) {
int num_sets;
int s;
char setstr[128], lostr[128], histr[128];
* maxlen Size of string buffer
* returns pointer to the source memory right after we stopped reading.
*/
-char *memreadline(char *start, char *buf, int maxlen)
-{
+char *memreadline(char *start, char *buf, int maxlen) {
char ch;
char *ptr;
int len = 0; /* tally our own length to avoid strlen() delays */
* retlen the length of the returned string
* returns a pointer to the source memory right after we stopped reading.
*/
-char *memreadlinelen(char *start, char *buf, int maxlen, int *retlen)
-{
+char *memreadlinelen(char *start, char *buf, int maxlen, int *retlen) {
char ch;
char *ptr;
int len = 0; /* tally our own length to avoid strlen() delays */
return (NULL);
}
+
/*
* bmstrcasestr() -- case-insensitive substring search
*
}
-
-
/*
* bmstrcasestr() -- case-insensitive substring search
*
return (NULL);
}
+
/*
* bmstrcasestr() -- case-insensitive substring search
*
return _cbmstrcasestr_len(text, textlen, pattern, patlen);
}
+
const char *cbmstrcasestr_len(const char *text, size_t textlen, const char *pattern, size_t patlen) {
return _cbmstrcasestr_len(text, textlen, pattern, patlen);
}
+
/*
* Local replacement for controversial C library function that generates
* names for temporary files. Included to shut up compiler warnings.
}
-
/*
* Determine whether the specified message number is contained within the specified set.
* Returns nonzero if the specified message number is in the specified message set string.
int is_msg_in_mset(const char *mset, long msgnum) {
int num_sets;
int s;
- char setstr[SIZ], lostr[SIZ], histr[SIZ]; /* was 1024 */
+ char setstr[SIZ], lostr[SIZ], histr[SIZ];
long lo, hi;
- /*
- * Now set it for all specified messages.
- */
+ // Now set it for all specified messages.
num_sets = num_tokens(mset, ',');
for (s=0; s<num_sets; ++s) {
extract_token(setstr, mset, s, ',', sizeof setstr);
}
-/*
- * searches for a pattern within a search string
- * returns position in string
- */
-int pattern2(char *search, char *patn)
-{
+// searches for a pattern within a search string
+// returns position in string
+int pattern2(char *search, char *patn) {
int a;
int len, plen;
len = strlen (search);
* buf - the string to modify
* len - length of the string.
*/
-void stripltlen(char *buf, int *len)
-{
+void stripltlen(char *buf, int *len) {
int delta = 0;
if (*len == 0) return;
while ((*len > delta) && (isspace(buf[delta]))){
/*
* Convert all whitespace characters in a supplied string to underscores
*/
-void convert_spaces_to_underscores(char *str)
-{
+void convert_spaces_to_underscores(char *str) {
int len;
int i;
/*
* check whether the provided string needs to be qp encoded or not
*/
-int CheckEncode(const char *pch, long len, const char *pche)
-{
+int CheckEncode(const char *pch, long len, const char *pche) {
if (pche == NULL)
pche = pch + len;
while (pch < pche) {
#include "libcitadel.h"
#include <sys/socket.h>
-/**
- * @defgroup URLHandling ParsedURL object to handle connection data
- */
-
-/**
- * @ingroup URLHandling
- * @brief frees a linked list of ParsedURL
- * @param Url (list) of ParsedURL to be freet; Pointer is NULL'ed for the caller.
- */
-void FreeURL(ParsedURL** Url)
-{
+// frees a linked list of ParsedURL
+// Url (list) of ParsedURL to be freet; Pointer is NULL'ed for the caller.
+void FreeURL(ParsedURL** Url) {
if (*Url != NULL) {
FreeStrBuf(&(*Url)->URL);
FreeStrBuf(&(*Url)->UrlWithoutCred);
}
}
-/**
- * @ingroup URLHandling
- * @brief parses the string provided with UrlStr into *Url
- * @param Url on success this contains the parsed object; needs to be free'd by caller.
- * @param UrlStr String we should parse into parts
- * @param DefaultPort Which is the default port here?
- */
-int ParseURL(ParsedURL **Url, StrBuf *UrlStr, unsigned short DefaultPort)
-{
+// parses the string provided with UrlStr into *Url
+// Url on success this contains the parsed object; needs to be free'd by caller.
+// UrlStr String we should parse into parts
+// DefaultPort Which is the default port here?
+int ParseURL(ParsedURL **Url, StrBuf *UrlStr, unsigned short DefaultPort) {
const char *pch, *pPort, *pCredEnd, *pUserEnd;
ParsedURL *url = (ParsedURL *)malloc(sizeof(ParsedURL));
memset(url, 0, sizeof(ParsedURL));
url->af = AF_INET;
url->Port = DefaultPort;
- /*
- * http://username:passvoid@[ipv6]:port/url
- */
- url->URL = NewStrBufDup(UrlStr);
+ url->URL = NewStrBufDup(UrlStr); // http://username:password@[ipv6]:port/url
url->Host = pch = ChrPtr(url->URL);
url->LocalPart = strchr(pch, '/');
if (url->LocalPart != NULL) {
if ((*(url->LocalPart + 1) == '/') &&
- (*(url->LocalPart - 1) == ':')) { /* TODO: find default port for this protocol... */
+ (*(url->LocalPart - 1) == ':')) {
url->Host = url->LocalPart + 2;
url->LocalPart = strchr(url->Host, '/');
if (url->LocalPart != NULL)
pCredEnd = strrchr(ChrPtr(url->URL), '@');
if (pCredEnd >= url->LocalPart)
pCredEnd = NULL;
- if (pCredEnd != NULL)
- {
+ if (pCredEnd != NULL) {
url->User = url->Host;
url->Host = pCredEnd + 1;
pUserEnd = strchr(url->User, ':');
}
if (pPort != NULL)
url->Port = atol(pPort);
- if (url->IPv6)
- {
+ if (url->IPv6) {
url->IsIP = inet_pton(AF_INET6, url->Host, &url->Addr.sin6_addr);
- if (url->IsIP)
- {
+ if (url->IsIP) {
url->Addr.sin6_port = htons(url->Port);
url->Addr.sin6_port = AF_INET6;
}
}
- else
- {
+ else {
url->IsIP = inet_pton(AF_INET, url->Host, &((struct sockaddr_in *)&(url->Addr))->sin_addr);
- if (url->IsIP)
- {
+ if (url->IsIP) {
((struct sockaddr_in *)&(url->Addr))->sin_port = htons(url->Port);
((struct sockaddr_in *)&(url->Addr))->sin_family = AF_INET;
}
return 1;
}
-void CurlPrepareURL(ParsedURL *Url)
-{
+void CurlPrepareURL(ParsedURL *Url) {
if (!strcmp(ChrPtr(Url->URL), "http"))
Url->UrlWithoutCred = NewStrBufPlain(ChrPtr(Url->URL), -1);
else
StrBufAppendPrintf(Url->UrlWithoutCred, "%u", Url->Port);
StrBufAppendBufPlain(Url->UrlWithoutCred, HKEY("/"), 0);
- if (Url->LocalPart)
- {
+ if (Url->LocalPart) {
StrBufAppendBufPlain(Url->UrlWithoutCred, Url->LocalPart, -1, 0);
}
- if (Url->User != NULL)
- {
+ if (Url->User != NULL) {
Url->CurlCreds = NewStrBufPlain(Url->User, -1);
StrBufAppendBufPlain(Url->CurlCreds, HKEY(":"), 0);
if (Url->Pass != NULL)
-//
// Utility functions
-//
// Copyright (c) 1996-2022 by the citadel.org team
-//
-// This program is open source software. Use, duplication, or
-// disclosure are subject to the GNU General Public License v3.
+// This program is open source software. Use, duplication, or disclosure are subject to the GNU General Public License v3.
#include "webcit.h"
// The button bar is a Grid element, and is also a Flexbox container.
+ "<div class=\"ctdl-compose-toolbar\">"
- + "<span class=\"ctdl-msg-button\" onclick=\"mail_save_message()\"><i class=\"fa fa-paper-plane\" style=\"color:green\"></i> " + _("Send message") + "</span>"
+ + "<span class=\"ctdl-msg-button\" onclick=\"mail_send_message()\"><i class=\"fa fa-paper-plane\" style=\"color:green\"></i> " + _("Send message") + "</span>"
+ "<span class=\"ctdl-msg-button\">" + _("Save to Drafts") + "</span>"
+ "<span class=\"ctdl-msg-button\">" + _("Attachments:") + " 0" + "</span>"
+ "<span class=\"ctdl-msg-button\">" + _("Contacts") + "</span>"
}
-// Helper function for mail_save_messages() to extract form values.
+// Helper function for mail_send_messages() to extract form values.
// (We have to replace "|" with "!" because "|" is a field separator in the Citadel protocol)
function msm_field(element_name, separator) {
return (document.getElementById(element_name).innerHTML).replaceAll("|",separator);
// Save the posted message to the server
-function mail_save_message() {
+function mail_send_message() {
document.body.style.cursor = "wait";
url = "/ctdl/r/" + escapeHTMLURI(current_room)
+ "&mailcc=" + msm_field("ctdl-compose-cc-field", ",") // Cc: (if present)
+ "&mailbcc=" + msm_field("ctdl-compose-bcc-field", ",") // Bcc: (if present)
;
+ console.log(url);
boundary = randomString();
body_text =
"--" + boundary + "\r\n"
-/*
- * de/encoding stuff. hopefully mostly to be depricated in favour of subst.c + strbuf
- */
+// de/encoding stuff. hopefully mostly to be depricated in favour of subst.c + strbuf
#define SHOW_ME_VAPPEND_PRINTF
#include <stdio.h>
#include "webcit.h"
-/*
- * remove escaped strings from i.e. the url string (like %20 for blanks)
- */
-long unescape_input(char *buf)
-{
+// remove escaped strings from i.e. the url string (like %20 for blanks)
+long unescape_input(char *buf) {
unsigned int a, b;
char hex[3];
long buflen;
if (buf[a] == '+')
buf[a] = ' ';
if (buf[a] == '%') {
- /* don't let % chars through, rather truncate the input. */
+ // don't let % chars through, rather truncate the input.
if (a + 2 > buflen) {
buf[a] = '\0';
buflen = a;
return a;
}
-/*
- * Copy a string, escaping characters which have meaning in HTML.
- *
- * target target buffer
- * strbuf source buffer
- * nbsp If nonzero, spaces are converted to non-breaking spaces.
- * nolinebreaks if set, linebreaks are removed from the string.
- */
-long stresc(char *target, long tSize, char *strbuf, int nbsp, int nolinebreaks)
-{
+// Copy a string, escaping characters which have meaning in HTML.
+//
+// target target buffer
+// strbuf source buffer
+// nbsp If nonzero, spaces are converted to non-breaking spaces.
+// nolinebreaks if set, linebreaks are removed from the string.
+long stresc(char *target, long tSize, char *strbuf, int nbsp, int nolinebreaks) {
char *aptr, *bptr, *eptr;
*target = '\0';
aptr = strbuf;
bptr = target;
- eptr = target + tSize - 6; /* our biggest unit to put in... */
+ eptr = target + tSize - 6; // our biggest unit to put in...
while ((bptr < eptr) && !IsEmptyStr(aptr) ){
return (bptr - target);
}
-/*
- * static wrapper for ecsputs1
- */
-void escputs(const char *strbuf)
-{
+// static wrapper for escputs1
+void escputs(const char *strbuf) {
StrEscAppend(WC->WBuf, NULL, strbuf, 0, 0);
}
-/*
- * urlescape buffer and print it to the client
- */
-void urlescputs(const char *strbuf)
-{
+// urlescape buffer and print it to the client
+void urlescputs(const char *strbuf) {
StrBufUrlescAppend(WC->WBuf, NULL, strbuf);
}
-/**
- * urlescape buffer and print it as header
- */
-void hurlescputs(const char *strbuf)
-{
+// urlescape buffer and print it as header
+void hurlescputs(const char *strbuf) {
StrBufUrlescAppend(WC->HBuf, NULL, strbuf);
}
-/*
- * Output a string to the client as a CDATA block
- */
-void cdataout(char *rawdata)
-{
+// Output a string to the client as a CDATA block
+void cdataout(char *rawdata) {
char *ptr = rawdata;
wc_printf("<![CDATA[");
}
wc_printf("]]>");
-}
-
+}
\ No newline at end of file