"Fossies" - the Fresh Open Source Software Archive

Member "install-tl-20200916/tlpkg/tlperl/lib/CORE/perliol.h" (10 Mar 2019, 13761 Bytes) of package /windows/misc/install-tl.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #ifndef PERLIOL_H_
    2 #define PERLIOL_H_
    3 
    4 typedef struct {
    5     PerlIO_funcs *funcs;
    6     SV *arg;
    7 } PerlIO_pair_t;
    8 
    9 struct PerlIO_list_s {
   10     IV refcnt;
   11     IV cur;
   12     IV len;
   13     PerlIO_pair_t *array;
   14 };
   15 
   16 struct _PerlIO_funcs {
   17     Size_t fsize;
   18     const char *name;
   19     Size_t size;
   20     U32 kind;
   21     IV (*Pushed) (pTHX_ PerlIO *f, const char *mode, SV *arg, PerlIO_funcs *tab);
   22     IV (*Popped) (pTHX_ PerlIO *f);
   23     PerlIO *(*Open) (pTHX_ PerlIO_funcs *tab,
   24              PerlIO_list_t *layers, IV n,
   25              const char *mode,
   26              int fd, int imode, int perm,
   27              PerlIO *old, int narg, SV **args);
   28     IV (*Binmode)(pTHX_ PerlIO *f);
   29     SV *(*Getarg) (pTHX_ PerlIO *f, CLONE_PARAMS *param, int flags);
   30     IV (*Fileno) (pTHX_ PerlIO *f);
   31     PerlIO *(*Dup) (pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *param, int flags);
   32     /* Unix-like functions - cf sfio line disciplines */
   33      SSize_t(*Read) (pTHX_ PerlIO *f, void *vbuf, Size_t count);
   34      SSize_t(*Unread) (pTHX_ PerlIO *f, const void *vbuf, Size_t count);
   35      SSize_t(*Write) (pTHX_ PerlIO *f, const void *vbuf, Size_t count);
   36     IV (*Seek) (pTHX_ PerlIO *f, Off_t offset, int whence);
   37      Off_t(*Tell) (pTHX_ PerlIO *f);
   38     IV (*Close) (pTHX_ PerlIO *f);
   39     /* Stdio-like buffered IO functions */
   40     IV (*Flush) (pTHX_ PerlIO *f);
   41     IV (*Fill) (pTHX_ PerlIO *f);
   42     IV (*Eof) (pTHX_ PerlIO *f);
   43     IV (*Error) (pTHX_ PerlIO *f);
   44     void (*Clearerr) (pTHX_ PerlIO *f);
   45     void (*Setlinebuf) (pTHX_ PerlIO *f);
   46     /* Perl's snooping functions */
   47     STDCHAR *(*Get_base) (pTHX_ PerlIO *f);
   48      Size_t(*Get_bufsiz) (pTHX_ PerlIO *f);
   49     STDCHAR *(*Get_ptr) (pTHX_ PerlIO *f);
   50      SSize_t(*Get_cnt) (pTHX_ PerlIO *f);
   51     void (*Set_ptrcnt) (pTHX_ PerlIO *f, STDCHAR * ptr, SSize_t cnt);
   52 };
   53 
   54 /*--------------------------------------------------------------------------------------*/
   55 /* Kind values */
   56 #define PERLIO_K_RAW        0x00000001
   57 #define PERLIO_K_BUFFERED   0x00000002
   58 #define PERLIO_K_CANCRLF    0x00000004
   59 #define PERLIO_K_FASTGETS   0x00000008
   60 #define PERLIO_K_DUMMY      0x00000010
   61 #define PERLIO_K_UTF8       0x00008000
   62 #define PERLIO_K_DESTRUCT   0x00010000
   63 #define PERLIO_K_MULTIARG   0x00020000
   64 
   65 /*--------------------------------------------------------------------------------------*/
   66 struct _PerlIO {
   67     PerlIOl *next;      /* Lower layer */
   68     PerlIO_funcs *tab;      /* Functions for this layer */
   69     U32 flags;          /* Various flags for state */
   70     int err;            /* Saved errno value */
   71 #ifdef VMS
   72     unsigned os_err;        /* Saved vaxc$errno value */
   73 #elif defined (OS2)
   74     unsigned long os_err;
   75 #elif defined (WIN32)
   76     DWORD os_err;       /* Saved GetLastError() value */
   77 #endif
   78     PerlIOl *head;      /* our ultimate parent pointer */
   79 };
   80 
   81 /*--------------------------------------------------------------------------------------*/
   82 
   83 /* Flag values */
   84 #define PERLIO_F_EOF        0x00000100
   85 #define PERLIO_F_CANWRITE   0x00000200
   86 #define PERLIO_F_CANREAD    0x00000400
   87 #define PERLIO_F_ERROR      0x00000800
   88 #define PERLIO_F_TRUNCATE   0x00001000
   89 #define PERLIO_F_APPEND     0x00002000
   90 #define PERLIO_F_CRLF       0x00004000
   91 #define PERLIO_F_UTF8       0x00008000
   92 #define PERLIO_F_UNBUF      0x00010000
   93 #define PERLIO_F_WRBUF      0x00020000
   94 #define PERLIO_F_RDBUF      0x00040000
   95 #define PERLIO_F_LINEBUF    0x00080000
   96 #define PERLIO_F_TEMP       0x00100000
   97 #define PERLIO_F_OPEN       0x00200000
   98 #define PERLIO_F_FASTGETS   0x00400000
   99 #define PERLIO_F_TTY        0x00800000
  100 #define PERLIO_F_NOTREG         0x01000000   
  101 #define PERLIO_F_CLEARED        0x02000000 /* layer cleared but not freed */
  102 
  103 #define PerlIOBase(f)      (*(f))
  104 #define PerlIOSelf(f,type) ((type *)PerlIOBase(f))
  105 #define PerlIONext(f)      (&(PerlIOBase(f)->next))
  106 #define PerlIOValid(f)     ((f) && *(f))
  107 
  108 /*--------------------------------------------------------------------------------------*/
  109 /* Data exports - EXTCONST rather than extern is needed for Cygwin */
  110 #undef EXTPERLIO 
  111 #ifdef PERLIO_FUNCS_CONST
  112 #define EXTPERLIO EXTCONST
  113 #else
  114 #define EXTPERLIO EXT
  115 #endif
  116 EXTPERLIO PerlIO_funcs PerlIO_unix;
  117 EXTPERLIO PerlIO_funcs PerlIO_perlio;
  118 EXTPERLIO PerlIO_funcs PerlIO_stdio;
  119 EXTPERLIO PerlIO_funcs PerlIO_crlf;
  120 EXTPERLIO PerlIO_funcs PerlIO_utf8;
  121 EXTPERLIO PerlIO_funcs PerlIO_byte;
  122 EXTPERLIO PerlIO_funcs PerlIO_raw;
  123 EXTPERLIO PerlIO_funcs PerlIO_pending;
  124 #ifdef WIN32
  125 EXTPERLIO PerlIO_funcs PerlIO_win32;
  126 #endif
  127 PERL_CALLCONV PerlIO *PerlIO_allocate(pTHX);
  128 PERL_CALLCONV SV *PerlIO_arg_fetch(PerlIO_list_t *av, IV n);
  129 #define PerlIOArg PerlIO_arg_fetch(layers,n)
  130 
  131 #ifdef PERLIO_USING_CRLF
  132 #define PERLIO_STDTEXT "t"
  133 #else
  134 #define PERLIO_STDTEXT ""
  135 #endif
  136 
  137 /*--------------------------------------------------------------------------------------*/
  138 /* perlio buffer layer
  139    As this is reasonably generic its struct and "methods" are declared here
  140    so they can be used to "inherit" from it.
  141 */
  142 
  143 typedef struct {
  144     struct _PerlIO base;    /* Base "class" info */
  145     STDCHAR *buf;       /* Start of buffer */
  146     STDCHAR *end;       /* End of valid part of buffer */
  147     STDCHAR *ptr;       /* Current position in buffer */
  148     Off_t posn;         /* Offset of buf into the file */
  149     Size_t bufsiz;      /* Real size of buffer */
  150     IV oneword;         /* Emergency buffer */
  151 } PerlIOBuf;
  152 
  153 PERL_CALLCONV int PerlIO_apply_layera(pTHX_ PerlIO *f, const char *mode,
  154             PerlIO_list_t *layers, IV n, IV max);
  155 PERL_CALLCONV int PerlIO_parse_layers(pTHX_ PerlIO_list_t *av, const char *names);
  156 PERL_CALLCONV PerlIO_funcs *PerlIO_layer_fetch(pTHX_ PerlIO_list_t *av, IV n, PerlIO_funcs *def);
  157 
  158 
  159 PERL_CALLCONV SV *PerlIO_sv_dup(pTHX_ SV *arg, CLONE_PARAMS *param);
  160 PERL_CALLCONV void PerlIO_cleantable(pTHX_ PerlIOl **tablep);
  161 PERL_CALLCONV SV * PerlIO_tab_sv(pTHX_ PerlIO_funcs *tab);
  162 PERL_CALLCONV void PerlIO_default_buffer(pTHX_ PerlIO_list_t *av);
  163 PERL_CALLCONV void PerlIO_stdstreams(pTHX);
  164 PERL_CALLCONV int PerlIO__close(pTHX_ PerlIO *f);
  165 PERL_CALLCONV PerlIO_list_t * PerlIO_resolve_layers(pTHX_ const char *layers, const char *mode, int narg, SV **args);
  166 PERL_CALLCONV PerlIO_funcs * PerlIO_default_layer(pTHX_ I32 n);
  167 PERL_CALLCONV PerlIO_list_t * PerlIO_default_layers(pTHX);
  168 PERL_CALLCONV PerlIO * PerlIO_reopen(const char *path, const char *mode, PerlIO *f);
  169 
  170 PERL_CALLCONV PerlIO_list_t *PerlIO_list_alloc(pTHX);
  171 PERL_CALLCONV PerlIO_list_t *PerlIO_clone_list(pTHX_ PerlIO_list_t *proto, CLONE_PARAMS *param);
  172 PERL_CALLCONV void PerlIO_list_free(pTHX_ PerlIO_list_t *list);
  173 PERL_CALLCONV void PerlIO_list_push(pTHX_ PerlIO_list_t *list, PerlIO_funcs *funcs, SV *arg);
  174 PERL_CALLCONV void PerlIO_list_free(pTHX_ PerlIO_list_t *list);
  175 
  176 /* PerlIO_teardown doesn't need exporting, but the EXTERN_C is needed
  177  * for compiling as C++.  Must also match with what perl.h says. */
  178 EXTERN_C void PerlIO_teardown(void);
  179 
  180 /*--------------------------------------------------------------------------------------*/
  181 /* Generic, or stub layer functions */
  182 
  183 PERL_CALLCONV IV        PerlIOBase_binmode(pTHX_ PerlIO *f);
  184 PERL_CALLCONV void      PerlIOBase_clearerr(pTHX_ PerlIO *f);
  185 PERL_CALLCONV IV        PerlIOBase_close(pTHX_ PerlIO *f);
  186 PERL_CALLCONV PerlIO *  PerlIOBase_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *param, int flags);
  187 PERL_CALLCONV IV        PerlIOBase_eof(pTHX_ PerlIO *f);
  188 PERL_CALLCONV IV        PerlIOBase_error(pTHX_ PerlIO *f);
  189 PERL_CALLCONV IV        PerlIOBase_fileno(pTHX_ PerlIO *f);
  190 PERL_CALLCONV void      PerlIOBase_flush_linebuf(pTHX);
  191 PERL_CALLCONV IV        PerlIOBase_noop_fail(pTHX_ PerlIO *f);
  192 PERL_CALLCONV IV        PerlIOBase_noop_ok(pTHX_ PerlIO *f);
  193 PERL_CALLCONV IV        PerlIOBase_popped(pTHX_ PerlIO *f);
  194 PERL_CALLCONV IV        PerlIOBase_pushed(pTHX_ PerlIO *f, const char *mode, SV *arg, PerlIO_funcs *tab);
  195 PERL_CALLCONV PerlIO *  PerlIOBase_open(pTHX_ PerlIO_funcs *self, PerlIO_list_t *layers, IV n, const char *mode, int fd, int imode, int perm, PerlIO *old, int narg, SV **args);
  196 PERL_CALLCONV SSize_t   PerlIOBase_read(pTHX_ PerlIO *f, void *vbuf, Size_t count);
  197 PERL_CALLCONV void      PerlIOBase_setlinebuf(pTHX_ PerlIO *f);
  198 PERL_CALLCONV SSize_t   PerlIOBase_unread(pTHX_ PerlIO *f, const void *vbuf, Size_t count);
  199 
  200 /* Buf */
  201 PERL_CALLCONV Size_t    PerlIOBuf_bufsiz(pTHX_ PerlIO *f);
  202 PERL_CALLCONV IV        PerlIOBuf_close(pTHX_ PerlIO *f);
  203 PERL_CALLCONV PerlIO *  PerlIOBuf_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *param, int flags);
  204 PERL_CALLCONV IV        PerlIOBuf_fill(pTHX_ PerlIO *f);
  205 PERL_CALLCONV IV        PerlIOBuf_flush(pTHX_ PerlIO *f);
  206 PERL_CALLCONV STDCHAR * PerlIOBuf_get_base(pTHX_ PerlIO *f);
  207 PERL_CALLCONV SSize_t   PerlIOBuf_get_cnt(pTHX_ PerlIO *f);
  208 PERL_CALLCONV STDCHAR * PerlIOBuf_get_ptr(pTHX_ PerlIO *f);
  209 PERL_CALLCONV PerlIO *  PerlIOBuf_open(pTHX_ PerlIO_funcs *self, PerlIO_list_t *layers, IV n, const char *mode, int fd, int imode, int perm, PerlIO *old, int narg, SV **args);
  210 PERL_CALLCONV IV        PerlIOBuf_popped(pTHX_ PerlIO *f);
  211 PERL_CALLCONV IV        PerlIOBuf_pushed(pTHX_ PerlIO *f, const char *mode, SV *arg, PerlIO_funcs *tab);
  212 PERL_CALLCONV SSize_t   PerlIOBuf_read(pTHX_ PerlIO *f, void *vbuf, Size_t count);
  213 PERL_CALLCONV IV        PerlIOBuf_seek(pTHX_ PerlIO *f, Off_t offset, int whence);
  214 PERL_CALLCONV void      PerlIOBuf_set_ptrcnt(pTHX_ PerlIO *f, STDCHAR * ptr, SSize_t cnt);
  215 PERL_CALLCONV Off_t     PerlIOBuf_tell(pTHX_ PerlIO *f);
  216 PERL_CALLCONV SSize_t   PerlIOBuf_unread(pTHX_ PerlIO *f, const void *vbuf, Size_t count);
  217 PERL_CALLCONV SSize_t   PerlIOBuf_write(pTHX_ PerlIO *f, const void *vbuf, Size_t count);
  218 
  219 /* Crlf */
  220 PERL_CALLCONV IV        PerlIOCrlf_binmode(pTHX_ PerlIO *f);
  221 PERL_CALLCONV IV        PerlIOCrlf_flush(pTHX_ PerlIO *f);
  222 PERL_CALLCONV SSize_t   PerlIOCrlf_get_cnt(pTHX_ PerlIO *f);
  223 PERL_CALLCONV IV        PerlIOCrlf_pushed(pTHX_ PerlIO *f, const char *mode, SV *arg, PerlIO_funcs *tab);
  224 PERL_CALLCONV void      PerlIOCrlf_set_ptrcnt(pTHX_ PerlIO *f, STDCHAR * ptr, SSize_t cnt);
  225 PERL_CALLCONV SSize_t   PerlIOCrlf_unread(pTHX_ PerlIO *f, const void *vbuf, Size_t count);
  226 PERL_CALLCONV SSize_t   PerlIOCrlf_write(pTHX_ PerlIO *f, const void *vbuf, Size_t count);
  227 
  228 /* Pending */
  229 PERL_CALLCONV IV        PerlIOPending_close(pTHX_ PerlIO *f);
  230 PERL_CALLCONV IV        PerlIOPending_fill(pTHX_ PerlIO *f);
  231 PERL_CALLCONV IV        PerlIOPending_flush(pTHX_ PerlIO *f);
  232 PERL_CALLCONV IV        PerlIOPending_pushed(pTHX_ PerlIO *f, const char *mode, SV *arg, PerlIO_funcs *tab);
  233 PERL_CALLCONV SSize_t   PerlIOPending_read(pTHX_ PerlIO *f, void *vbuf, Size_t count);
  234 PERL_CALLCONV IV        PerlIOPending_seek(pTHX_ PerlIO *f, Off_t offset, int whence);
  235 PERL_CALLCONV void      PerlIOPending_set_ptrcnt(pTHX_ PerlIO *f, STDCHAR * ptr, SSize_t cnt);
  236 
  237 /* Pop */
  238 PERL_CALLCONV IV        PerlIOPop_pushed(pTHX_ PerlIO *f, const char *mode, SV *arg, PerlIO_funcs *tab);
  239 
  240 /* Raw */
  241 PERL_CALLCONV IV        PerlIORaw_pushed(pTHX_ PerlIO *f, const char *mode, SV *arg, PerlIO_funcs *tab);
  242 
  243 /* Stdio */
  244 PERL_CALLCONV void      PerlIOStdio_clearerr(pTHX_ PerlIO *f);
  245 PERL_CALLCONV IV        PerlIOStdio_close(pTHX_ PerlIO *f);
  246 PERL_CALLCONV PerlIO *  PerlIOStdio_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *param, int flags);
  247 PERL_CALLCONV IV        PerlIOStdio_eof(pTHX_ PerlIO *f);
  248 PERL_CALLCONV IV        PerlIOStdio_error(pTHX_ PerlIO *f);
  249 PERL_CALLCONV IV        PerlIOStdio_fileno(pTHX_ PerlIO *f);
  250 #ifdef USE_STDIO_PTR
  251 PERL_CALLCONV STDCHAR * PerlIOStdio_get_ptr(pTHX_ PerlIO *f);
  252 PERL_CALLCONV SSize_t   PerlIOStdio_get_cnt(pTHX_ PerlIO *f);
  253 PERL_CALLCONV void      PerlIOStdio_set_ptrcnt(pTHX_ PerlIO *f, STDCHAR * ptr, SSize_t cnt);
  254 #endif
  255 PERL_CALLCONV IV        PerlIOStdio_fill(pTHX_ PerlIO *f);
  256 PERL_CALLCONV IV        PerlIOStdio_flush(pTHX_ PerlIO *f);
  257 #ifdef FILE_base
  258 PERL_CALLCONV STDCHAR * PerlIOStdio_get_base(pTHX_ PerlIO *f);
  259 PERL_CALLCONV Size_t    PerlIOStdio_get_bufsiz(pTHX_ PerlIO *f);
  260 #endif
  261 PERL_CALLCONV char *    PerlIOStdio_mode(const char *mode, char *tmode);
  262 PERL_CALLCONV PerlIO *  PerlIOStdio_open(pTHX_ PerlIO_funcs *self, PerlIO_list_t *layers, IV n, const char *mode, int fd, int imode, int perm, PerlIO *f, int narg, SV **args);
  263 PERL_CALLCONV IV        PerlIOStdio_pushed(pTHX_ PerlIO *f, const char *mode, SV *arg, PerlIO_funcs *tab);
  264 PERL_CALLCONV SSize_t   PerlIOStdio_read(pTHX_ PerlIO *f, void *vbuf, Size_t count);
  265 PERL_CALLCONV IV        PerlIOStdio_seek(pTHX_ PerlIO *f, Off_t offset, int whence);
  266 PERL_CALLCONV void      PerlIOStdio_setlinebuf(pTHX_ PerlIO *f);
  267 PERL_CALLCONV Off_t     PerlIOStdio_tell(pTHX_ PerlIO *f);
  268 PERL_CALLCONV SSize_t   PerlIOStdio_unread(pTHX_ PerlIO *f, const void *vbuf, Size_t count);
  269 PERL_CALLCONV SSize_t   PerlIOStdio_write(pTHX_ PerlIO *f, const void *vbuf, Size_t count);
  270 
  271 /* Unix */
  272 PERL_CALLCONV IV        PerlIOUnix_close(pTHX_ PerlIO *f);
  273 PERL_CALLCONV PerlIO *  PerlIOUnix_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *param, int flags);
  274 PERL_CALLCONV IV        PerlIOUnix_fileno(pTHX_ PerlIO *f);
  275 PERL_CALLCONV int       PerlIOUnix_oflags(const char *mode);
  276 PERL_CALLCONV PerlIO *  PerlIOUnix_open(pTHX_ PerlIO_funcs *self, PerlIO_list_t *layers, IV n, const char *mode, int fd, int imode, int perm, PerlIO *f, int narg, SV **args);
  277 PERL_CALLCONV IV        PerlIOUnix_pushed(pTHX_ PerlIO *f, const char *mode, SV *arg, PerlIO_funcs *tab);
  278 PERL_CALLCONV SSize_t   PerlIOUnix_read(pTHX_ PerlIO *f, void *vbuf, Size_t count);
  279 PERL_CALLCONV int       PerlIOUnix_refcnt_dec(int fd);
  280 PERL_CALLCONV void      PerlIOUnix_refcnt_inc(int fd);
  281 PERL_CALLCONV int       PerlIOUnix_refcnt(int fd);
  282 PERL_CALLCONV IV        PerlIOUnix_seek(pTHX_ PerlIO *f, Off_t offset, int whence);
  283 PERL_CALLCONV Off_t     PerlIOUnix_tell(pTHX_ PerlIO *f);
  284 PERL_CALLCONV SSize_t   PerlIOUnix_write(pTHX_ PerlIO *f, const void *vbuf, Size_t count);
  285 
  286 /* Utf8 */
  287 PERL_CALLCONV IV        PerlIOUtf8_pushed(pTHX_ PerlIO *f, const char *mode, SV *arg, PerlIO_funcs *tab);
  288 
  289 #endif              /* PERLIOL_H_ */
  290 
  291 /*
  292  * ex: set ts=8 sts=4 sw=4 et:
  293  */