RE: [PATCH] compress 2.018
[p5sagit/p5-mst-13.2.git] / perlsfio.h
CommitLineData
d6376244 1/* perlsfio.h
2 *
663f364b 3 * Copyright (C) 1996, 1999, 2000, 2001, 2002, 2003, 2005, 2007,
4 * by Larry Wall and others
d6376244 5 *
6 * You may distribute under the terms of either the GNU General Public
7 * License or the Artistic License, as specified in the README file.
8 *
9 */
10
760ac839 11/* The next #ifdef should be redundant if Configure behaves ... */
92bff44d 12#ifndef FILE
13#define FILE FILE
14#endif
760ac839 15#ifdef I_SFIO
16#include <sfio.h>
17#endif
18
25259385 19/* sfio 2000 changed _stdopen to _stdfdopen */
20#if SFIO_VERSION >= 20000101L
76ced9ad 21#define _stdopen _stdfdopen
25259385 22#endif
23
760ac839 24extern Sfio_t* _stdopen _ARG_((int, const char*));
25extern int _stdprintf _ARG_((const char*, ...));
26
27#define PerlIO Sfio_t
28#define PerlIO_stderr() sfstderr
29#define PerlIO_stdout() sfstdout
30#define PerlIO_stdin() sfstdin
31
76ced9ad 32#define PerlIO_isutf8(f) 0
33
760ac839 34#define PerlIO_printf sfprintf
35#define PerlIO_stdoutf _stdprintf
76ced9ad 36#define PerlIO_vprintf(f,fmt,a) sfvprintf(f,fmt,a)
760ac839 37#define PerlIO_read(f,buf,count) sfread(f,buf,count)
38#define PerlIO_write(f,buf,count) sfwrite(f,buf,count)
39#define PerlIO_open(path,mode) sfopen(NULL,path,mode)
40#define PerlIO_fdopen(fd,mode) _stdopen(fd,mode)
e50990e1 41#define PerlIO_reopen(path,mode,f) sfopen(f,path,mode)
760ac839 42#define PerlIO_close(f) sfclose(f)
43#define PerlIO_puts(f,s) sfputr(f,s,-1)
44#define PerlIO_putc(f,c) sfputc(f,c)
45#define PerlIO_ungetc(f,c) sfungetc(f,c)
46#define PerlIO_sprintf sfsprintf
47#define PerlIO_getc(f) sfgetc(f)
48#define PerlIO_eof(f) sfeof(f)
49#define PerlIO_error(f) sferror(f)
50#define PerlIO_fileno(f) sffileno(f)
51#define PerlIO_clearerr(f) sfclrerr(f)
52#define PerlIO_flush(f) sfsync(f)
76ced9ad 53#define PerlIO_tell(f) sftell(f)
760ac839 54#define PerlIO_seek(f,o,w) sfseek(f,o,w)
55#define PerlIO_rewind(f) (void) sfseek((f),0L,0)
56#define PerlIO_tmpfile() sftmp(0)
e5f84f0c 57#define PerlIO_exportFILE(f,fl) Perl_croak(aTHX_ "Export to FILE * unimplemented")
58#define PerlIO_releaseFILE(p,f) Perl_croak(aTHX_ "Release of FILE * unimplemented")
760ac839 59
60#define PerlIO_setlinebuf(f) sfset(f,SF_LINE,1)
61
62/* Now our interface to equivalent of Configure's FILE_xxx macros */
63
76ced9ad 64#define PerlIO_has_cntptr(f) 1
760ac839 65#define PerlIO_get_ptr(f) ((f)->next)
66#define PerlIO_get_cnt(f) ((f)->endr - (f)->next)
76ced9ad 67#define PerlIO_canset_cnt(f) 1
a7ffa9b9 68#define PerlIO_fast_gets(f) 1
76ced9ad 69#define PerlIO_set_ptrcnt(f,p,c) STMT_START {(f)->next = (unsigned char *)(p); assert(PerlIO_get_cnt(f) == (c));} STMT_END
70#define PerlIO_set_cnt(f,c) STMT_START {(f)->next = (f)->endr - (c);} STMT_END
760ac839 71
76ced9ad 72#define PerlIO_has_base(f) 1
760ac839 73#define PerlIO_get_base(f) ((f)->data)
74#define PerlIO_get_bufsiz(f) ((f)->endr - (f)->data)
75
e9a8c099 76/*
77 * Local variables:
78 * c-indentation-style: bsd
79 * c-basic-offset: 4
80 * indent-tabs-mode: t
81 * End:
82 *
83 * ex: set ts=8 sts=4 sw=4 noet:
84 */