]> code.citadel.org Git - citadel.git/commitdiff
Implemented MultilineToList
authorArt Cancro <ajc@citadel.org>
Sat, 13 Mar 1999 01:22:14 +0000 (01:22 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 13 Mar 1999 01:22:14 +0000 (01:22 +0000)
daphne/citclient.cpp
daphne/utils.c

index da65682e8a4d3994c43a385be0b966be715aefaf..a4d49856fc83cbb213967651462dc9566b56e70b 100644 (file)
@@ -81,6 +81,7 @@ int CitClient::serv_trans(
                        ) {
 
        int first_digit;
+        int i;
        wxString buf;
        bool express_messages_waiting = FALSE;
 
@@ -97,7 +98,10 @@ int CitClient::serv_trans(
                        xferbuf.Add(buf);
                }
        } else if (first_digit == 4) {          // SEND_LISTING
-               // FIX do this!!
+               for (i=0; i<xferbuf.Number(); ++i) {
+                       buf.Printf("%s", (wxString *)xferbuf.Nth(i)->GetData());
+                       serv_puts(buf);
+               }
                serv_puts("000");
        }
 
index 4be5f9c8f3cfb2f5925141d8df679fc9a4fcda08..ccbee8ab57f45527f2d3c4e51dd7cf1168e507d6 100644 (file)
@@ -1,7 +1,14 @@
+// utils.c: utility functions not belonging to any particular class
 
 #include <wx/wx.h>
 #include "utils.h"
 
+
+// The following two functions convert between the wxStringList class used for
+// text transfers to and from the Citadel server, and the wxString class used
+// for the contents of a wxTextCtrl.
+
+
 void ListToMultiline(wxString& outputbuf, wxStringList inputlist) {
        int i;
        wxString buf;
@@ -14,6 +21,37 @@ void ListToMultiline(wxString& outputbuf, wxStringList inputlist) {
        }
 }
 
+
+void MultilineToList(wxStringList& outputlist, wxString inputbuf) {
+       wxString buf;
+       int pos;
+       
+       buf = inputbuf;
+       outputlist.Clear();
+
+       while (buf.Length() > 0) {
+               // First try to locate a line break
+               pos = buf.Find('\n', FALSE);
+               if ( (pos >=0) && (pos < 256) ) {
+                       outputlist.Add(buf.Mid(0, pos-1));
+                       buf = buf.Mid(pos+1);
+               } else {
+               // Otherwise, try to find a space
+                       pos = buf.Mid(0, 256).Find(' ', TRUE);
+                       if ( (pos >=0) && (pos < 256) ) {
+                               outputlist.Add(buf.Mid(0, pos-1));
+                               buf = buf.Mid(pos+1);
+                       } else {
+                               pos = 255;
+                               outputlist.Add(buf.Mid(0, pos-1));
+                               buf = buf.Mid(pos);
+                       }
+               }
+       }
+}
+
+
+
 // Extract a field from a string returned by the server
 //
 void extract(wxString& outputbuf, wxString inputbuf, int parmnum) {
@@ -25,7 +63,7 @@ void extract(wxString& outputbuf, wxString inputbuf, int parmnum) {
        for (a=0; a<parmnum; ++a) {
                p = outputbuf.First('|');
                if (p >= 0) {
-                       outputbuf = outputbuf.Mid(p+1, STRING_MAXLEN);
+                       outputbuf = outputbuf.Mid(p+1, 32767);
                }
        }