|
|
1.1 root 1: /*
2: * AT&T Bell Laboratories
3: *
4: * sfio stdio source emulation
5: */
6:
7: #ifndef _STDIO_H_
8:
9: #if __cplusplus || c_plusplus
10:
11: #include <../CC/stdio.h>
12:
13: #ifndef _STDIO_H_
14: #define _STDIO_H_
15: #endif
16:
17: #else
18:
19: #define _STDIO_H_
20:
21: #include <sfio.h>
22:
23: #define _IOFBF 0
24: #define _IONBF 1
25: #define _IOLBF 2
26: #define L_ctermid 9
27: #define L_cuserid 9
28: #define P_tmpdir "/usr/tmp/"
29: #define L_tmpnam (sizeof(P_tmpdir)+15)
30:
31: #if __cplusplus || c_plusplus
32: extern "C"
33: {
34: #endif
35:
36: extern char *ctermid _SFA_((char*));
37: extern char *cuserid _SFA_((char*));
38: extern char *tmpnam _SFA_((char*));
39: extern char *tempnam _SFA_((char*));
40: extern char *_stdgets _SFA_((char*, int n));
41: extern int _stdprintf _SFA_((const char*, ...));
42: extern int _stdsprintf _SFA_((char*, const char*, ...));
43: extern int _stdscanf _SFA_((const char*, ...));
44: extern int _stdsetvbuf _SFA_((Sfile_t*, char*, int, int));
45:
46: #if __cplusplus || c_plusplus
47: }
48: #endif
49:
50: #define stdin sfstdin
51: #define stdout sfstdout
52: #define stderr sfstderr
53: #define FILE Sfile_t
54: #define BUFSIZ SF_BUFSIZE
55:
56: #define fopen(f,m) sfopen((Sfile_t*)0,f,m)
57: #define fdopen(fd,m) sfdopen(fd,m)
58: #define freopen(f,m,p) sfopen(p,f,m)
59: #define tmpfile() sftmpfile()
60: #define popen(cmd,m) sfpopen(cmd,m,(Sfile_t**)0)
61: #define fclose(f) sfclose(f)
62: #define pclose(f) sfclose(f)
63:
64: #define fwrite(p,s,n,f) ((_Sfi = sfwrite(f,p,(s)*(n))) <= 0 ? _Sfi : _Sfi/(s))
65: #define fputc(c,f) sfputc(f,c)
66: #define putc(c,f) sfputc(f,c)
67: #define putw(w,f) (_Sfi = (int)w, sfwrite(f,&_Sfi,sizeof(int)) <= 0 ? 1 : 0)
68: #define putchar(c) sfputc(sfstdout,c)
69: #define fputs(s,f) sfputs(f,s,0)
70: #define puts(s) sfputs(sfstdout,s,'\n')
71: #define fprintf sfprintf
72: #define vfprintf sfvprintf
73: #define vprintf(f,a) sfvprintf(sfstdout,f,a)
74: #define vsprintf _stdvsprintf
75: #define printf _stdprintf
76: #define sprintf _stdsprintf
77:
78: #define fread(p,s,n,f) ((_Sfi = sfread(f,p,(s)*(n))) <= 0 ? _Sfi : _Sfi/(s))
79: #define fgetc(f) sfgetc(f)
80: #define getc(f) sfgetc(f)
81: #define getw(f) (sfread(f,&_Sfi,sizeof(int)) == sizeof(int) ? _Sfi : -1)
82: #define getchar() sfgetc(sfstdin)
83: #define ungetc(c,f) sfungetc(f,c)
84: #define fgets(s,n,f) sfgets(f,s,n)
85: #define _SIZEOF(s) (sizeof(s) != sizeof(char*) ? sizeof(s) : BUFSIZ)
86: #define gets(s) _stdgets(s,_SIZEOF(s))
87: #define fscanf sfscanf
88: #define vfscanf sfvscanf
89: #define sscanf sfsscanf
90: #define vscanf(f,a) sfvscanf(sfstdin,f,a)
91: #define scanf _stdscanf
92: #define vsscanf _stdvssanf
93:
94: #define fflush(f) sfsync(f)
95: #define fseek(f,o,t) (sfseek(f,o,t) < 0L ? -1 : 0)
96: #define rewind(f) sfseek((f),0L,0)
97: #define ftell(f) sftell(f)
98: #define setbuf(f,b) sfsetbuf(f,b,(b) ? BUFSIZ : 0)
99: #define setbuffer(f,b,n) sfsetbuf(f,b,n)
100: #define setlinebuf(f) sfsetflag(f,SF_LINE,1)
101: #define setvbuf _stdsetvbuf
102:
103: #define fileno(f) sffileno(f)
104: #define feof(f) sfeof(f)
105: #define ferror(f) sferror(f)
106: #define clearerr(f) (sfclearerr(f),sfclearlock(f))
107:
108: #endif
109:
110: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.