Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site druxu.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!ihnp4!drutx!druxu!tll From: tll@druxu.UUCP (LaidigTL) Newsgroups: net.unix-wizards Subject: Re: magic numbers Message-ID: <1006@druxu.UUCP> Date: Mon, 5-Mar-84 23:48:26 EST Article-I.D.: druxu.1006 Posted: Mon Mar 5 23:48:26 1984 Date-Received: Tue, 6-Mar-84 06:57:31 EST References: <2639@alice.UUCP>, <215@masscomp.UUCP> Organization: AT&T Information Systems Laboratories, Denver Lines: 19 One little annoyance that appears with using "#!" as a magic number is the old byte-ordering problem. The magic number for an executable file is defined to be a short int (maybe unsigned, I forget), so that the old octal 407 is ^G^A on a PDP-11 or a VAX, but is ^A^G on some other machines. Similarly, depending on your machine, #! can have either of two values. You can get around this in several (semi-) portable ways, for instance: 1) Have the kernel do a strncmp to test against #!, and integer tests for the magic numbers of binary executable files. This is less efficient than is nice. 2) Test for the #! with an integer test for equality with '#!' if you believe in the portability of this. Tom Laidig AT&T Information Systems Laboratories, Denver ...!ihnp4!druxu!tll