From: Wilfried Goesgens Date: Thu, 28 Jul 2011 12:13:42 +0000 (+0000) Subject: enhance GetServerStatus to GetServerStatusMsg; supply migration define X-Git-Tag: v8.11~538 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=cc1ac05448414ebbdfb65a7f7e1d3081a5618570 enhance GetServerStatus to GetServerStatusMsg; supply migration define GetServerStatusMsg() can now directly add the server reply text after the status code into WC->ImportantMsg. --- diff --git a/webcit/serv_func.c b/webcit/serv_func.c index 2f6c80735..71d5d57da 100644 --- a/webcit/serv_func.c +++ b/webcit/serv_func.c @@ -544,11 +544,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; } diff --git a/webcit/tcp_sockets.h b/webcit/tcp_sockets.h index 4219fe8bd..1c8591e03 100644 --- a/webcit/tcp_sockets.h +++ b/webcit/tcp_sockets.h @@ -2,7 +2,20 @@ int uds_connectsock(char *); int tcp_connectsock(char *, char *); int serv_getln(char *strbuf, int bufsize); int StrBuf_ServGetln(StrBuf *buf); -int GetServerStatus(StrBuf *Line, long* FullState); + +/** + * @brief parse & check the server reply + * @param Line the line containing the server reply + * @param FullState if you need more than just the major number, this is returns it. Ignored if NULL. + * @param PutImportantMessage if you want to forward the text part of the server reply to the user, specify 1; + * the result will be put into the 'Important Message' framework. + * @param MajorOK in case of which major number not to put the ImportantMessage? 0 for all. + * @return the most significant digit of the server status + * / +int GetServerStatusMsg(StrBuf *Line, long* FullState, int PutImportantMessage, int MajorOK); +/* to migrate old calls.... */ +#define GetServerStatus(a, b) GetServerStatusMsg(a, b, 0, 0) + int serv_puts(const char *string); int serv_write(const char *buf, int nbytes);