Pristine Ack-5.5
[Ack-5.5.git] / lang / basic / src / initialize.c
1 /*
2  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3  * See the copyright notice in the ACK home directory, in the file "Copyright".
4  */
5
6 #include "bem.h"
7
8 #ifndef NORSCID
9 static char rcs_id[] = "$Id: initialize.c,v 1.6 1994/06/24 11:30:55 ceriel Exp $";
10 #endif
11
12 /* generate temporary files etc */
13
14 File    *datfile;
15
16
17
18 initialize()
19 {
20         register char *cindex, *cptr;
21         int result1, result2;
22
23         /* Find the basename */
24         /* Strip leading directories */
25         cindex= (char *)0;
26         for ( cptr=program; *cptr; cptr++ ) if ( *cptr=='/' ) cindex=cptr;
27         if ( !cindex ) cindex= program;
28         else {
29                 cindex++;
30                 if ( !*cindex ) {
31                         warning("Null program name, assuming \"basic\"");
32                         cindex= "basic";
33                 }
34         }
35         cptr=datfname;
36         while ( *cptr++ = *cindex++ );
37         /* Strip trailing suffix */
38         if ( cptr>datfname+3 && cptr[-3]=='.' ) cptr[-3]=0;
39         strcat(datfname,".d");
40         C_init((arith)BEMINTSIZE, (arith)BEMPTRSIZE);
41         result1 = sys_open(inpfile, OP_READ, &yyin);
42         result2 = C_open(outfile);
43         if ( result1==0 || result2== 0 )
44                 fatal("Improper file permissions");
45         C_magic();
46         fillkex();      /* initialize symbol table */
47         C_ms_emx((arith)BEMINTSIZE,(arith)BEMPTRSIZE);
48         initdeftype();  /* set default symbol declarers */
49 }