Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!sun-barr!lll-winken!arisia!sgi!shinobu!odin!sgi.com!karlton From: karlton@sgi.com (Phil Karlton) Newsgroups: comp.windows.x Subject: Re: Storing data structure as a property Keywords: properties, XChangeProperty, selections Message-ID: <1936@odin.SGI.COM> Date: 12 Dec 89 22:25:01 GMT References: <1989Nov29.072922.18738@ntvax.uucp> Sender: news@odin.SGI.COM Reply-To: karlton@sgi.com Organization: Silicon Graphics, WorkGroup Products Division Lines: 53 In article <1989Nov29.072922.18738@ntvax.uucp>, doug@ntvax.uucp (Douglas Scott) writes: > I have an application in which I wish to transfer a structure containing some > data between two instances of the same application, using the Selection > mechanism. It is a small structure containing the name and size of a > temporary file (created by the requestee) wthat will be read by the requestor. > Since none of the standard format types or Atoms match what I am doing, I > figured I would just treat the struct as if it were just a string of raw > chars (as far as the property was concerned) and then recast it after it > is retrieved by the requestor: > Is there a better way to send this data structure than as a char array? > Is there a format or size problem here? > Am I trying to do something illegal, and if so, why cant you send arbitrary > chunks of data as chars and recast on the other side? I have my own Atom > type for this that I create with XInternAtom, so I am sure to send and recieve > something that both sides recognize. I have no idea why your application was being killed or why changing the cast would fix this, but I would like to address the property you are using. It seems a little odd to me that your structure will only hold a fixed length file name. However, you know your application, and maybe that is appropriate. The principle problem is that you have enclosed an integer (probably 32 bits wide) into the same data structure with the file name. This will not work across applications that are running on different endian machines. There are two straightforward ways of solving this. One is to convert the length into a string, and bundle the two "strings" into a single text property by using XStringListToTextProperty and XSetTextProperty. (I can hear the people complaining about the runtime cost of doing the sprintf and the atoi. Compare that to the cost sending a packet.) The second is to use the MULTIPLE target and get both the FILE_NAME and LENGTH targets converted with a single request. See the ICCCM for details. This would imply that FILE_NAME as a target has no other meaning within the context of your application Note that the target of a selecton and the type of the returned value need not be the same. PK -- Phil Karlton karlton@sgi.com Silicon Graphics Computer Systems 415-335-1557 2011 N. Shoreline Blvd. Mountain View, CA 94039