summaryrefslogtreecommitdiffhomepage
path: root/src/perl/nxt_perl_psgi_layer.h
blob: 0972d66f10780a287c7e975f1711a41c9cac7f1d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

/*
 * Copyright (C) Alexander Borisov
 * Copyright (C) NGINX, Inc.
 */

#ifndef _NXT_PERL_PSGI_LAYER_H_INCLUDED_
#define _NXT_PERL_PSGI_LAYER_H_INCLUDED_


#include <EXTERN.h>
#include <XSUB.h>
#include <perl.h>
#include <perliol.h>


typedef struct nxt_perl_psgi_io_tab_s nxt_perl_psgi_io_tab_t;
typedef struct nxt_perl_psgi_io_arg_s nxt_perl_psgi_io_arg_t;


struct nxt_perl_psgi_io_tab_s {
    SSize_t (*read)(PerlInterpreter *my_perl,
        nxt_perl_psgi_io_arg_t *arg, void *vbuf, size_t length);
    SSize_t (*write)(PerlInterpreter *my_perl,
        nxt_perl_psgi_io_arg_t *arg, const void *vbuf, size_t length);
};


struct nxt_perl_psgi_io_arg_s {
    SV                            *rv;
    SV                            *io;
    PerlIO                        *fp;

    const nxt_perl_psgi_io_tab_t  *io_tab;

    void                          *req;
};


void nxt_perl_psgi_layer_stream_init(pTHX);

PerlIO *nxt_perl_psgi_layer_stream_fp_create(pTHX_ SV *arg_rv,
    const char *mode);
void nxt_perl_psgi_layer_stream_fp_destroy(pTHX_ PerlIO *io);

SV *nxt_perl_psgi_layer_stream_io_create(pTHX_ PerlIO *fp);

#endif /* _NXT_PERL_PSGI_LAYER_H_INCLUDED_ */