home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Distributions / ucb / spencer_2bsd.tar.gz / 2bsd.tar / src / pi1 / yymain.c < prev   
C/C++ Source or Header  |  1980-02-17  |  1KB  |  85 lines

  1. /* Copyright (c) 1979 Regents of the University of California */
  2. #
  3. /*
  4.  * pi - Pascal interpreter code translator
  5.  *
  6.  * Charles Haley, Bill Joy UCB
  7.  * Version 1.2 January 1979
  8.  *
  9.  *
  10.  * pxp - Pascal execution profiler
  11.  *
  12.  * Bill Joy UCB
  13.  * Version 1.2 January 1979
  14.  */
  15.  
  16. #include "0.h"
  17.  
  18. int    line 1;
  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.     /*
  29.      * Initialize the clusters
  30.      */
  31.     initstring();
  32.     inittree();
  33.     initnl();
  34.  
  35.     /*
  36.      * Process the input
  37.      */
  38.     receive();
  39.     /* no return */
  40. }
  41.  
  42. static
  43. struct {
  44.     int magic;
  45.     int txt_size;
  46.     int data_size;
  47. } header;
  48.  
  49. magic()
  50. {
  51.     int buf[512];
  52.     register int hf, i;
  53.  
  54.     hf = open("/usr/lib/px_header", 0);
  55.     if (hf >= 0 && read(hf, buf, 1024) > 16) {
  56.         header.magic = buf[0];
  57.         header.txt_size = buf[1];
  58.         header.data_size = buf[2];
  59.         for (i = 0; i < 512; i++)
  60.             word(buf[i]);
  61.     }
  62.     close(hf);
  63. #ifdef DEBUG
  64.     word(hp21mx ? 0403 : 0404);
  65. #else
  66.     word(0404);
  67. #endif
  68. }
  69.  
  70. magic2()
  71. {
  72.     int i;
  73.  
  74.     pflush();
  75.     if (header.magic != 0407)
  76.         return;
  77.     seek(ofil, 0, 0);
  78.     header.data_size = lc - header.txt_size;
  79.     header.data_size =- 16;
  80.     write(ofil, &header, sizeof header);
  81.     seek(ofil, 1022, 0);
  82.     i = ((int) lc) - 1024;
  83.     write(ofil, &i, 2);
  84. }
  85.