⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 apxs.in

📁 Apache HTTP Server 是一个功能强大的灵活的与HTTP/1.1相兼容的web服务器.这里给出的是Apache HTTP服务器的源码。
💻 IN
📖 第 1 页 / 共 2 页
字号:
    my @cmds = ();    my $opt = '';    my ($opt_Wc, $opt_I, $opt_D);    foreach $opt_Wc (@opt_W) {        $opt .= "$1 " if ($opt_Wc =~ m|^\s*c,(.*)$|);    }    foreach $opt_I (@opt_I) {        $opt .= "-I$opt_I ";    }    foreach $opt_D (@opt_D) {        $opt .= "-D$opt_D ";    }    my $cflags = "$CFG_CFLAGS";    my $s;    my $mod;    foreach $s (@srcs) {        my $slo = $s;        $slo =~ s|\.c$|.slo|;        my $lo = $s;        $lo =~ s|\.c$|.lo|;        my $la = $s;        $la =~ s|\.c$|.la|;        my $o = $s;        $o =~ s|\.c$|.o|;        push(@cmds, "$libtool $ltflags --mode=compile $CFG_CC $cflags -I$CFG_INCLUDEDIR $apr_includedir $apu_includedir $opt -c -o $lo $s && touch $slo");        unshift(@objs, $lo);    }    #   create link command    my $o;    my $lo;	    foreach $o (@objs) {        $lo .= " $o";    }    my ($opt_Wl, $opt_L, $opt_l);    $opt = '';    foreach $opt_Wl (@opt_W) {        $opt .= "$1 " if ($opt_Wl =~ m|^\s*l,(.*)$|);    }    foreach $opt_L (@opt_L) {        $opt .= " -L$opt_L";    }    foreach $opt_l (@opt_l) {        $opt .= " -l$opt_l";    }    if ($opt_p == 1) {                my $apr_libs=`$apr_bindir/apr-config --ldflags --link-libtool --libs`;        chomp($apr_libs);        my $apu_libs=`$apu_bindir/apu-config --ldflags --link-libtool --libs`;        chomp($apu_libs);                $opt .= " ".$apu_libs." ".$apr_libs;    }    else {        my $apr_ldflags=`$apr_bindir/apr-config --ldflags`;        chomp($apr_ldflags);        $opt .= " -rpath $CFG_LIBEXECDIR -module -avoid-version $apr_ldflags";    }    push(@cmds, "$libtool $ltflags --mode=link $CFG_CC -o $dso_file $opt $lo");    #   execute the commands    &execute_cmds(@cmds);    #   allow one-step compilation and installation    if ($opt_i or $opt_e) {        @args = ( $dso_file );    }}if ($opt_i or $opt_e) {    ##    ##  SHARED OBJECT INSTALLATION    ##    #   determine installation commands    #   and corresponding LoadModule/AddModule directives    my @lmd = ();    my @amd = ();    my @cmds = ();    my $f;    foreach $f (@args) {        if ($f !~ m#(\.so$|\.la$)#) {            error("file $f is not a shared object");            exit(1);        }        my $t = $f;        $t =~ s|^.+/([^/]+)$|$1|;        $t =~ s|\.la$|\.so|;        if ($opt_i) {	    push(@cmds, "$installbuilddir/instdso.sh SH_LIBTOOL='" .                 "$libtool' $f $CFG_LIBEXECDIR");	    push(@cmds, "chmod 755 $CFG_LIBEXECDIR/$t");        }        #   determine module symbolname and filename        my $filename = '';        if ($name eq 'unknown') {            $name = '';            my $base = $f;            $base =~ s|\.[^.]+$||;            if (-f "$base.c") {                open(FP, "<$base.c");                my $content = join('', <FP>);                close(FP);                if ($content =~ m|.*module\s+(?:AP_MODULE_DECLARE_DATA\s+)?([a-zA-Z0-9_]+)_module\s*=\s*.*|s) {                    $name = "$1";                    $filename = "$base.c";                    $filename =~ s|^[^/]+/||;                }            }            if ($name eq '') {                if ($base =~ m|.*mod_([a-zA-Z0-9_]+)\..+|) {                    $name = "$1";                    $filename = $base;                    $filename =~ s|^[^/]+/||;                }            }            if ($name eq '') {                error("Sorry, cannot determine bootstrap symbol name");                error("Please specify one with option `-n'");                exit(1);            }        }        if ($filename eq '') {            $filename = "mod_${name}.c";        }        my $dir = $CFG_LIBEXECDIR;        $dir =~ s|^$CFG_PREFIX/?||;        $dir =~ s|(.)$|$1/|;	$t =~ s|\.la$|.so|;        push(@lmd, sprintf("LoadModule %-18s %s", "${name}_module", "$dir$t"));        push(@amd, sprintf("AddModule %s", $filename));    }    #   execute the commands    &execute_cmds(@cmds);    #   activate module via LoadModule/AddModule directive    if ($opt_a or $opt_A) {        if (not -f "$CFG_SYSCONFDIR/$CFG_TARGET.conf") {            error("Config file $CFG_SYSCONFDIR/$CFG_TARGET.conf not found");            exit(1);        }        open(FP, "<$CFG_SYSCONFDIR/$CFG_TARGET.conf") || die;        my $content = join('', <FP>);        close(FP);        if ($content !~ m|\n#?\s*LoadModule\s+|) {            error("Activation failed for custom $CFG_SYSCONFDIR/$CFG_TARGET.conf file.");            error("At least one `LoadModule' directive already has to exist.");            exit(1);        }        my $lmd;        my $c = '';        $c = '#' if ($opt_A);        foreach $lmd (@lmd) {            my $what = $opt_A ? "preparing" : "activating";            if ($content !~ m|\n#?\s*$lmd|) {                # check for open <containers>, so that the new LoadModule                # directive always appears *outside* of an <container>.                my $before = ($content =~ m|^(.*\n)#?\s*LoadModule\s+[^\n]+\n|s)[0];                # the '()=' trick forces list context and the scalar                # assignment counts the number of list members (aka number                # of matches) then                my $cntopen = () = ($before =~ m|^\s*<[^/].*$|mg);                my $cntclose = () = ($before =~ m|^\s*</.*$|mg);                if ($cntopen == $cntclose) {                    # fine. Last LoadModule is contextless.                    $content =~ s|^(.*\n#?\s*LoadModule\s+[^\n]+\n)|$1$c$lmd\n|s;                }                elsif ($cntopen < $cntclose) {                    error('Configuration file is not valid. There are sections'                          . ' closed before opened.');                    exit(1);                }                else {                    # put our cmd after the section containing the last                    # LoadModule.                    my $found =                    $content =~ s!\A (               # string and capture start                                  (?:(?:                                    ^\s*             # start of conf line with a                                    (?:[^<]|<[^/])   # directive which does not                                                     # start with '</'                                    .*(?:$)\n        # rest of the line.                                                     # the '$' is in parentheses                                                     # to avoid misinterpreting                                                     # the string "$\" as                                                     # perl variable.                                    )*               # catch as much as possible                                                     # of such lines. (including                                                     # zero)                                    ^\s*</.*(?:$)\n? # after the above, we                                                     # expect a config line with                                                     # a closing container (</)                                  ) {$cntopen}       # the whole pattern (bunch                                                     # of lines that end up with                                                     # a closing directive) must                                                     # be repeated $cntopen                                                     # times. That's it.                                                     # Simple, eh? ;-)                                  )                  # capture end                                 !$1$c$lmd\n!mx;                    unless ($found) {                        error('Configuration file is not valid. There are '                              . 'sections opened and not closed.');                        exit(1);                    }                }            } else {                # replace already existing LoadModule line                $content =~ s|^(.*\n)#?\s*$lmd[^\n]*\n|$1$c$lmd\n|s;            }            $lmd =~ m|LoadModule\s+(.+?)_module.*|;            notice("[$what module `$1' in $CFG_SYSCONFDIR/$CFG_TARGET.conf]");        }        my $amd;        foreach $amd (@amd) {            if ($content !~ m|\n#?\s*$amd|) {                 $content =~ s|^(.*\n#?\s*AddModule\s+[^\n]+\n)|$1$c$amd\n|sg;            } else {                 $content =~ s|^(.*\n)#?\s*$amd[^\n]*\n|$1$c$amd\n|sg;            }        }        if (@lmd or @amd) {            if (open(FP, ">$CFG_SYSCONFDIR/$CFG_TARGET.conf.new")) {                print FP $content;                close(FP);                system("cp $CFG_SYSCONFDIR/$CFG_TARGET.conf $CFG_SYSCONFDIR/$CFG_TARGET.conf.bak && " .                       "cp $CFG_SYSCONFDIR/$CFG_TARGET.conf.new $CFG_SYSCONFDIR/$CFG_TARGET.conf && " .                       "rm $CFG_SYSCONFDIR/$CFG_TARGET.conf.new");            } else {                notice("unable to open configuration file");            }	}    }}sub error{    print STDERR "apxs:Error: $_[0].\n";}sub notice{    print STDERR "$_[0]\n";}##EOF##__DATA__####  Makefile -- Build procedure for sample %NAME% Apache module##  Autogenerated via ``apxs -n %NAME% -g''.##builddir=.top_srcdir=%PREFIX%top_builddir=%PREFIX%include %INSTALLBUILDDIR%/special.mk#   the used toolsAPXS=apxsAPACHECTL=apachectl#   additional defines, includes and libraries#DEFS=-Dmy_define=my_value#INCLUDES=-Imy/include/dir#LIBS=-Lmy/lib/dir -lmylib#   the default targetall: local-shared-build#   install the shared object file into Apache install: install-modules#   cleanupclean:	-rm -f mod_%NAME%.o mod_%NAME%.lo mod_%NAME%.slo mod_%NAME%.la #   simple testtest: reload	lynx -mime_header http://localhost/%NAME%#   install and activate shared object by reloading Apache to#   force a reload of the shared object filereload: install restart#   the general Apache start/restart/stop#   proceduresstart:	$(APACHECTL) startrestart:	$(APACHECTL) restartstop:	$(APACHECTL) stop-=#=-mod_%NAME%.la: mod_%NAME%.slo	$(SH_LINK) -rpath $(libexecdir) -module -avoid-version  mod_%NAME%.loDISTCLEAN_TARGETS = modules.mkshared =  mod_%NAME%.la-=#=-/* **  mod_%NAME%.c -- Apache sample %NAME% module**  [Autogenerated via ``apxs -n %NAME% -g'']****  To play with this sample module first compile it into a**  DSO file and install it into Apache's modules directory **  by running:****    $ apxs -c -i mod_%NAME%.c****  Then activate it in Apache's %TARGET%.conf file for instance**  for the URL /%NAME% in as follows:****    #   %TARGET%.conf**    LoadModule %NAME%_module modules/mod_%NAME%.so**    <Location /%NAME%>**    SetHandler %NAME%**    </Location>****  Then after restarting Apache via****    $ apachectl restart****  you immediately can request the URL /%NAME% and watch for the**  output of this module. This can be achieved for instance via:****    $ lynx -mime_header http://localhost/%NAME% ****  The output should be similar to the following one:****    HTTP/1.1 200 OK**    Date: Tue, 31 Mar 1998 14:42:22 GMT**    Server: Apache/1.3.4 (Unix)**    Connection: close**    Content-Type: text/html**  **    The sample page from mod_%NAME%.c*/ #include "httpd.h"#include "http_config.h"#include "http_protocol.h"#include "ap_config.h"/* The sample content handler */static int %NAME%_handler(request_rec *r){    if (strcmp(r->handler, "%NAME%")) {        return DECLINED;    }    r->content_type = "text/html";          if (!r->header_only)        ap_rputs("The sample page from mod_%NAME%.c\n", r);    return OK;}static void %NAME%_register_hooks(apr_pool_t *p){    ap_hook_handler(%NAME%_handler, NULL, NULL, APR_HOOK_MIDDLE);}/* Dispatch list for API hooks */module AP_MODULE_DECLARE_DATA %NAME%_module = {    STANDARD20_MODULE_STUFF,     NULL,                  /* create per-dir    config structures */    NULL,                  /* merge  per-dir    config structures */    NULL,                  /* create per-server config structures */    NULL,                  /* merge  per-server config structures */    NULL,                  /* table of config file commands       */    %NAME%_register_hooks  /* register hooks                      */};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -