]> code.citadel.org Git - citadel.git/blobdiff - webcit/serv_func.c
If we disconnect the server, clean up thoroughly, so we don't struggle over half...
[citadel.git] / webcit / serv_func.c
index 14a4d655937151e456e1269cad7c6ea03d20fd22..873a3ffde67114687c9492af222b5273a31a1e0a 100644 (file)
@@ -172,6 +172,7 @@ int GetConnected (void)
                WCC->serv_sock = tcp_connectsock(ctdlhost, ctdlport);
        
        if (WCC->serv_sock < 0) {
+               WCC->connected = 0;
                FreeStrBuf(&WCC->ReadBuf);
                return 1;
        }
@@ -257,12 +258,12 @@ int GetConnected (void)
  *  Read Citadel variformat text and spit it out as HTML.
  *  align html align string
  */
-inline void fmout(char *align)
+inline void fmout(const char *align)
 {
        _fmout(WC->WBuf, align);
 }
 
-void _fmout(StrBuf *Target, char *align)
+void _fmout(StrBuf *Target, const char *align)
 {
        int intext = 0;
        int bq = 0;
@@ -303,7 +304,7 @@ void _fmout(StrBuf *Target, char *align)
        wc_printf("</div><br>\n");
 }
 
-void FmOut(StrBuf *Target, char *align, StrBuf *Source)
+void FmOut(StrBuf *Target, const char *align, const StrBuf *Source)
 {
        const char *ptr, *pte;
        const char *BufPtr = NULL;
@@ -544,11 +545,19 @@ int read_server_text(StrBuf *Buf, long *nLines)
 }
 
 
-int GetServerStatus(StrBuf *Line, long* FullState)
+int GetServerStatusMsg(StrBuf *Line, long* FullState, int PutImportantMessage, int MajorOK)
 {
+       int rc;
        if (FullState != NULL)
                *FullState = StrTol(Line);
-       return ChrPtr(Line)[0] - 48;
+       rc = ChrPtr(Line)[0] - 48;
+       if ((!PutImportantMessage) || 
+           (MajorOK == rc)||
+           (StrLength(Line) <= 4))
+               return rc;
+
+       AppendImportantMessage(ChrPtr(Line) + 4, StrLength(Line) - 4);
+       return rc;
 }