From owner-freebsd-questions Wed Sep 15 14:45:31 1999 Delivered-To: freebsd-questions@freebsd.org Received: from cc942873-a.ewndsr1.nj.home.com (cc942873-a.ewndsr1.nj.home.com [24.2.89.207]) by hub.freebsd.org (Postfix) with ESMTP id C5EA814F4F for ; Wed, 15 Sep 1999 14:45:27 -0700 (PDT) (envelope-from cjc@cc942873-a.ewndsr1.nj.home.com) Received: (from cjc@localhost) by cc942873-a.ewndsr1.nj.home.com (8.9.3/8.8.8) id RAA28463 for freebsd-questions@FreeBSD.ORG; Wed, 15 Sep 1999 17:48:14 -0400 (EDT) (envelope-from cjc) From: "Crist J. Clark" Message-Id: <199909152148.RAA28463@cc942873-a.ewndsr1.nj.home.com> Subject: Reading 'Foreign' Binaries To: freebsd-questions@FreeBSD.ORG (FreeBSD Questions) Date: Wed, 15 Sep 1999 17:48:14 -0400 (EDT) Reply-To: cjclark@home.com X-Mailer: ELM [version 2.4ME+ PL54 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG I have large (100s MB) files that are written in binary formats. That is, structures from C programs are just dumped to files using write(2). All of them are produced on SGIs (MIPS processor), which, like most computers, have the opposite endian convention than i386s. I have never had to deal with this issue before and have not been able to get this help from my usual C resources. I found the htonl, htons, ntohl, and ntohs family of functions, but they only seem to want to help with int's. The structures I want to read are full of int's, float's, double's, and char's. Looking over what happens when I write(2) float's from both platforms has not been particularly enlightening yet. I probably could figure this out given the time, but I would have to guess this has been dealt with many times before. Why re-invent the wheel? Can anyone point me in the right direction or offer direct help? Thanks. -- Crist J. Clark cjclark@home.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message