1 2 /* 3 * Copyright (C) Alexander Borisov 4 * Copyright (C) NGINX, Inc. 5 */ 6 7 #ifndef _NXT_PERL_PSGI_LAYER_H_INCLUDED_ 8 #define _NXT_PERL_PSGI_LAYER_H_INCLUDED_ 9 10 11 #include <EXTERN.h> 12 #include <XSUB.h> 13 #include <perl.h> 14 #include <perliol.h> 15 16 17 typedef struct nxt_perl_psgi_io_arg nxt_perl_psgi_io_arg_t; 18 19 typedef long (*nxt_perl_psgi_io_read_f)(PerlInterpreter *my_perl, 20 nxt_perl_psgi_io_arg_t *arg, void *vbuf, size_t length); 21 typedef long (*nxt_perl_psgi_io_write_f)(PerlInterpreter *my_perl, 22 nxt_perl_psgi_io_arg_t *arg, const void *vbuf, size_t length); 23 typedef long (*nxt_perl_psgi_io_arg_f)(PerlInterpreter *my_perl, 24 nxt_perl_psgi_io_arg_t *arg); 25 26 27 struct nxt_perl_psgi_io_arg { 28 SV *io; 29 PerlIO *fp; 30 31 nxt_perl_psgi_io_arg_f flush; 32 nxt_perl_psgi_io_read_f read; 33 nxt_perl_psgi_io_write_f write; 34 35 void *ctx; 36 }; 37 38 39 void nxt_perl_psgi_layer_stream_init(pTHX); 40 41 PerlIO *nxt_perl_psgi_layer_stream_fp_create(pTHX_ nxt_perl_psgi_io_arg_t *arg, 42 const char *mode); 43 void nxt_perl_psgi_layer_stream_fp_destroy(pTHX_ PerlIO *io); 44 45 SV *nxt_perl_psgi_layer_stream_io_create(pTHX_ PerlIO *fp); 46 void nxt_perl_psgi_layer_stream_io_destroy(pTHX_ SV *rvio); 47 48 #endif /* _NXT_PERL_PSGI_LAYER_H_INCLUDED_ */ 49