Added upstream from http://ftp.icm.edu.pl/pub/loglan/
[loglan.git] / sources / pass1 / stdio.c
1      /* Loglan82 Compiler&Interpreter
2      Copyright (C) 1981-1993 Institute of Informatics, University of Warsaw
3      Copyright (C)  1993, 1994 LITA, Pau
4      
5      This program is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published by
7      the Free Software Foundation; either version 2 of the License, or
8      (at your option) any later version.
9      
10      This program is distributed in the hope that it will be useful,
11      but WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13      GNU General Public License for more details.
14      
15
16 =======================================================================
17 */
18
19 #include <stdio.h>
20
21 #if WSIZE==4
22         typedef long word;
23 #elif WSIZE==2
24         typedef short word;
25 #else
26  Define WSIZE to 2 or 4 !
27 #endif
28
29    
30 extern FILE *file_arr[];
31
32
33 #define sunit FILE *f=stdout; if((int)(*unit)!=0L) f=file_arr[*unit];
34
35
36 void ffputnl_(unit) word *unit;{
37    sunit
38    fprintf(f,"\n");
39 }
40 void ffputff_(unit) word *unit;{
41    sunit
42    fprintf(f,"\f");
43 }
44 void ffputspaces_(unit,count) word *unit,*count;{
45    sunit
46    fprintf(f,"%*s",(int)(*count),"");
47 }
48 void ffputi_(unit,i,count) word *unit,*i,*count;{
49    sunit
50    fprintf(f,"%*d",(int)(*count),(int)(*i));
51 }
52 void ffputcs_(unit,s,count) word *unit; long count; char *s;{
53    sunit
54    fprintf(f,"%*.*s",(int)count,(int)count,s);
55 }
56 void ffputs_(unit,s,count,one) word *unit,*count; char *s; long one;{
57    sunit
58    fprintf(f,"%*.*s",(int)(*count),(int)(*count),s);
59 }
60 void ffgets_(unit,s,count,one) word *unit,*count; char *s; long one;{
61    FILE *f=stdin; if((int)(*unit)!=0) f=file_arr[*unit];
62    fgets(s,(int)(*count),f);
63 }
64 void ffexit_(){ exit(0); }
65
66