On Wed, Oct 03, 2001 at 09:51:09AM -0700, Doug MacEachern wrote:
> On Tue, 2 Oct 2001, Philippe M . Chiasson wrote:
>
> > Hi, this patch implements the Apache->module() functionnality with a few
>differences.
> >
> > Apache->module() is in Apache::compat and the real name for this is
>Apache::Module::loaded()
> > and I am open for better suggestions. "if (Apache->module('Apache::Auth'))"
>doesn't quite
> > make as much sense to me than "if (Apache::Module::loaded('Apache::Auth'))"
>
> name is fine.
>
> > +
> > +MP_INLINE module *modperl_get_ap_module(const char *name)
> > +{
> > + module *modp;
> > + for (modp = ap_top_module; modp; modp = modp->next) {
> > + if (modp && modp->name && ( 0 == apr_strnatcmp(modp->name, name))) {
> > + return modp;
> > + }
> > + }
> > + return NULL;
> > +}
>
> why not just use ap_find_linked_module like 1.x does?
Good idea, I must have overlooked that one.
>
> > +MP_INLINE int modperl_is_module_loaded(pTHX_ const char *name)
> > +{
> > + return (NULL != gv_stashpv(name, FALSE));
> > +}
>
> this also needs to be as 1.x is, checking that the module exists in %INC
Can you tell me exactly why ? I started doing it the way 1.x used to do it
but it was pretty complicated and I thought about this method instead, that
sounded as good yet a lot simpler. Care to explain why we need to check %INC
for real ?
> as for the malloc, we should avoid that. see if you can work off
> this..
Good idea, will try to get that in soon.
One question remains though, if I am stuck in some bit of code that doesn't
get passed anything interesting as arguments, how can I cleanly get my hands
on the current apr_pool ?
> #include <stdio.h>
> #include <string.h>
>
> int module_loaded(const char *module_name)
> {
> char name[256]; /* should be plenty of space */
> const char *nameptr = name, *base;
>
> if ((base = strchr(module_name, '.'))) {
> int len = base - module_name;
> int shared;
>
> memcpy((void*)nameptr, module_name, len);
> memcpy((void*)nameptr + len, ".c\0", 3);
>
> fprintf(stderr, "cmodule name=%s\n", nameptr);
> /* if (!(modp = ap_find_linked_module(nameptr))) return 0; */
>
> shared = *(base + 1) == 'c' ? 0 : 1;
>
> if (shared) {
> fprintf(stderr, "checking for shared module\n");
> /* if (!modp->dynamic_load_handle) return 0; */
> }
>
> return 1;
> }
>
>
> fprintf(stderr, "perl module name=%s\n", module_name);
> /* if (modperl_perl_module_loaded(module_name) return 1; else */
> return 0;
> }
>
> static const char *modules[] = {
> "mod_perl.c", "mod_perl.so", "Apache::Status", NULL,
> };
>
> int main(int argc, char **argv, char **env)
> {
> int i;
> for (i=0; modules[i]; i++) {
> module_loaded(modules[i]);
> }
> return 0;
> }
>
>
--
+----------------------------------------------------+
| Philippe M. Chiasson <[EMAIL PROTECTED]> |
+----------------------------------------------------+
| F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3 A5A5 |
+----------------------------------------------------+
gethostent not implemented : Your C library apparently
doesn't implement gethostent(), probably because if it did,
it'd feel morally obligated to return every hostname on the
Internet.
-- perldiag(1)
perl -e '$$=\${gozer};{$_=unpack(P26,pack(L,$$));/^Just Another Perl
Hacker!\n$/&&print||$$++&&redo}'
PGP signature