From b803e2eb752d2bc0abb6fa4e13f60848ba64f1ce Mon Sep 17 00:00:00 2001
From: pw <pw>
Date: Mon, 14 Feb 2000 11:52:25 +0000
Subject: [PATCH] Add code to implement sending long strings to the motifd
 server. Support for the reverse of this (server sending long strings to
 client) should come soon.

---
 motif/lisp/conversion.lisp | 14 +++++++++++---
 motif/server/datatrans.c   | 23 ++++++++++++++++-------
 2 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/motif/lisp/conversion.lisp b/motif/lisp/conversion.lisp
index 5564f3887..6a979e7c1 100644
--- a/motif/lisp/conversion.lisp
+++ b/motif/lisp/conversion.lisp
@@ -5,7 +5,7 @@
 ;;; Carnegie Mellon University, and has been placed in the public domain.
 ;;;
 (ext:file-comment
-  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/motif/lisp/conversion.lisp,v 1.3 1994/10/31 04:54:48 ram Exp $")
+  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/motif/lisp/conversion.lisp,v 1.4 2000/02/14 11:52:25 pw Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -201,8 +201,16 @@
 	      (packet-write-string (message-fill-packet message)
 				   string 0 length))
 	     (t
-	      (break "Attempt to write a string larger than *packet-size*.
-		      Come back later to get this to work.")))
+	      (do ((next 0)
+		   (len (min length (- *packet-size* (packet-length packet)))
+			(min length (- *packet-size* (packet-length packet)))))
+		  ((not (plusp length)))
+		(packet-write-string packet string next len)
+		(incf next len)
+		(decf length len)
+		(when (plusp length)
+		  (message-add-packet message)
+		  (setf packet (message-fill-packet message))))))
 	    (let ((pad (- 4 (mod (packet-fill packet) 4))))
 	      (unless (> pad 3)
 		(dotimes (i pad)
diff --git a/motif/server/datatrans.c b/motif/server/datatrans.c
index 99aa42330..4d7cbb98b 100644
--- a/motif/server/datatrans.c
+++ b/motif/server/datatrans.c
@@ -1,6 +1,6 @@
 /*
 
- $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/motif/server/datatrans.c,v 1.6 1997/12/31 18:57:53 pw Exp $
+ $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/motif/server/datatrans.c,v 1.7 2000/02/14 11:52:25 pw Exp $
 
  This code was written as part of the CMU Common Lisp project at
  Carnegie Mellon University, and has been placed in the public domain.
@@ -280,14 +280,23 @@ String really_read_string(message_t message,int length)
   int pad,i;
   packet_t packet=message->packets;
   String string;
-
-  /* Check to see if the string is in this packet or not */
-  if( length > packet->length-(packet->fill-packet->data) )
+  if( length <= packet->length - (packet->fill - packet->data)){
+    string = packet->fill;
+    packet->fill += length;
+  }
+  else if (length < (PACKET_SIZE - HEADER_LENGTH)){
     packet = message->packets = packet->next;
+    string = packet->fill;
+    packet->fill += length;
+  }
+  else {
+    string = XtMalloc(length * sizeof(*string));
+    register_garbage(string, GarbageData);
+    for(i=0; i<length; i++)
+      string[i] = message_get_byte(message);
+    packet = message->packets;
+  }
 
-  /***** We will IGNORE strings spanning packets for now *******/
-  string = packet->fill;
-  for(i=0;i<length;i++) packet->fill++;
   /*
    * This is a pretty gross way of finding out how many padding bytes
    * there should be.  The outermost %4 should perhaps be replaced with
-- 
GitLab