xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/perlsfio.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*    perlsfio.h
2*0Sstevel@tonic-gate  *
3*0Sstevel@tonic-gate  *    Copyright (C) 1996, 1999, 2000, 2001, 2002, by Larry Wall and others
4*0Sstevel@tonic-gate  *
5*0Sstevel@tonic-gate  *    You may distribute under the terms of either the GNU General Public
6*0Sstevel@tonic-gate  *    License or the Artistic License, as specified in the README file.
7*0Sstevel@tonic-gate  *
8*0Sstevel@tonic-gate  */
9*0Sstevel@tonic-gate 
10*0Sstevel@tonic-gate /* The next #ifdef should be redundant if Configure behaves ... */
11*0Sstevel@tonic-gate #ifndef FILE
12*0Sstevel@tonic-gate #define FILE FILE
13*0Sstevel@tonic-gate #endif
14*0Sstevel@tonic-gate #ifdef I_SFIO
15*0Sstevel@tonic-gate #include <sfio.h>
16*0Sstevel@tonic-gate #endif
17*0Sstevel@tonic-gate 
18*0Sstevel@tonic-gate /* sfio 2000 changed _stdopen to _stdfdopen */
19*0Sstevel@tonic-gate #if SFIO_VERSION >= 20000101L
20*0Sstevel@tonic-gate #define _stdopen _stdfdopen
21*0Sstevel@tonic-gate #endif
22*0Sstevel@tonic-gate 
23*0Sstevel@tonic-gate extern Sfio_t*	_stdopen _ARG_((int, const char*));
24*0Sstevel@tonic-gate extern int	_stdprintf _ARG_((const char*, ...));
25*0Sstevel@tonic-gate 
26*0Sstevel@tonic-gate #define PerlIO				Sfio_t
27*0Sstevel@tonic-gate #define PerlIO_stderr()			sfstderr
28*0Sstevel@tonic-gate #define PerlIO_stdout()			sfstdout
29*0Sstevel@tonic-gate #define PerlIO_stdin()			sfstdin
30*0Sstevel@tonic-gate 
31*0Sstevel@tonic-gate #define PerlIO_isutf8(f)		0
32*0Sstevel@tonic-gate 
33*0Sstevel@tonic-gate #define PerlIO_printf			sfprintf
34*0Sstevel@tonic-gate #define PerlIO_stdoutf			_stdprintf
35*0Sstevel@tonic-gate #define PerlIO_vprintf(f,fmt,a)		sfvprintf(f,fmt,a)
36*0Sstevel@tonic-gate #define PerlIO_read(f,buf,count)	sfread(f,buf,count)
37*0Sstevel@tonic-gate #define PerlIO_write(f,buf,count)	sfwrite(f,buf,count)
38*0Sstevel@tonic-gate #define PerlIO_open(path,mode)		sfopen(NULL,path,mode)
39*0Sstevel@tonic-gate #define PerlIO_fdopen(fd,mode)		_stdopen(fd,mode)
40*0Sstevel@tonic-gate #define PerlIO_reopen(path,mode,f)	sfopen(f,path,mode)
41*0Sstevel@tonic-gate #define PerlIO_close(f)			sfclose(f)
42*0Sstevel@tonic-gate #define PerlIO_puts(f,s)		sfputr(f,s,-1)
43*0Sstevel@tonic-gate #define PerlIO_putc(f,c)		sfputc(f,c)
44*0Sstevel@tonic-gate #define PerlIO_ungetc(f,c)		sfungetc(f,c)
45*0Sstevel@tonic-gate #define PerlIO_sprintf			sfsprintf
46*0Sstevel@tonic-gate #define PerlIO_getc(f)			sfgetc(f)
47*0Sstevel@tonic-gate #define PerlIO_eof(f)			sfeof(f)
48*0Sstevel@tonic-gate #define PerlIO_error(f)			sferror(f)
49*0Sstevel@tonic-gate #define PerlIO_fileno(f)		sffileno(f)
50*0Sstevel@tonic-gate #define PerlIO_clearerr(f)		sfclrerr(f)
51*0Sstevel@tonic-gate #define PerlIO_flush(f)			sfsync(f)
52*0Sstevel@tonic-gate #if 0
53*0Sstevel@tonic-gate /* This breaks tests */
54*0Sstevel@tonic-gate #define PerlIO_tell(f)			sfseek(f,0,1|SF_SHARE)
55*0Sstevel@tonic-gate #else
56*0Sstevel@tonic-gate #define PerlIO_tell(f)			sftell(f)
57*0Sstevel@tonic-gate #endif
58*0Sstevel@tonic-gate #define PerlIO_seek(f,o,w)		sfseek(f,o,w)
59*0Sstevel@tonic-gate #define PerlIO_rewind(f)		(void) sfseek((f),0L,0)
60*0Sstevel@tonic-gate #define PerlIO_tmpfile()		sftmp(0)
61*0Sstevel@tonic-gate 
62*0Sstevel@tonic-gate #if 0
63*0Sstevel@tonic-gate #define PerlIO_importFILE(f,fl)		((void) Perl_croak(aTHX_ "Import from FILE * unimplemented"), NULL)
64*0Sstevel@tonic-gate #define PerlIO_findFILE(f)		NULL
65*0Sstevel@tonic-gate #endif
66*0Sstevel@tonic-gate #define PerlIO_exportFILE(f,fl)		Perl_croak(aTHX_ "Export to FILE * unimplemented")
67*0Sstevel@tonic-gate #define PerlIO_releaseFILE(p,f)		Perl_croak(aTHX_ "Release of FILE * unimplemented")
68*0Sstevel@tonic-gate 
69*0Sstevel@tonic-gate #define PerlIO_setlinebuf(f)		sfset(f,SF_LINE,1)
70*0Sstevel@tonic-gate 
71*0Sstevel@tonic-gate /* Now our interface to equivalent of Configure's FILE_xxx macros */
72*0Sstevel@tonic-gate 
73*0Sstevel@tonic-gate #define PerlIO_has_cntptr(f)		1
74*0Sstevel@tonic-gate #define PerlIO_get_ptr(f)		((f)->next)
75*0Sstevel@tonic-gate #define PerlIO_get_cnt(f)		((f)->endr - (f)->next)
76*0Sstevel@tonic-gate #define PerlIO_canset_cnt(f)		1
77*0Sstevel@tonic-gate #define PerlIO_fast_gets(f)		1
78*0Sstevel@tonic-gate #define PerlIO_set_ptrcnt(f,p,c)	STMT_START {(f)->next = (unsigned char *)(p); assert(PerlIO_get_cnt(f) == (c));} STMT_END
79*0Sstevel@tonic-gate #define PerlIO_set_cnt(f,c)		STMT_START {(f)->next = (f)->endr - (c);} STMT_END
80*0Sstevel@tonic-gate 
81*0Sstevel@tonic-gate #define PerlIO_has_base(f)		1
82*0Sstevel@tonic-gate #define PerlIO_get_base(f)		((f)->data)
83*0Sstevel@tonic-gate #define PerlIO_get_bufsiz(f)		((f)->endr - (f)->data)
84*0Sstevel@tonic-gate 
85*0Sstevel@tonic-gate 
86