[net.unix] Testing to see if a file is ASCII

de@dcl-cs.UUCP (David England) (09/10/85)

In the following piece of program to test for an ASCII file I know that
the commented values are magic numbers from a.out format files but I'm
curious to know what the other values represent ?

/* c is the first character in the file with descriptor f */
/* runs on UNIX 4.2 Vax or Sun */

switch ((c | *f->_ptr << 8) & 0177777) {
	case 0405:
	case 0407: /*magic number*/
	case 0410: /*magic number*/
	case 0411:
	case 0413: /*magic number*/
	case 0177545:
		printf("SomeErrorMessage");
	default:
	      break;
}

All flames to /dev/blackhole.


"I vomit when I see icons!"

-- 
UUCP    : ..!seismo!mcvax!ukc!dcl-cs!de DARPA : de%lancs.comp@ucl-cs		
JANET   : de@uk.ac.lancs.comp           PHONE : +44 524 65201 Ext. 4586
POST    : Univ. of Lancaster, Dept of Computing, Lancaster LA1 2YR, UK.
PROJECT : Alvey ECLIPSE User Interface

geoff@ISM780.UUCP (09/13/85)

de@dcl-cs asks:
>             ... what the other values represent ?
> switch ((c | *f->_ptr << 8) & 0177777) {
>         case 0405:
>         case 0407: /*magic number*/
>         case 0410: /*magic number*/
>         case 0411:
>         case 0413: /*magic number*/
These other values are also magic numbers.  I suspect they're for pdp11
executables, but they might have other applications.
	0405    "Old overlay"
	0411    "Separate I&D"

	 Geoffrey Kimbrough -- Director of Dangerous Activities
	INTERACTIVE Systems Corporation, Santa Monica California.
	    {decvax!vortex || ihnp4!allegra!ima}!ism780!geoff
	     Nothing works, and nobody cares. -- Woody Allen