X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fserv_func.c;h=66afe5e12e87dd818c95a461d4371fa6f9ec6fc8;hb=HEAD;hp=88af2024f5c8d6dcc6d4324c2f6af25b0ec01c22;hpb=8611acef7ff4213c28ad20ff755d34509870bc96;p=citadel.git
diff --git a/webcit/serv_func.c b/webcit/serv_func.c
index 88af2024f..e987c8216 100644
--- a/webcit/serv_func.c
+++ b/webcit/serv_func.c
@@ -1,12 +1,12 @@
// 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;
@@ -16,7 +16,7 @@ void SetInlinMimeRenderers(void) {
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);
@@ -25,8 +25,9 @@ void SetInlinMimeRenderers(void) {
void DeleteServInfo(ServInfo **FreeMe) {
- if (*FreeMe == NULL)
+ if (*FreeMe == NULL) {
return;
+ }
FreeStrBuf(&(*FreeMe)->serv_nodename);
FreeStrBuf(&(*FreeMe)->serv_humannode);
FreeStrBuf(&(*FreeMe)->serv_fqdn);
@@ -39,12 +40,11 @@ void DeleteServInfo(ServInfo **FreeMe) {
*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;
@@ -53,37 +53,27 @@ ServInfo *get_serv_info(StrBuf *browser_host, StrBuf *user_agent) {
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) {
@@ -181,11 +171,11 @@ int GetConnected (void) {
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");
@@ -205,12 +195,10 @@ int GetConnected (void) {
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();
@@ -283,21 +271,19 @@ void FmOut(StrBuf *Target, const char *align, const StrBuf *Source) {
StrBufAppendBufPlain(Target, HKEY("
"), 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
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 totags. if (i > 0) StrBufCutLeft(Line, i); @@ -310,7 +296,7 @@ void FmOut(StrBuf *Target, const char *align, const StrBuf *Source) { if (StrLength(Line) == 0) continue; - /* Activate embedded URL's */ + // Activate embedded URL's UrlizeText(Line1, Line, Line2); StrEscAppend(Target, Line1, NULL, 0, 0); @@ -330,10 +316,7 @@ void FmOut(StrBuf *Target, const char *align, const StrBuf *Source) { } - -/* - * 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; @@ -374,23 +357,17 @@ void text_to_server(char *ptr) { } -/* - * 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; - ServBuf = StrBufRFC2047encodeMessage(SendMeEncoded); + ServBuf = StrBufQuotedPrintableEncode(SendMeEncoded); serv_putbuf(ServBuf); FreeStrBuf(&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]; @@ -406,13 +383,9 @@ void server_to_text() { } - - -/* - * 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;