📄 iperlsys.h
字号:
/*
* iperlsys.h - Perl's interface to the system
*
* This file defines the system level functionality that perl needs.
*
* When using C, this definition is in the form of a set of macros
* that can be #defined to the system-level function (or a wrapper
* provided elsewhere).
*
* When using C++ with -DPERL_OBJECT, this definition is in the
* form of a set of virtual base classes which must be subclassed to
* provide a real implementation. The Perl Object will use instances
* of this implementation to use the system-level functionality.
*
* GSAR 21-JUN-98
*/
#ifndef __Inc__IPerl___
#define __Inc__IPerl___
/*
* PerlXXX_YYY explained - DickH and DougL @ ActiveState.com
*
* XXX := functional group
* YYY := stdlib/OS function name
*
* Continuing with the theme of PerlIO, all OS functionality was
* encapsulated into one of several interfaces.
*
* PerlIO - stdio
* PerlLIO - low level I/O
* PerlMem - malloc, realloc, free
* PerlDir - directory related
* PerlEnv - process environment handling
* PerlProc - process control
* PerlSock - socket functions
*
*
* The features of this are:
* 1. All OS dependant code is in the Perl Host and not the Perl Core.
* (At least this is the holy grail goal of this work)
* 2. The Perl Host (see perl.h for description) can provide a new and
* improved interface to OS functionality if required.
* 3. Developers can easily hook into the OS calls for instrumentation
* or diagnostic purposes.
*
* What was changed to do this:
* 1. All calls to OS functions were replaced with PerlXXX_YYY
*
*/
/*
Interface for perl stdio functions
*/
/* Clean up (or at least document) the various possible #defines.
This section attempts to match the 5.003_03 Configure variables
onto the 5.003_02 header file values.
I can't figure out where USE_STDIO was supposed to be set.
--AD
*/
#ifndef USE_PERLIO
# define PERLIO_IS_STDIO
#endif
/* Below is the 5.003_02 stuff. */
#ifdef USE_STDIO
# ifndef PERLIO_IS_STDIO
# define PERLIO_IS_STDIO
# endif
#else
extern void PerlIO_init _((void));
#endif
#ifdef PERL_OBJECT
#ifndef PerlIO
typedef struct _PerlIO PerlIO;
#endif
class IPerlStdIO
{
public:
virtual PerlIO * Stdin(void) = 0;
virtual PerlIO * Stdout(void) = 0;
virtual PerlIO * Stderr(void) = 0;
virtual PerlIO * Open(const char *, const char *, int &err) = 0;
virtual int Close(PerlIO*, int &err) = 0;
virtual int Eof(PerlIO*, int &err) = 0;
virtual int Error(PerlIO*, int &err) = 0;
virtual void Clearerr(PerlIO*, int &err) = 0;
virtual int Getc(PerlIO*, int &err) = 0;
virtual char * GetBase(PerlIO *, int &err) = 0;
virtual int GetBufsiz(PerlIO *, int &err) = 0;
virtual int GetCnt(PerlIO *, int &err) = 0;
virtual char * GetPtr(PerlIO *, int &err) = 0;
virtual char * Gets(PerlIO*, char*, int, int& err) = 0;
virtual int Putc(PerlIO*, int, int &err) = 0;
virtual int Puts(PerlIO*, const char *, int &err) = 0;
virtual int Flush(PerlIO*, int &err) = 0;
virtual int Ungetc(PerlIO*,int, int &err) = 0;
virtual int Fileno(PerlIO*, int &err) = 0;
virtual PerlIO * Fdopen(int, const char *, int &err) = 0;
virtual PerlIO * Reopen(const char*, const char*, PerlIO*, int &err) = 0;
virtual SSize_t Read(PerlIO*,void *,Size_t, int &err) = 0;
virtual SSize_t Write(PerlIO*,const void *,Size_t, int &err) = 0;
virtual void SetBuf(PerlIO *, char*, int &err) = 0;
virtual int SetVBuf(PerlIO *, char*, int, Size_t, int &err) = 0;
virtual void SetCnt(PerlIO *, int, int &err) = 0;
virtual void SetPtrCnt(PerlIO *, char *, int, int& err) = 0;
virtual void Setlinebuf(PerlIO*, int &err) = 0;
virtual int Printf(PerlIO*, int &err, const char *,...) = 0;
virtual int Vprintf(PerlIO*, int &err, const char *, va_list) = 0;
virtual long Tell(PerlIO*, int &err) = 0;
virtual int Seek(PerlIO*, off_t, int, int &err) = 0;
virtual void Rewind(PerlIO*, int &err) = 0;
virtual PerlIO * Tmpfile(int &err) = 0;
virtual int Getpos(PerlIO*, Fpos_t *, int &err) = 0;
virtual int Setpos(PerlIO*, const Fpos_t *, int &err) = 0;
virtual void Init(int &err) = 0;
virtual void InitOSExtras(void* p) = 0;
#ifdef WIN32
virtual int OpenOSfhandle(long osfhandle, int flags) = 0;
virtual int GetOSfhandle(int filenum) = 0;
#endif
};
#ifdef USE_STDIO_PTR
# define PerlIO_has_cntptr(f) 1
# ifdef STDIO_CNT_LVALUE
# define PerlIO_canset_cnt(f) 1
# ifdef STDIO_PTR_LVALUE
# define PerlIO_fast_gets(f) 1
# endif
# else
# define PerlIO_canset_cnt(f) 0
# endif
#else /* USE_STDIO_PTR */
# define PerlIO_has_cntptr(f) 0
# define PerlIO_canset_cnt(f) 0
#endif /* USE_STDIO_PTR */
#ifndef PerlIO_fast_gets
#define PerlIO_fast_gets(f) 0
#endif
#ifdef FILE_base
#define PerlIO_has_base(f) 1
#else
#define PerlIO_has_base(f) 0
#endif
#define PerlIO_stdin() PL_piStdIO->Stdin()
#define PerlIO_stdout() PL_piStdIO->Stdout()
#define PerlIO_stderr() PL_piStdIO->Stderr()
#define PerlIO_open(x,y) PL_piStdIO->Open((x),(y), ErrorNo())
#define PerlIO_close(f) PL_piStdIO->Close((f), ErrorNo())
#define PerlIO_eof(f) PL_piStdIO->Eof((f), ErrorNo())
#define PerlIO_error(f) PL_piStdIO->Error((f), ErrorNo())
#define PerlIO_clearerr(f) PL_piStdIO->Clearerr((f), ErrorNo())
#define PerlIO_getc(f) PL_piStdIO->Getc((f), ErrorNo())
#define PerlIO_get_base(f) PL_piStdIO->GetBase((f), ErrorNo())
#define PerlIO_get_bufsiz(f) PL_piStdIO->GetBufsiz((f), ErrorNo())
#define PerlIO_get_cnt(f) PL_piStdIO->GetCnt((f), ErrorNo())
#define PerlIO_get_ptr(f) PL_piStdIO->GetPtr((f), ErrorNo())
#define PerlIO_putc(f,c) PL_piStdIO->Putc((f),(c), ErrorNo())
#define PerlIO_puts(f,s) PL_piStdIO->Puts((f),(s), ErrorNo())
#define PerlIO_flush(f) PL_piStdIO->Flush((f), ErrorNo())
#define PerlIO_gets(s, n, fp) PL_piStdIO->Gets((fp), s, n, ErrorNo())
#define PerlIO_ungetc(f,c) PL_piStdIO->Ungetc((f),(c), ErrorNo())
#define PerlIO_fileno(f) PL_piStdIO->Fileno((f), ErrorNo())
#define PerlIO_fdopen(f, s) PL_piStdIO->Fdopen((f),(s), ErrorNo())
#define PerlIO_reopen(p, m, f) PL_piStdIO->Reopen((p), (m), (f), ErrorNo())
#define PerlIO_read(f,buf,count) \
(SSize_t)PL_piStdIO->Read((f), (buf), (count), ErrorNo())
#define PerlIO_write(f,buf,count) \
PL_piStdIO->Write((f), (buf), (count), ErrorNo())
#define PerlIO_setbuf(f,b) PL_piStdIO->SetBuf((f), (b), ErrorNo())
#define PerlIO_setvbuf(f,b,t,s) PL_piStdIO->SetVBuf((f), (b), (t), (s), ErrorNo())
#define PerlIO_set_cnt(f,c) PL_piStdIO->SetCnt((f), (c), ErrorNo())
#define PerlIO_set_ptrcnt(f,p,c) \
PL_piStdIO->SetPtrCnt((f), (p), (c), ErrorNo())
#define PerlIO_setlinebuf(f) PL_piStdIO->Setlinebuf((f), ErrorNo())
#define PerlIO_printf fprintf
#define PerlIO_stdoutf PL_piStdIO->Printf
#define PerlIO_vprintf(f,fmt,a) PL_piStdIO->Vprintf((f), ErrorNo(), (fmt),a)
#define PerlIO_tell(f) PL_piStdIO->Tell((f), ErrorNo())
#define PerlIO_seek(f,o,w) PL_piStdIO->Seek((f),(o),(w), ErrorNo())
#define PerlIO_getpos(f,p) PL_piStdIO->Getpos((f),(p), ErrorNo())
#define PerlIO_setpos(f,p) PL_piStdIO->Setpos((f),(p), ErrorNo())
#define PerlIO_rewind(f) PL_piStdIO->Rewind((f), ErrorNo())
#define PerlIO_tmpfile() PL_piStdIO->Tmpfile(ErrorNo())
#define PerlIO_init() PL_piStdIO->Init(ErrorNo())
#undef init_os_extras
#define init_os_extras() PL_piStdIO->InitOSExtras(this)
#else /* PERL_OBJECT */
#include "perlsdio.h"
#endif /* PERL_OBJECT */
#ifndef PERLIO_IS_STDIO
#ifdef USE_SFIO
#include "perlsfio.h"
#endif /* USE_SFIO */
#endif /* PERLIO_IS_STDIO */
#ifndef EOF
#define EOF (-1)
#endif
/* This is to catch case with no stdio */
#ifndef BUFSIZ
#define BUFSIZ 1024
#endif
#ifndef SEEK_SET
#define SEEK_SET 0
#endif
#ifndef SEEK_CUR
#define SEEK_CUR 1
#endif
#ifndef SEEK_END
#define SEEK_END 2
#endif
#ifndef PerlIO
struct _PerlIO;
#define PerlIO struct _PerlIO
#endif /* No PerlIO */
#ifndef Fpos_t
#define Fpos_t long
#endif
#ifndef NEXT30_NO_ATTRIBUTE
#ifndef HASATTRIBUTE /* disable GNU-cc attribute checking? */
#ifdef __attribute__ /* Avoid possible redefinition errors */
#undef __attribute__
#endif
#define __attribute__(attr)
#endif
#endif
#ifndef PerlIO_stdoutf
extern int PerlIO_stdoutf _((const char *,...))
__attribute__((format (printf, 1, 2)));
#endif
#ifndef PerlIO_puts
extern int PerlIO_puts _((PerlIO *,const char *));
#endif
#ifndef PerlIO_open
extern PerlIO * PerlIO_open _((const char *,const char *));
#endif
#ifndef PerlIO_close
extern int PerlIO_close _((PerlIO *));
#endif
#ifndef PerlIO_eof
extern int PerlIO_eof _((PerlIO *));
#endif
#ifndef PerlIO_error
extern int PerlIO_error _((PerlIO *));
#endif
#ifndef PerlIO_clearerr
extern void PerlIO_clearerr _((PerlIO *));
#endif
#ifndef PerlIO_getc
extern int PerlIO_getc _((PerlIO *));
#endif
#ifndef PerlIO_putc
extern int PerlIO_putc _((PerlIO *,int));
#endif
#ifndef PerlIO_flush
extern int PerlIO_flush _((PerlIO *));
#endif
#ifndef PerlIO_ungetc
extern int PerlIO_ungetc _((PerlIO *,int));
#endif
#ifndef PerlIO_fileno
extern int PerlIO_fileno _((PerlIO *));
#endif
#ifndef PerlIO_fdopen
extern PerlIO * PerlIO_fdopen _((int, const char *));
#endif
#ifndef PerlIO_importFILE
extern PerlIO * PerlIO_importFILE _((FILE *,int));
#endif
#ifndef PerlIO_exportFILE
extern FILE * PerlIO_exportFILE _((PerlIO *,int));
#endif
#ifndef PerlIO_findFILE
extern FILE * PerlIO_findFILE _((PerlIO *));
#endif
#ifndef PerlIO_releaseFILE
extern void PerlIO_releaseFILE _((PerlIO *,FILE *));
#endif
#ifndef PerlIO_read
extern SSize_t PerlIO_read _((PerlIO *,void *,Size_t));
#endif
#ifndef PerlIO_write
extern SSize_t PerlIO_write _((PerlIO *,const void *,Size_t));
#endif
#ifndef PerlIO_setlinebuf
extern void PerlIO_setlinebuf _((PerlIO *));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -