~ubuntu-branches/ubuntu/edgy/libapache2-mod-perl2/edgy-updates

« back to all changes in this revision

Viewing changes to src/modules/perl/modperl_mgv.c

  • 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
#include "mod_perl.h"
2
17
 
3
18
/*
84
99
    return symbol;
85
100
}
86
101
 
87
 
char *modperl_mgv_name_from_sv(pTHX_ apr_pool_t *p, SV *sv)
88
 
{
89
 
    char *name = NULL;
90
 
    GV *gv;
91
 
 
92
 
    if (SvROK(sv)) {
93
 
        sv = SvRV(sv);
94
 
    }
95
 
 
96
 
    switch (SvTYPE(sv)) {
97
 
      case SVt_PV:
98
 
        name = SvPVX(sv);
99
 
        break;
100
 
      case SVt_PVCV:
101
 
        if (CvANON((CV*)sv)) {
102
 
            Perl_croak(aTHX_ "anonymous handlers not (yet) supported");
103
 
        }
104
 
        gv = CvGV((CV*)sv);
105
 
        name = apr_pstrcat(p, HvNAME(GvSTASH(gv)), "::", GvNAME(gv), NULL);
106
 
        break;
107
 
    };
108
 
 
109
 
    return name;
110
 
}
111
 
 
112
102
void modperl_mgv_append(pTHX_ apr_pool_t *p, modperl_mgv_t *symbol,
113
103
                        const char *name)
114
104
{
223
213
    char *handler_name = "handler";
224
214
    char *tmp;
225
215
 
 
216
    if (MpHandlerANON(handler)) {
 
217
        /* already resolved anonymous handler */
 
218
        return 1;
 
219
    }
 
220
    
226
221
    if (strnEQ(name, "sub ", 4)) {
227
222
        MP_TRACE_h(MP_FUNC, "handler is anonymous\n");
228
223
        MpHandlerANON_On(handler);
298
293
                       "package %s not in %INC, attempting to load '%s'\n",
299
294
                       name, filename);
300
295
 
301
 
            if (modperl_require_module(aTHX_ name, FALSE)) {
 
296
            if (modperl_require_module(aTHX_ name, logfailure)) {
302
297
                MP_TRACE_h(MP_FUNC, "loaded %s package\n", name);
303
298
            }
304
299
            else {
305
 
                MP_TRACE_h(MP_FUNC, "failed to load %s package\n", name);
306
 
                return 0;
 
300
                if (logfailure) {
 
301
                    /* the caller doesn't handle the error checking */
 
302
                    Perl_croak(aTHX_ "failed to load %s package\n", name);
 
303
                }
 
304
                else {
 
305
                    /* the caller handles the error checking */
 
306
                    MP_TRACE_h(MP_FUNC, "failied to load %s package\n", name);
 
307
                    return 0;
 
308
                }
307
309
            }
308
310
        }
309
311
        else {
310
312
            MP_TRACE_h(MP_FUNC, "package %s seems to be loaded\n"
311
 
                       "  $INC{%s)='%s';\n",
 
313
                       "  $INC{'%s')='%s';\n",
312
314
                       name, filename, SvPV_nolen(*svp));
313
315
        }
314
316
    }
318
320
     * module was loaded, preventing from loading the module
319
321
     */
320
322
    if (!(stash || (stash = gv_stashpv(name, FALSE)))) {
321
 
        MP_TRACE_h(MP_FUNC, "package %s seems to be loaded, "
322
 
                   "but can't find its stash\n", name);
 
323
        MP_TRACE_h(MP_FUNC, "%s's stash is not found\n", name);
323
324
        return 0;
324
325
    }
325
326
 
346
347
        return 1;
347
348
    }
348
349
 
 
350
    /* at least modperl_hash_handlers needs to verify that an
 
351
     * autoloaded-marked handler needs to be loaded, since it doesn't
 
352
     * check success failure, and handlers marked to be autoloaded are
 
353
     * the same as PerlModule and the failure should be fatal */
 
354
    if (MpHandlerAUTOLOAD(handler)) {
 
355
        Perl_croak(aTHX_ "failed to resolve handler %s\n", name);
 
356
    }
 
357
    
349
358
#ifdef MP_TRACE
350
359
    /* complain only if the class was actually loaded/created */
351
360
    if (stash) {
417
426
}
418
427
#endif
419
428
 
420
 
/* precompute the hash(es) for handler names */
 
429
/* precompute the hash(es) for handler names, preload handlers
 
430
 * configured to be autoloaded */
421
431
static void modperl_hash_handlers(pTHX_ apr_pool_t *p, server_rec *s,
422
432
                                  MpAV *entry, void *data)
423
433
{