X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fserv_func.c;h=a6c41f711e858a9ec61cc87c88570d2d3cba6450;hb=2c1eedd6a74e856c5c2a48868c987a5ef38680fa;hp=2f6c8073526021482cc519ccfefdebf34c874b97;hpb=ee6d156f84e201b99c0557689389f9ae068647e6;p=citadel.git diff --git a/webcit/serv_func.c b/webcit/serv_func.c index 2f6c80735..a6c41f711 100644 --- a/webcit/serv_func.c +++ b/webcit/serv_func.c @@ -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; } @@ -523,32 +524,41 @@ void server_to_text() int read_server_text(StrBuf *Buf, long *nLines) { wcsession *WCC = WC; + StrBuf *ReadBuf; long nRead; long nTotal = 0; long nlines; nlines = 0; + ReadBuf = NewStrBuf(); while ((WCC->serv_sock!=-1) && - (nRead = StrBuf_ServGetln(Buf), (nRead >= 0) )) + (nRead = StrBuf_ServGetln(ReadBuf), (nRead >= 0) && + ((nRead != 3)||(strcmp(ChrPtr(ReadBuf), "000") != 0)))) { - if (strcmp(ChrPtr(Buf) + nTotal, "000") != 0) { - StrBufCutRight(Buf, nRead); - break; - } + StrBufAppendBuf(Buf, ReadBuf, 0); + StrBufAppendBufPlain(Buf, HKEY("\n"), 0); nTotal += nRead; nlines ++; } - + FreeStrBuf(&ReadBuf); *nLines = nlines; return nTotal; } -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; }