jeremy@bbird4.prime.com (Jeremy Nussbaum) (04/13/90)
I would like to get notes using the same nfs mounted spool directory. Notes outputs nested structures and reads them back in. The sizeof operator returns different lengths for some of the structures. Is there some way to make the sun3 and sun4 versions write and read the same nested structures? Is there a generally accepted and portable way of doing this in general? Please email replies to jeremy@jeremy.prime.com. Thanks, Jeremy Nussbaum Prime computer
aperez@cs.utexas.edu (Arturo Perez x6739) (04/14/90)
From article <JEREMY.90Apr12181201@bbird4.prime.com>, by jeremy@bbird4.prime.com (Jeremy Nussbaum): > I would like to get notes using the same nfs mounted spool directory. > Notes outputs nested structures and reads them back in. The sizeof > operator returns different lengths for some of the structures. > Is there some way to make the sun3 and sun4 versions write and read > the same nested structures? Is there a generally accepted and portable > way of doing this in general? The best way to do this is to output self-describing data. That is where you keep on disk information describing the form of the data file. This is also the least practical :-) The next best way to handle this problem is to change the output routines from something like struct foo data; . . . write (fd, &data, sizeof(data); /* I hope you know what I mean */ to write (fd, &data.field1, sizeof(data.field1)); write (fd, &data.field2, sizeof(data.field2)); write (fd, &data.field3, sizeof(data.field3)); .... and then to read() them in the same way. This just happens to work because Sparc and 68000 have the same format integers. If there are floating numbers I'm not sure if there will be a problem. Another, less reliable, way to do it is to move around structure members so that the padding which causes the problem is the same in both cases. The practicality of this depends on how well you know the 2 machines and how often the structures are likely to change. Arturo Perez ComputerVision, a division of Prime aperez@cvbnet.prime.com Too much information, like a bullet through my brain -- The Police