// Functions which handle communication with the Citadel server.
//
-// Copyright (c) 1996-2021 by the citadel.org team
+// Copyright (c) 1996-2024 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.
#include "webcit.h"
-#include "webserver.h"
+
HashList *EmbeddableMimes = NULL;
StrBuf *EmbeddableMimeStrs = NULL;
Buf = NewStrBuf();
- /* Tell the server what kind of richtext we prefer */
+ // Tell the server what kind of richtext we prefer
serv_putbuf(EmbeddableMimeStrs);
StrBuf_ServGetln(Buf);
void DeleteServInfo(ServInfo **FreeMe) {
- if (*FreeMe == NULL)
+ if (*FreeMe == NULL) {
return;
+ }
FreeStrBuf(&(*FreeMe)->serv_nodename);
FreeStrBuf(&(*FreeMe)->serv_humannode);
FreeStrBuf(&(*FreeMe)->serv_fqdn);
*FreeMe = NULL;
}
-/*
- * get info about the server we've connected to
- *
- * browser_host the citadel we want to connect to
- * user_agent which browser uses our client?
- */
+
+// get info about the server we've connected to
+//
+// browser_host the citadel we want to connect to
+// user_agent which browser uses our client?
ServInfo *get_serv_info(StrBuf *browser_host, StrBuf *user_agent) {
ServInfo *info;
StrBuf *Buf;
Buf = NewStrBuf();
- /* Tell the server what kind of client is connecting */
- serv_printf("IDEN %d|%d|%d|%s|%s",
- DEVELOPER_ID,
- CLIENT_ID,
- CLIENT_VERSION,
- ChrPtr(user_agent),
- ChrPtr(browser_host)
- );
+ // Tell the server what kind of client is connecting
+ serv_printf("IDEN 0|0|0|%s|%s", ChrPtr(user_agent), ChrPtr(browser_host));
StrBuf_ServGetln(Buf);
if (GetServerStatus(Buf, NULL) != 2) {
- syslog(LOG_WARNING, "get_serv_info(IDEN): unexpected answer [%s]\n",
- ChrPtr(Buf));
+ syslog(LOG_WARNING, "get_serv_info(IDEN): unexpected answer [%s]\n", ChrPtr(Buf));
FreeStrBuf(&Buf);
return NULL;
}
- /*
- * Tell the server that when we save a calendar event, we
- * want invitations to be generated by the Citadel server
- * instead of by the client.
- */
+ // Tell the server that when we save a calendar event, we
+ // want invitations to be generated by the Citadel server
+ // instead of by the client.
serv_puts("ICAL sgi|1");
StrBuf_ServGetln(Buf);
if (GetServerStatus(Buf, NULL) != 2) {
- syslog(LOG_WARNING, "get_serv_info(ICAL sgi|1): unexpected answer [%s]\n",
- ChrPtr(Buf));
+ syslog(LOG_WARNING, "get_serv_info(ICAL sgi|1): unexpected answer [%s]\n", ChrPtr(Buf));
FreeStrBuf(&Buf);
return NULL;
}
- /* Now ask the server to tell us a little bit about itself... */
+ // Now ask the server to tell us a little bit about itself...
serv_puts("INFO");
StrBuf_ServGetln(Buf);
if (GetServerStatus(Buf, NULL) != 1) {
int short_status;
Buf = NewStrBuf();
WC->connected = 1;
- StrBuf_ServGetln(Buf); /* get the server greeting */
+ StrBuf_ServGetln(Buf); // get the server greeting
short_status = GetServerStatus(Buf, &Status);
FreeStrBuf(&Buf);
- /* Server isn't ready for us? */
+ // Server isn't ready for us?
if (short_status != 2) {
if (Status == 551) {
hprintf("HTTP/1.1 503 Service Unavailable\r\n");
return 1;
}
- /*
- * From what host is our user connecting? Go with
- * the host at the other end of the HTTP socket,
- * unless we are following X-Forwarded-For: headers
- * and such a header has already turned up something.
- */
+ // From what host is our user connecting? Go with
+ // the host at the other end of the HTTP socket,
+ // unless we are following X-Forwarded-For: headers
+ // and such a header has already turned up something.
if ( (!follow_xff) || (StrLength(WC->Hdr->HR.browser_host) == 0) ) {
if (WC->Hdr->HR.browser_host == NULL) {
WC->Hdr->HR.browser_host = NewStrBuf();
StrBufAppendBufPlain(Target, HKEY("<br>"), 0);
}
intext = 1;
- if (isspace(*ptr)) while ((ptr < pte) &&
- ((*ptr == '>') ||
- isspace(*ptr)))
- {
- if (*ptr == '>')
- bq++;
- ptr ++;
- i++;
- }
-
- /*
- * Quoted text should be displayed in italics and in a
- * different colour. This code understands Citadel-style
- * " >" quotes and will convert to <BLOCKQUOTE> tags.
- */
+ if (isspace(*ptr)) {
+ while ((ptr < pte) && ((*ptr == '>') || isspace(*ptr))) {
+ if (*ptr == '>') {
+ bq++;
+ }
+ ptr ++;
+ i++;
+ }
+ }
+
+ // Quoted text should be displayed in italics and in a
+ // different colour. This code understands Citadel-style
+ // " >" quotes and will convert to <BLOCKQUOTE> tags.
if (i > 0) StrBufCutLeft(Line, i);
if (StrLength(Line) == 0)
continue;
- /* Activate embedded URL's */
+ // Activate embedded URL's
UrlizeText(Line1, Line, Line2);
StrEscAppend(Target, Line1, NULL, 0, 0);
}
-
-/*
- * Transmit message text (in memory) to the server.
- */
+// Transmit message text (in memory) to the server.
void text_to_server(char *ptr) {
char buf[256];
int ch, a, pos, len;
}
-/*
- * Transmit message text (in memory) to the server, converting to Quoted-Printable encoding as we go.
- */
+// Transmit message text (in memory) to the server, converting to Quoted-Printable encoding as we go.
void text_to_server_qp(const StrBuf *SendMeEncoded) {
StrBuf *ServBuf;
}
-
-
-/*
- * translate server message output to text (used for editing room info files and such)
- */
+// translate server message output to text (used for editing room info files and such)
void server_to_text() {
char buf[SIZ];
}
-
-
-/*
- * Read text from server, appending to a string buffer until the
- * usual 000 terminator is found. Caller is responsible for freeing
- * the returned pointer.
- */
+// Read text from server, appending to a string buffer until the
+// usual 000 terminator is found. Caller is responsible for freeing
+// the returned pointer.
int read_server_text(StrBuf *Buf, long *nLines) {
StrBuf *ReadBuf;
long nRead;