-char *read_server_text(void) {
- char *text = NULL;
- size_t bytes_allocated = 0;
- size_t bytes_read = 0;
- int linelen;
- char buf[SIZ];
-
- text = malloc(SIZ);
- if (text == NULL) {
- return(NULL);
- }
- text[0] = 0;
- bytes_allocated = SIZ;
-
- while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
- linelen = strlen(buf);
- buf[linelen] = '\n';
- buf[linelen+1] = 0;
- ++linelen;
-
- if ((bytes_read + linelen) >= (bytes_allocated - 2)) {
- bytes_allocated = 2 * bytes_allocated;
- text = realloc(text, bytes_allocated);
- }
-
- strcpy(&text[bytes_read], buf);
- bytes_read += linelen;
+StrBuf *read_server_text(long *nLines)
+{
+ struct wcsession *WCC = WC;
+ StrBuf *Buf;
+ long nRead;
+ long nlines;
+ const char *buf;
+
+ Buf = NewStrBuf();
+ buf = ChrPtr(Buf);
+ nlines = 0;
+ while ((WCC->serv_sock!=-1) &&
+ (nRead = StrBuf_ServGetln(Buf)),
+ (nRead >= 0) &&
+ (buf += nRead), (strcmp(buf, "000") != 0)) {
+
+ nlines ++;