enhance GetServerStatus to GetServerStatusMsg; supply migration define
authorWilfried Goesgens <dothebart@citadel.org>
Thu, 28 Jul 2011 12:13:42 +0000 (12:13 +0000)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 4 Sep 2011 21:43:59 +0000 (21:43 +0000)
GetServerStatusMsg() can now directly add the server reply text after the status code into WC->ImportantMsg.

webcit/serv_func.c
webcit/tcp_sockets.h

index 2f6c8073526021482cc519ccfefdebf34c874b97..71d5d57daa6eafd1ab2fdf2c7560381e40aea209 100644 (file)
@@ -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;
 }
 
 
index 4219fe8bd16890109ed623f1af0fc6e1293d489f..1c8591e033bba49062c3aeabcbada6e2158746d0 100644 (file)
@@ -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);