WCC->serv_sock = tcp_connectsock(ctdlhost, ctdlport);
if (WCC->serv_sock < 0) {
+ WCC->connected = 0;
FreeStrBuf(&WCC->ReadBuf);
return 1;
}
* 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;
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;
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;
}