You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl-cvs@perl.apache.org by do...@hyperreal.org on 1999/05/20 02:22:13 UTC
cvs commit: modperl/t/conf httpd.conf.pl
dougm 99/05/19 17:22:13
Modified: . Changes ToDo
src/modules/perl perl_config.c
t/conf httpd.conf.pl
Log:
added proper support for {Location,Directory,Files}Match in <Perl> sections
Revision Changes Path
1.296 +2 -0 modperl/Changes
Index: Changes
===================================================================
RCS file: /export/home/cvs/modperl/Changes,v
retrieving revision 1.295
retrieving revision 1.296
diff -u -r1.295 -r1.296
--- Changes 1999/05/19 19:42:57 1.295
+++ Changes 1999/05/20 00:22:10 1.296
@@ -8,6 +8,8 @@
=item 1.19_01-dev
+added proper support for {Location,Directory,Files}Match in <Perl> sections
+
new Apache::ExtUtils::pm function to generate Foo.pm/Makefile.PL
templates for modules with directive handlers
1.181 +0 -2 modperl/ToDo
Index: ToDo
===================================================================
RCS file: /export/home/cvs/modperl/ToDo,v
retrieving revision 1.180
retrieving revision 1.181
diff -u -r1.180 -r1.181
--- ToDo 1999/05/18 22:07:56 1.180
+++ ToDo 1999/05/20 00:22:11 1.181
@@ -11,8 +11,6 @@
- modules/file + -T
-- <Perl> patch for *Match from Craig Lien <li...@rrnet.com>
-
- Apache::Include->virtual should return run() value, not status()
- win32 socket bug (WSAStartup() needed for each thread?)
1.71 +48 -14 modperl/src/modules/perl/perl_config.c
Index: perl_config.c
===================================================================
RCS file: /export/home/cvs/modperl/src/modules/perl/perl_config.c,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- perl_config.c 1999/05/17 19:08:19 1.70
+++ perl_config.c 1999/05/20 00:22:12 1.71
@@ -1087,6 +1087,14 @@
perl_set_config_vectors(cmd, cfg, &core_module);
}
+#ifdef WIN32
+#define USE_ICASE REG_ICASE
+#else
+#define USE_ICASE 0
+#endif
+
+#define SECTION_NAME(n) (cmd->info ? (char *)cmd->info : n)
+
#define TRACE_SECTION(n,v) \
MP_TRACE_s(fprintf(stderr, "perl_section: <%s %s>\n", n, v))
@@ -1153,6 +1161,9 @@
dSEC;
int old_overrides = cmd->override;
char *old_path = cmd->path;
+#ifdef PERL_TRACE
+ char *sname = SECTION_NAME("Location");
+#endif
dSECiter_start
@@ -1170,12 +1181,15 @@
cmd->path = pstrdup(cmd->pool, getword_conf (cmd->pool, &key));
cmd->override = OR_ALL|ACCESS_CONF;
- if (!strcmp(cmd->path, "~")) {
+ if (cmd->info) { /* <LocationMatch> */
+ r = pregcomp(cmd->pool, cmd->path, REG_EXTENDED);
+ }
+ else if (!strcmp(cmd->path, "~")) {
cmd->path = getword_conf (cmd->pool, &key);
r = pregcomp(cmd->pool, cmd->path, REG_EXTENDED);
}
- TRACE_SECTION("Location", cmd->path);
+ TRACE_SECTION(sname, cmd->path);
perl_section_hash_walk(cmd, new_url_conf, tab);
@@ -1191,7 +1205,7 @@
cmd->path = old_path;
cmd->override = old_overrides;
- TRACE_SECTION_END("Location");
+ TRACE_SECTION_END(sname);
return NULL;
}
@@ -1200,6 +1214,9 @@
dSEC;
int old_overrides = cmd->override;
char *old_path = cmd->path;
+#ifdef PERL_TRACE
+ char *sname = SECTION_NAME("Directory");
+#endif
dSECiter_start
@@ -1221,12 +1238,15 @@
#endif
cmd->override = OR_ALL|ACCESS_CONF;
- if (!strcmp(cmd->path, "~")) {
+ if (cmd->info) { /* <DirectoryMatch> */
+ r = pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);
+ }
+ else if (!strcmp(cmd->path, "~")) {
cmd->path = getword_conf (cmd->pool, &key);
r = pregcomp(cmd->pool, cmd->path, REG_EXTENDED);
}
- TRACE_SECTION("Directory", cmd->path);
+ TRACE_SECTION(sname, cmd->path);
perl_section_hash_walk(cmd, new_dir_conf, tab);
@@ -1239,7 +1259,7 @@
cmd->path = old_path;
cmd->override = old_overrides;
- TRACE_SECTION_END("Directory");
+ TRACE_SECTION_END(sname);
return NULL;
}
@@ -1256,6 +1276,9 @@
dSEC;
int old_overrides = cmd->override;
char *old_path = cmd->path;
+#ifdef PERL_TRACE
+ char *sname = SECTION_NAME("Files");
+#endif
dSECiter_start
@@ -1274,7 +1297,10 @@
if (!old_path)
cmd->override = OR_ALL|ACCESS_CONF;
- if (!strcmp(cmd->path, "~")) {
+ if (cmd->info) { /* <FilesMatch> */
+ r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);
+ }
+ else if (!strcmp(cmd->path, "~")) {
cmd->path = getword_conf (cmd->pool, &key);
if (old_path && cmd->path[0] != '/' && cmd->path[0] != '^')
cmd->path = pstrcat(cmd->pool, "^", old_path, cmd->path, NULL);
@@ -1283,7 +1309,7 @@
else if (old_path && cmd->path[0] != '/')
cmd->path = pstrcat(cmd->pool, old_path, cmd->path, NULL);
- TRACE_SECTION("Files", cmd->path);
+ TRACE_SECTION(sname, cmd->path);
perl_section_hash_walk(cmd, new_file_conf, tab);
@@ -1297,7 +1323,7 @@
add_file_conf((core_dir_config *)dummy, new_file_conf);
dSECiter_stop
- TRACE_SECTION_END("Files");
+ TRACE_SECTION_END(sname);
cmd->path = old_path;
cmd->override = old_overrides;
@@ -1349,16 +1375,24 @@
{
/* Emulate the handing of the begin token of the section */
void *dummy = perl_set_config_vectors(cmd, config, &core_module);
- if(strEQ(key, "Location"))
+ void *old_info = cmd->info;
+
+ if (strstr(key, "Match")) {
+ cmd->info = (void*)key;
+ }
+
+ if(strnEQ(key, "Location", 8))
perl_urlsection(cmd, dummy, hv);
- else if(strEQ(key, "Directory"))
+ else if(strnEQ(key, "Directory", 9))
perl_dirsection(cmd, dummy, hv);
else if(strEQ(key, "VirtualHost"))
perl_virtualhost_section(cmd, dummy, hv);
- else if(strEQ(key, "Files"))
+ else if(strnEQ(key, "Files", 5))
perl_filesection(cmd, (core_dir_config *)dummy, hv);
else if(strEQ(key, "Limit"))
perl_limit_section(cmd, dummy, hv);
+
+ cmd->info = old_info;
}
void perl_handle_command_av(AV *av, I32 n, char *key, cmd_parms *cmd, void *config)
@@ -1462,7 +1496,7 @@
MP_TRACE_s(fprintf(stderr,
"bootstrapping <Perl> sections: arg=%s, keys=%d\n",
- arg, SvIV(nk)));
+ arg, (int)SvIV(nk)));
perl_sections_boot_module = arg;
perl_sections_self_boot = 1;
@@ -1616,7 +1650,7 @@
MP_TRACE_s(fprintf(stderr,
"`@%s' directive is %s, (%d elements)\n",
- key, splain_args(c->args_how), AvFILL(av)+1));
+ key, splain_args(c->args_how), (int)AvFILL(av)+1));
switch (c->args_how) {
1.24 +24 -1 modperl/t/conf/httpd.conf.pl
Index: httpd.conf.pl
===================================================================
RCS file: /export/home/cvs/modperl/t/conf/httpd.conf.pl,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- httpd.conf.pl 1998/11/19 04:33:37 1.23
+++ httpd.conf.pl 1999/05/20 00:22:13 1.24
@@ -156,9 +156,32 @@
};
}
-$Location{"/cgi-bin"} = {
+$LocationMatch{"/(cgi|slow)-bin"} = {
SetHandler => "cgi-script",
Options => "ExecCGI",
+};
+
+sub My::Files::handler {
+ my $r = shift;
+ $r->send_http_header('text/plain');
+ printf "%s pulled out of thin air at %s",
+ $r->filename, scalar localtime $r->request_time;
+}
+
+sub My::Directory::handler {
+ my $r = shift;
+ $r->send_http_header('text/plain');
+ printf "%s says to take a hike", $r->filename =~ m:(\w+)/public:;
+}
+
+$FilesMatch{".(date|time)\$"} = {
+ SetHandler => 'perl-script',
+ PerlHandler => 'My::Files',
+};
+
+$DirectoryMatch{"public_html"} = {
+ SetHandler => 'perl-script',
+ PerlHandler => 'My::Directory',
};
#just make sure we can parse this