From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 3841 invoked from network); 23 Nov 1999 02:11:17 -0000 Received: from mail.redhat.com (199.183.24.239) by lists.redhat.com with SMTP; 23 Nov 1999 02:11:17 -0000 Received: from ruff.gi.alaska.edu (ruff.gi.alaska.EDU [137.229.30.190]) by mail.redhat.com (8.8.7/8.8.7) with ESMTP id VAA27834 for ; Mon, 22 Nov 1999 21:11:15 -0500 Received: (from dnc@localhost) by ruff.gi.alaska.edu (8.9.3/8.9.3) id RAA10766 for axp-list@redhat.com; Mon, 22 Nov 1999 17:06:51 -0900 Date: Mon, 22 Nov 1999 17:06:51 -0900 From: David Covey Message-Id: <199911230206.RAA10766@ruff.gi.alaska.edu> To: axp-list@redhat.com Subject: binary data files Hi all, I've been using Linux/Alpha for a while now and slowly working on a problem I have with binary data files. I *think* I've figured it out and have a kludge but I'd like to know if someone has come up with a better explanation and/or solution. Specifically I've been having problems reading binary data files with 'variable-length record' format. The records in these files are prefixed and suffixed with a 4-byte integer with a count of the data bytes in the record (excluding the prefix and suffix). I often have data files using this format that have been written on other machines, and so the data may be byte-swapped. That much can be fixed with a compiler option, or a 'dd conv=swab...' command. The prefix/suffix byte-count has an additional twist though, in that it appears to be word-swapped. Hence a record of 13 bytes would have a 4-byte count that, on the Linux/Alpha box, looks like the byte sequence : 13 0 0 0 The same data generated on another type of (big-endian) workstation would have a count : 0 0 0 13 In the case I'm working on now, the actual binary data is byte-swapped but not word-swapped, only the leading and trailing record size count. I've written a small C utility that reads a data file and word-swaps the count, and optionally byte-swaps the data. I'd be happy to make it available if it would help anyone else. Please let me know if this is a previously solved problem, if I've managed to re-invent the wheel, whatever... - Dave