xref: /unit/src/perl/nxt_perl_psgi_layer.h (revision 2060:a1991578c62e)
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_tab_s nxt_perl_psgi_io_tab_t;
18 typedef struct nxt_perl_psgi_io_arg_s nxt_perl_psgi_io_arg_t;
19 
20 
21 struct nxt_perl_psgi_io_tab_s {
22     SSize_t (*read)(PerlInterpreter *my_perl,
23         nxt_perl_psgi_io_arg_t *arg, void *vbuf, size_t length);
24     SSize_t (*write)(PerlInterpreter *my_perl,
25         nxt_perl_psgi_io_arg_t *arg, const void *vbuf, size_t length);
26 };
27 
28 
29 struct nxt_perl_psgi_io_arg_s {
30     SV                            *rv;
31     SV                            *io;
32     PerlIO                        *fp;
33 
34     const nxt_perl_psgi_io_tab_t  *io_tab;
35 
36     void                          *req;
37 };
38 
39 
40 void nxt_perl_psgi_layer_stream_init(pTHX);
41 
42 PerlIO *nxt_perl_psgi_layer_stream_fp_create(pTHX_ SV *arg_rv,
43     const char *mode);
44 void nxt_perl_psgi_layer_stream_fp_destroy(pTHX_ PerlIO *io);
45 
46 SV *nxt_perl_psgi_layer_stream_io_create(pTHX_ PerlIO *fp);
47 
48 #endif /* _NXT_PERL_PSGI_LAYER_H_INCLUDED_ */
49