/* Copyright (c) 1979 Regents of the University of California */
static char sccsid
[] = "@(#)int.c 1.4 %G%";
* px - interpreter for Berkeley Pascal
* Version 3.0 Winter 1979
* Original version for the PDP 11/70 authored by:
* Bill Joy, Charles Haley, Ken Thompson
* Rewritten for VAX 11/780 by Kirk McKusick
register char *objprog
, *file
;
register long bytesread
, block
;
* Determine how PX was invoked, and how to process the program
if (_argv
[0][0] == '-' && _argv
[0][1] == 'o')
else if (_argv
[1][0] != '-')
else if (_argv
[1][1] == 0)
fputs("Improper specification of object file to PX\n",stderr
);
* Process program header information
read(pipe
,&pxhd
,sizeof(struct pxhdr
));
fseek(prog
,(long)(HEADER_BYTES
-sizeof(struct pxhdr
)),0);
fread(&pxhd
,sizeof(struct pxhdr
),1,prog
);
if (pxhd
.maketime
< createtime
)
fprintf(stderr
,"%s is obsolete and must be recompiled\n",file
);
if (pxhd
.magicnum
!= MAGICNUM
)
fprintf(stderr
,"%s is not a Pascal interpreter file\n",file
);
* Load program into memory
objprog
= malloc((int)pxhd
.objsize
);
block
= read(pipe
,(int)(objprog
+bytesread
),pipesize
);
bytesread
= fread(objprog
,1,(int)pxhd
.objsize
,prog
);
if (bytesread
!= pxhd
.objsize
)
fprintf(stderr
,"Read error occurred while loading %s\n",file
);
fputs("Execution begins...\n",stderr
);
* set interpreter to catch expected signals and begin interpretation
if (signal(SIGINT
,SIG_IGN
) != SIG_IGN
)
* reset signals, deallocate memory, and exit normally