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