# 2.11BSD#431 - /usr/src/ucb/PORT/pascal/src/yymain.c

##### Functions

    copyfile          X
    magic             X
    magic2            X
    writef            X
    yymain            X

       1: /*
       2:  * Copyright (c) 1980 Regents of the University of California.
       3:  * All rights reserved.  The Berkeley software License Agreement
       4:  * specifies the terms and conditions for redistribution.
       5:  */
       6:
       7: #ifndef lint
       8: static char sccsid[] = "@(#)yymain.c	5.1 (Berkeley) 6/5/85";
       9: #endif not lint
      10:
      11: #include "whoami.h"
      12: #include "0.h"
      13: #include "tree_ty.h"    /* must be included for yy.h */
      14: #include "yy.h"
      15: #include <a.out.h>
      16: #include "objfmt.h"
      17: #include <signal.h>
      18: #include "config.h"
      19:
      20: /*
      21:  * Yymain initializes each of the utility
      22:  * clusters and then starts the processing
      23:  * by calling yyparse.
      24:  */
      25: yymain()
      26: {
      27:
      28: #ifdef OBJ
      29: /*
      30:  * initialize symbol table temp files
      31:  */
      32:     startnlfile();
      33: #endif
      34:     /*
      35: 	 * Initialize the scanner
      36: 	 */
      37: #ifdef PXP
      38:     if (bracket == 0) {
      39: #endif
      40:         if (getline() == -1) {
      41:             Perror(filename, "No lines in file");
      42:             pexit(NOSTART);
      43:         }
      44: #ifdef PXP
      45:     } else
      46:         yyline = 0;
      47: #endif
      48:
      49: #ifdef PI
      50: #   ifdef OBJ
      51:     magic();
      52: #   endif OBJ
      53: #endif
      54:     line = 1;
      55:     errpfx = 'E';
      56:     /*
      57: 	 * Initialize the clusters
      58: 	 *
      59: 	initstring();
      60: 	 */
      61:     inithash();
      62:     inittree();
      63: #ifdef PI
      64:     initnl();
      65: #endif
      66:
      67:     /*
      68: 	 * Process the input
      69: 	 */
      70:     yyparse();
      71: #ifdef PI
      72: #   ifdef OBJ
      73:
      74:     /*
      75: 	 * save outermost block of namelist
      76: 	 */
      77:     savenl(NLNIL);
      78:
      79:     magic2();
      80: #   endif OBJ
      81: #   ifdef DEBUG
      82:     dumpnl(NLNIL);
      83: #   endif
      84: #endif
      85:
      86: #ifdef PXP
      87:     prttab();
      88:     if (onefile) {
      89:         extern int outcol;
      90:
      91:         if (outcol)
      92:             pchr('\n');
      93:         flush();
      94:         if (eflg) {
      95:             writef(2, "File not rewritten because of errors\n");
      96:             pexit(ERRS);
      97:         }
      98:         (void) signal(SIGHUP, SIG_IGN);
      99:         (void) signal(SIGINT, SIG_IGN);
     100:         copyfile();
     101:     }
     102: #endif
     103:     pexit(eflg ? ERRS : AOK);
     104: }
     105:
     106: #ifdef PXP
     107: copyfile()
     108: {
     109:     extern int fout[];
     110:     register int c;
     111:
     112:     (void) close(1);
     113:     if (creat(firstname, 0644) != 1) {
     114:         perror(firstname);
     115:         pexit(ERRS);
     116:     }
     117:     (void) lseek(fout[0], 0l, 0);
     118:     while ((c = read(fout[0], &fout[3], 512)) > 0) {
     119:         if (write(1, &fout[3], c) != c) {
     120:             perror(firstname);
     121:             pexit(ERRS);
     122:         }
     123:     }
     124: }
     125: #endif
     126:
     127:
     128: #ifdef PI
     129: #ifdef OBJ
     130:
     131: static
     132: struct exec magichdr;
     133:
     134: magic()
     135: {
     136:
     137:     short       buf[HEADER_BYTES / sizeof ( short )];
     138:     unsigned    *ubuf = (unsigned *) buf;
     139:     register int    hf, i;
     140:
     141:     hf = open(px_header,0);
     142:     if (hf >= 0 && read(hf, (char *) buf, HEADER_BYTES) > sizeof(struct exec)) {
     143:         magichdr.a_magic = ubuf[0];
     144:         magichdr.a_text = ubuf[1];
     145:         magichdr.a_data = ubuf[2];
     146:         magichdr.a_bss = ubuf[3];
     147:         magichdr.a_syms = ubuf[4];
     148:         magichdr.a_entry = ubuf[5];
     149:         magichdr.a_trsize = ubuf[6];
     150:         magichdr.a_drsize = ubuf[7];
     151:         for (i = 0; i < HEADER_BYTES / sizeof ( short ); i++)
     152:             word(buf[i]);
     153:     }
     154:     (void) close(hf);
     155: }
     156: #endif OBJ
     157:
     158: #ifdef OBJ
     159: magic2()
     160: {
     161:     struct pxhdr pxhd;
     162:     extern long lseek();
     163:
     164:     if  (magichdr.a_magic != 0407)
     165:         panic ( "magic2" );
     166:     pflush();
     167:     magichdr.a_data = ( unsigned ) lc - magichdr.a_text;
     168:     magichdr.a_data -= sizeof (struct exec);
     169:     pxhd.objsize = ( ( unsigned ) lc) - HEADER_BYTES;
     170:     pxhd.symtabsize = nlhdrsize();
     171:     magichdr.a_data += pxhd.symtabsize;
     172:     (void) time((long *) (&pxhd.maketime));
     173:     pxhd.magicnum = MAGICNUM;
     174:     (void) lseek(ofil, 0l, 0);
     175:     write(ofil, (char *) (&magichdr), sizeof(struct exec));
     176:     (void) lseek(ofil, ( long ) ( HEADER_BYTES - sizeof ( pxhd ) ) , 0);
     177:     write(ofil, (char *) (&pxhd), sizeof (pxhd));
     178: }
     179: #endif OBJ
     180: #endif
     181:
     182: #ifdef PXP
     183: writef(i, cp)
     184: {
     185:
     186:     write(i, cp, strlen(cp));
     187: }
     188: #endif

#### Defined functions

copyfile defined in line 107; used 1 times

- in line 100

magic defined in line 134; used 1 times

- in line 51

magic2 defined in line 159; used 1 times

- in line 79

writef defined in line 183; used 1 times

- in line 95

yymain defined in line 25; used 1 times

- in /usr/src/ucb/PORT/pascal/src/main.c line 323

#### Defined variables

magichdr defined in line 132; used 14 times

- in line 143-150(8), 164-175(6)

sccsid defined in line 8; never used

Last modified: 1985-06-06 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 971 |