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 / main.c < prev    next >
C/C++ Source or Header  |  1980-02-17  |  1KB  |  89 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. #include "0.h"
  11.  
  12. #define    INTR    2
  13.  
  14. int    onintr();
  15.  
  16. #ifdef DEBUG
  17. main(argc)
  18.     int argc;
  19. #else
  20. main()
  21. #endif
  22. {
  23.     int intr;
  24.  
  25. #ifdef DEBUG
  26.     hp21mx = argc > 1;
  27. #endif
  28.     intr = signal(INTR, 1);
  29.     if (intr == 0)
  30.         signal(INTR, onintr);
  31. #ifdef DEBUG
  32.     dprintf("PI1 initialized\n");
  33. #endif
  34.     yymain();
  35.     /* no return */
  36. }
  37.  
  38. /*
  39.  * Buffer for putchar
  40.  */
  41. char    pcbuf[128];
  42. char    *pcbp pcbuf;
  43.  
  44. /*
  45.  * Line buffered putchar for pi.
  46.  */
  47. putchar(c)
  48.     char c;
  49. {
  50.  
  51.     *pcbp++ = c;
  52.      if (c == '\n' || pcbp == &pcbuf[sizeof pcbuf-1]) { 
  53.         write(1, &pcbuf, pcbp-pcbuf);
  54.         pcbp = pcbuf;
  55.     }
  56. }
  57.  
  58. char    ugh[]    "Fatal error in pi1\n";
  59. /*
  60.  * Exit from the Pascal system.
  61.  */
  62. pexit(c)
  63.     int c;
  64. {
  65.  
  66.     if (c == DIED)
  67.         write(2, ugh, sizeof ugh);
  68.     exit(c);
  69. }
  70.  
  71. onintr()
  72. {
  73.  
  74.     signal(2, 1);
  75.     pexit(NOSTART);
  76. }
  77.  
  78. /*
  79.  * Get an error message from the error message file
  80.  */
  81. geterr(seekpt, buf)
  82.     int seekpt;
  83.     char *buf;
  84. {
  85.  
  86.     if (seek(efil, seekpt, 0) || read(efil, buf, 256) <= 0)
  87.         perror(errfile), pexit(DIED);
  88. }
  89.