xref: /original-bsd/usr.bin/pascal/eyacc/ey5.c (revision cd79ddd6)
1 /*-
2  * Copyright (c) 1979, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.proprietary.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)ey5.c	8.1 (Berkeley) 06/06/93";
10 #endif /* not lint */
11 
12 /* fake portable I/O routines, for those
13     sites so backward as to not have the
14      port. library */
15 /* munged for standard i/o library: peter and louise 5 may 80 */
16 #include <stdio.h>
17 
18 FILE *cin, *cout;
19 
copen(s,c)20 FILE *copen( s, c )
21     char *s;
22     char c;
23   {
24   FILE *f;
25 
26 	  if( c == 'r' ){
27 	    f = fopen( s, "r" );
28   } else  if( c == 'a' ){
29 	    f = fopen( s, "a" );
30 	    fseek( f, 0L, 2 );
31   } else {  /* c == w */
32 	    f = fopen( s, "w" );
33   }
34 
35   return( f );
36   }
37 
cflush(x)38 cflush(x) FILE *x; { /* fake! sets file to x */
39   fflush( cout );
40   cout = x;
41   }
42 
cclose(i)43 cclose(i) FILE *i; {
44   fclose(i);
45   }
46 
cexit(i)47 cexit(i){
48   fflush( cout );
49   if ( i != 0 ) {
50     abort();
51   }
52   exit(i);
53   }
54