From b4e49a8d3954d7d0adb3b3397a9d6a4f93a6f5ff Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 2 Jan 2024 16:57:06 -0500 Subject: [PATCH] serv_func.c: simplify IDEN command Remove parameters no longer used --- webcit/serv_func.c | 113 +++++++++++++++++---------------------------- 1 file changed, 43 insertions(+), 70 deletions(-) diff --git a/webcit/serv_func.c b/webcit/serv_func.c index 02e687946..10bea4657 100644 --- a/webcit/serv_func.c +++ b/webcit/serv_func.c @@ -1,6 +1,6 @@ // 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. @@ -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 to
tags. 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,9 +357,7 @@ 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; @@ -386,11 +367,7 @@ void text_to_server_qp(const StrBuf *SendMeEncoded) { } - - -/* - * 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; -- 2.30.2