~ubuntu-branches/ubuntu/feisty/libapache2-mod-perl2/feisty-security

« back to all changes in this revision

Viewing changes to xs/modperl_xs_util.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2004-08-19 06:23:48 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040819062348-jxl4koqbtvgm8v2t
Tags: 1.99.14-4
Remove the LFS CFLAGS, and build-dep against apache2-*-dev (>= 2.0.50-10)
as we're backing out of the apache2/apr ABI transition.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2001-2004 The Apache Software Foundation
 
2
 *
 
3
 * Licensed under the Apache License, Version 2.0 (the "License");
 
4
 * you may not use this file except in compliance with the License.
 
5
 * You may obtain a copy of the License at
 
6
 *
 
7
 *     http://www.apache.org/licenses/LICENSE-2.0
 
8
 *
 
9
 * Unless required by applicable law or agreed to in writing, software
 
10
 * distributed under the License is distributed on an "AS IS" BASIS,
 
11
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
12
 * See the License for the specific language governing permissions and
 
13
 * limitations under the License.
 
14
 */
 
15
 
1
16
#ifndef MODPERL_XS_H
2
17
#define MODPERL_XS_H
3
18
 
6
21
#define mp_xs_sv2_r(sv) modperl_sv2request_rec(aTHX_ sv)
7
22
 
8
23
#undef mp_xs_sv2_APR__Table
9
 
#define mp_xs_sv2_APR__Table(sv) \
10
 
   (apr_table_t *)modperl_hash_tied_object(aTHX_ "APR::Table", sv)
 
24
#define mp_xs_sv2_APR__Table(sv)                                        \
 
25
    (apr_table_t *)modperl_hash_tied_object(aTHX_ "APR::Table", sv)
11
26
 
12
27
#define mpxs_Apache__RequestRec_pool(r) r->pool
13
28
#define mpxs_Apache__Connection_pool(c) c->pool
22
37
#    define dITEMS I32 items = SP - MARK
23
38
#endif
24
39
 
25
 
#define mpxs_PPCODE(code) STMT_START { \
26
 
    SP -= items; \
27
 
    code; \
28
 
    PUTBACK; \
 
40
#define mpxs_PPCODE(code) STMT_START {          \
 
41
    SP -= items;                                \
 
42
    code;                                       \
 
43
    PUTBACK;                                    \
29
44
} STMT_END
30
45
 
31
46
#define PUSHs_mortal_iv(iv) PUSHs(sv_2mortal(newSViv(iv)))
40
55
 
41
56
#define mpxs_sv_cur_set(sv, len) MP_SvCUR_set(sv, len)
42
57
 
43
 
#define mpxs_set_targ(func, arg) \
44
 
STMT_START { \
45
 
    dXSTARG; \
46
 
    XSprePUSH; \
47
 
    func(aTHX_ TARG, arg); \
48
 
    PUSHTARG; \
49
 
    XSRETURN(1); \
 
58
#define mpxs_set_targ(func, arg)                \
 
59
    STMT_START {                                \
 
60
    dXSTARG;                                    \
 
61
    XSprePUSH;                                  \
 
62
    func(aTHX_ TARG, arg);                      \
 
63
    PUSHTARG;                                   \
 
64
    XSRETURN(1);                                \
50
65
} STMT_END
51
66
 
52
 
#define mpxs_cv_name() \
53
 
HvNAME(GvSTASH(CvGV(cv))), GvNAME(CvGV(cv))
54
 
 
55
 
#define mpxs_sv_is_object(sv) \
56
 
(SvROK(sv) && (SvTYPE(SvRV(sv)) == SVt_PVMG))
57
 
 
58
 
#define mpxs_sv_object_deref(sv, type) \
59
 
(mpxs_sv_is_object(sv) ? (type *)SvIVX((SV*)SvRV(sv)) : NULL)
60
 
 
61
 
#define mpxs_sv2_obj(obj, sv) \
62
 
(obj = mp_xs_sv2_##obj(sv))
63
 
 
64
 
#define mpxs_usage_items_1(arg) \
65
 
if (items != 1) { \
66
 
    Perl_croak(aTHX_ "usage: %s::%s(%s)", \
67
 
               mpxs_cv_name(), arg); \
68
 
}
69
 
 
70
 
#define mpxs_usage_va(i, obj, msg) \
71
 
if ((items < i) || !(mpxs_sv2_obj(obj, *MARK))) { \
72
 
    Perl_croak(aTHX_ "usage: %s", msg); \
73
 
} \
74
 
MARK++
 
67
#define mpxs_cv_name()                          \
 
68
    HvNAME(GvSTASH(CvGV(cv))), GvNAME(CvGV(cv))
 
69
 
 
70
#define mpxs_sv_is_object(sv)                           \
 
71
    (SvROK(sv) && (SvTYPE(SvRV(sv)) == SVt_PVMG))
 
72
 
 
73
#define mpxs_sv_object_deref(sv, type)                            \
 
74
    (mpxs_sv_is_object(sv) ? (type *)SvIVX((SV*)SvRV(sv)) : NULL)
 
75
 
 
76
#define mpxs_sv2_obj(obj, sv)                   \
 
77
    (obj = mp_xs_sv2_##obj(sv))
 
78
 
 
79
#define mpxs_usage_items_1(arg)                 \
 
80
    if (items != 1) {                           \
 
81
        Perl_croak(aTHX_ "usage: %s::%s(%s)",   \
 
82
                   mpxs_cv_name(), arg);        \
 
83
    }
 
84
 
 
85
#define mpxs_usage_va(i, obj, msg)                      \
 
86
    if ((items < i) || !(mpxs_sv2_obj(obj, *MARK))) {   \
 
87
        Perl_croak(aTHX_ "usage: %s", msg);             \
 
88
    }                                                   \
 
89
    MARK++
75
90
 
76
91
#define mpxs_usage_va_1(obj, msg) mpxs_usage_va(1, obj, msg)
77
92
 
78
 
#define mpxs_usage_va_2(obj, arg, msg) \
79
 
mpxs_usage_va(2, obj, msg); \
80
 
arg = *MARK++
 
93
#define mpxs_usage_va_2(obj, arg, msg)          \
 
94
    mpxs_usage_va(2, obj, msg);                 \
 
95
    arg = *MARK++
81
96
 
82
97
/* XXX: we probably shouldn't croak here */
83
 
#define mpxs_write_loop(func, obj) \
84
 
    while (MARK <= SP) { \
85
 
        apr_ssize_t wlen; \
86
 
        apr_status_t rv; \
87
 
        char *buf = SvPV(*MARK, wlen); \
88
 
        MP_TRACE_o(MP_FUNC, "%d bytes [%s]", wlen, buf); \
89
 
        rv = func(aTHX_ obj, buf, &wlen); \
90
 
        if (rv != APR_SUCCESS) { \
91
 
            Perl_croak(aTHX_ modperl_apr_strerror(rv)); \
92
 
        } \
93
 
        bytes += wlen; \
94
 
        MARK++; \
 
98
#define mpxs_write_loop(func, obj)                              \
 
99
    while (MARK <= SP) {                                        \
 
100
        apr_size_t wlen;                                        \
 
101
        apr_status_t rv;                                        \
 
102
        char *buf = SvPV(*MARK, wlen);                          \
 
103
        MP_TRACE_o(MP_FUNC, "%d bytes [%s]", wlen, buf);        \
 
104
        rv = func(aTHX_ obj, buf, &wlen);                       \
 
105
        if (rv != APR_SUCCESS) {                                \
 
106
            Perl_croak(aTHX_ modperl_error_strerror(aTHX_ rv)); \
 
107
        }                                                       \
 
108
        bytes += wlen;                                          \
 
109
        MARK++;                                                 \
95
110
    }
96
111
 
97
112
#endif /* MODPERL_XS_H */