* Copyright (c) 1997-2002, Larry Wall
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
Interface for perl to IO functions.
There is a hierachy of Configure determined #define controls:
USE_STDIO - forces PerlIO_xxx() to be #define-d onto stdio functions.
This is used for x2p subdirectory and for conservative
builds - "just like perl5.00X used to be".
This dominates over the others.
USE_PERLIO - The primary Configure variable that enables PerlIO.
If USE_PERLIO is _NOT_ set
then USE_STDIO above will be set to be conservative.
then there are two modes determined by USE_SFIO:
USE_SFIO - If set causes PerlIO_xxx() to be #define-d onto sfio functions.
A backward compatability mode for some specialist applications.
If USE_SFIO is not set then PerlIO_xxx() are real functions
defined in perlio.c which implement extra functionality
required for utf8 support.
One further note - the table-of-functions scheme controlled
by PERL_IMPLICIT_SYS turns on USE_PERLIO so that iperlsys.h can
#define PerlIO_xxx() to go via the function table, without having
to #undef them from (say) stdio forms.
#if defined(PERL_IMPLICIT_SYS)
/* # define USE_PERLIO */
/* -------------------- End of Configure controls ---------------------------- */
* Although we may not want stdio to be used including <stdio.h> here
* avoids issues where stdio.h has strange side effects
int fseeko(FILE *stream
, off_t offset
, int whence
);
off_t
ftello(FILE *stream
);
#if defined(USE_64_BIT_STDIO) && defined(HAS_FTELLO) && !defined(USE_FTELL64)
#if defined(USE_64_BIT_STDIO) && defined(HAS_FSEEKO) && !defined(USE_FSEEK64)
/* BS2000 includes are sometimes a bit non standard :-( */
#if defined(POSIX_BC) && defined(O_BINARY) && !defined(O_TEXT)
/* #define PerlIO_xxxx() as equivalent stdio function */
#else /* PERLIO_IS_STDIO */
/* #define PerlIO_xxxx() as equivalent sfio function */
#endif /* PERLIO_IS_STDIO */
/* ----------- PerlIO implementation ---------- */
/* PerlIO not #define-d to something else - define the implementation */
typedef struct _PerlIO PerlIOl
;
typedef struct _PerlIO_funcs PerlIO_funcs
;
extern void PerlIO_define_layer(pTHX_ PerlIO_funcs
*tab
);
extern PerlIO_funcs
*PerlIO_find_layer(pTHX_
const char *name
, STRLEN len
,
extern PerlIO
*PerlIO_push(pTHX_ PerlIO
*f
, PerlIO_funcs
*tab
,
const char *mode
, SV
*arg
);
extern void PerlIO_pop(pTHX_ PerlIO
*f
);
extern void PerlIO_clone(pTHX_ PerlInterpreter
*proto
, CLONE_PARAMS
*param
);
/* ----------- End of implementation choices ---------- */
/* Not using stdio _directly_ as PerlIO */
/* We now need to determine what happens if source trys to use stdio.
* There are three cases based on PERLIO_NOT_STDIO which XS code
/* Make a choice for perl core code
- currently this is set to try and catch lingering raw stdio calls.
This is a known issue with some non UNIX ports which still use
#define PERLIO_NOT_STDIO 1
#define PERLIO_NOT_STDIO 0
* PERLIO_NOT_STDIO #define'd as 1
* Case 1: Strong denial of stdio - make all stdio calls (we can think of) errors
#else /* if PERLIO_NOT_STDIO */
* PERLIO_NOT_STDIO #define'd as 0
* Case 2: Declares that both PerlIO and stdio can be used
#endif /* if PERLIO_NOT_STDIO */
#else /* ifdef PERLIO_NOT_STDIO */
* PERLIO_NOT_STDIO not defined
* Case 3: Try and fake stdio calls as PerlIO calls
#endif /* ifndef PERLIO_NOT_STDIO */
#endif /* PERLIO_IS_STDIO */
#define specialCopIO(sv) ((sv) == Nullsv)
/* ----------- fill in things that have not got #define'd ---------- */
/* This is to catch case with no stdio */
#define PERLIO_DUP_CLONE 1
/* --------------------- Now prototypes for functions --------------- */
#ifndef NEXT30_NO_ATTRIBUTE
#ifndef HASATTRIBUTE /* disable GNU-cc attribute checking? */
#ifdef __attribute__ /* Avoid possible redefinition errors */
#define __attribute__(attr)
extern void PerlIO_init(pTHX
);
extern int PerlIO_stdoutf(const char *, ...)
__attribute__ ((__format__(__printf__
, 1, 2)));
extern int PerlIO_puts(PerlIO
*, const char *);
extern PerlIO
*PerlIO_open(const char *, const char *);
extern PerlIO
*PerlIO_openn(pTHX_
const char *layers
, const char *mode
,
int fd
, int imode
, int perm
, PerlIO
*old
,
extern int PerlIO_eof(PerlIO
*);
extern int PerlIO_error(PerlIO
*);
extern void PerlIO_clearerr(PerlIO
*);
extern int PerlIO_getc(PerlIO
*);
extern int PerlIO_putc(PerlIO
*, int);
extern int PerlIO_ungetc(PerlIO
*, int);
extern PerlIO
*PerlIO_fdopen(int, const char *);
#ifndef PerlIO_importFILE
extern PerlIO
*PerlIO_importFILE(FILE *, const char *);
#ifndef PerlIO_exportFILE
extern FILE *PerlIO_exportFILE(PerlIO
*, const char *);
extern FILE *PerlIO_findFILE(PerlIO
*);
#ifndef PerlIO_releaseFILE
extern void PerlIO_releaseFILE(PerlIO
*, FILE *);
extern SSize_t
PerlIO_read(PerlIO
*, void *, Size_t
);
extern SSize_t
PerlIO_unread(PerlIO
*, const void *, Size_t
);
extern SSize_t
PerlIO_write(PerlIO
*, const void *, Size_t
);
#ifndef PerlIO_setlinebuf
extern void PerlIO_setlinebuf(PerlIO
*);
extern int PerlIO_printf(PerlIO
*, const char *, ...)
__attribute__ ((__format__(__printf__
, 2, 3)));
extern int PerlIO_sprintf(char *, int, const char *, ...)
__attribute__ ((__format__(__printf__
, 3, 4)));
extern int PerlIO_vprintf(PerlIO
*, const char *, va_list);
extern Off_t
PerlIO_tell(PerlIO
*);
extern int PerlIO_seek(PerlIO
*, Off_t
, int);
extern void PerlIO_rewind(PerlIO
*);
extern int PerlIO_has_base(PerlIO
*);
#ifndef PerlIO_has_cntptr
extern int PerlIO_has_cntptr(PerlIO
*);
extern int PerlIO_fast_gets(PerlIO
*);
#ifndef PerlIO_canset_cnt
extern int PerlIO_canset_cnt(PerlIO
*);
extern STDCHAR
*PerlIO_get_ptr(PerlIO
*);
extern int PerlIO_get_cnt(PerlIO
*);
extern void PerlIO_set_cnt(PerlIO
*, int);
#ifndef PerlIO_set_ptrcnt
extern void PerlIO_set_ptrcnt(PerlIO
*, STDCHAR
*, int);
extern STDCHAR
*PerlIO_get_base(PerlIO
*);
#ifndef PerlIO_get_bufsiz
extern int PerlIO_get_bufsiz(PerlIO
*);
extern PerlIO
*PerlIO_tmpfile(void);
extern PerlIO
*PerlIO_stdin(void);
extern PerlIO
*PerlIO_stdout(void);
extern PerlIO
*PerlIO_stderr(void);
extern int PerlIO_getpos(PerlIO
*, SV
*);
extern int PerlIO_setpos(PerlIO
*, SV
*);
extern PerlIO
*PerlIO_fdupopen(pTHX_ PerlIO
*, CLONE_PARAMS
*, int);
#if !defined(PerlIO_modestr) && !defined(PERLIO_IS_STDIO)
extern char *PerlIO_modestr(PerlIO
*, char *buf
);
extern int PerlIO_isutf8(PerlIO
*);
#ifndef PerlIO_apply_layers
extern int PerlIO_apply_layers(pTHX_ PerlIO
*f
, const char *mode
,
extern int PerlIO_binmode(pTHX_ PerlIO
*f
, int iotype
, int omode
,
extern char *PerlIO_getname(PerlIO
*, char *);
extern void PerlIO_destruct(pTHX
);
extern int PerlIO_intmode2str(int rawmode
, char *mode
, int *writing
);
extern void PerlIO_cleanup(pTHX
);
extern void PerlIO_debug(const char *fmt
, ...);
typedef struct PerlIO_list_s PerlIO_list_t
;