One little endian question

Brian K. White brian at aljex.com
Mon Mar 3 10:19:37 PST 2008


Let's just say:
Well then use some other field is all, how about @id ... doh, fails for root.


I still don't see what's so hard about writing 2 bytes explicitly and then asking the system "what number is this?"
Or conversely, have the system write a value, and you just look at the first byte of it.

Like the c example from 
http://unixpapa.com/incnote/byteorder.html

---snip---
It's easy enough to write code to check if you are big or little endian. The following function returns true if we are big endian. 
  int am_big_endian()
  {
     long one= 1;
     return !(*((char *)(&one)));
  }
---snip---

ie: write the value "1" into a long, then read back only a char. If you get a 1 you are big-endian. If you get a 0 you are little endian.

That's why I suggested use file-io to write out a 20 byte header, where you explicitly place every byte, then have fp interpret it.
You write out 0x00 0x01 where @xx goes, then lookup that record and test if lookup(@xx) is 1 or 10
(the inverse, yet equivalent of the c test)
Except I was hoping there was a simpler way than creating a whole valid filepro file on the fly.
Laura's trick fills the bill, it just requires an external file to exist along with the processing and assumes that file is correctly formatted for the platform the code is running on.

The only big-endian box I have is an old G3-ppc running osx 10.4 and Ubuntu 7.10 and no filepro binaris for it so I can't test any of this but I would if I could. I hate to say something is simple that I never actually tried. But I just can't accept that this is a problem.

-- 
Brian K. White    brian at aljex.com    http://www.myspace.com/KEYofR
+++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++.
filePro  BBx    Linux  SCO  FreeBSD    #callahans  Satriani  Filk!


----- Original Message ----- 
From: "Kenneth Brody" <kenbrody at bestweb.net>
To: "Jeff Harrison" <jeffaharrison at yahoo.com>
Cc: <filepro-list at lists.celestial.com>
Sent: Monday, March 03, 2008 11:49 AM
Subject: Re: One little endian question


> Quoting Jeff Harrison (Mon, 3 Mar 2008 07:37:33 -0800 (PST)):
> 
>> --- Kenneth Brody <kenbrody at bestweb.net> wrote:
> [...]
>>> Of course, she has the advantage of reading a screen file, which has
>>> a known "magic number" at the start of the file header.  If you don't
>>> mind a little bit of overhead, you could read the header of a known
>>> screen (you could use @FI and @SN) to determine the byte order.  Do
>>> you have a copy of her toolkit?
> [...]
>>
>> Good point - for some reason I was thinking that I
>> couldn't rely on a format file that I provided - but
>> of course anyone running big-endian will need to run
>> swap-cpu anyway - so that will work.
> 
> Well, if you're on a big-endian system, the screen will be big-endian.  I'm
> not sure what swapcpu has to do with things.
> 
>> But, looking at a new @cd should work too, right?
> 
> It will fail every 256 days, the next one being 1-May-2008.  (I leave it
> as an exercise to the reader to figure out why.)
> 
> -- 
> KenBrody at BestWeb dot net        spamtrap: <g8ymh8uf001 at sneakemail.com>
> http://www.hvcomputer.com
> http://www.fileProPlus.com
> _______________________________________________
> Filepro-list mailing list
> Filepro-list at lists.celestial.com
> http://mailman.celestial.com/mailman/listinfo/filepro-list
> 
> 
> 
> -- 
> No virus found in this incoming message.
> Checked by AVG Free Edition. 
> Version: 7.5.516 / Virus Database: 269.21.3/1308 - Release Date: 3/3/2008 10:01 AM
> 
>


More information about the Filepro-list mailing list