Here's a 3.2.x patch. It makes the server block configuration matching
more flexible. Instead of the host name having to exactly match the
name specified in the server block, a less-qualified server name can
be specified, and all host names under this will match. For example,
a <server: foo.net> block would match hosts foo.net, www.foo.net,
store.foo.net
and www.store.foo.net. However, it won't try to match just 'net', so
a <server: net> block will have no effect (but a <server: co.nz> block
would).
====================================
--- htdig/htcommon/HtConfiguration.cc Thu May 17 04:36:44 2001
+++ htdig-patched/htcommon/HtConfiguration.cc Thu Oct 11 17:11:21 2001
@@ -57,47 +57,97 @@ HtConfiguration::Add(const char *name, c
}
//*********************************************************************
-const String HtConfiguration::Find(const char *blockName,const char
*name,const char *value) const
+const String
+HtConfiguration::Find(const char *blockName,const char *name,const char
*value) const
{
- if (!(blockName && name && value) )
- return String();
- union {
- void *ptr;
- Object *obj;
- Dictionary *dict;
- HtConfiguration *conf;
- } tmpPtr;
- String chr;
-
- if (strcmp("url",blockName)==0) { // URL needs special compare
- URL paramUrl(name); // split URL to compare separatly host and
path
- chr=Find(¶mUrl,value);
- if (chr[0]!=0) {
- return chr;
+ if (!(blockName && name && value) )
+ return String();
+ union {
+ void *ptr;
+ Object *obj;
+ Dictionary *dict;
+ HtConfiguration *conf;
+ } tmpPtr;
+ String chr;
+
+ if (strcmp("url",blockName)==0) { // URL needs special compare
+ URL paramUrl(name); // split URL to compare separatly host
and path
+ chr=Find(¶mUrl,value);
+ if (chr[0]!=0) {
+ return chr;
+ }
}
+ else if (strcmp("server", blockName)==0) {
+ tmpPtr.obj=dcBlocks.Find(blockName);
+ if (tmpPtr.ptr)
+ {
+ // look to see if 'name' matches exactly with something in
the config
+ tmpPtr.obj = tmpPtr.dict->Find(name);
+ if (tmpPtr.ptr)
+ {
+ chr = tmpPtr.conf->Find(value);
+ if (chr[0] != 0)
+ return chr;
+ }
+ else
+ // if it doesn't, and if 'name' contains two or more dots,
like www.htdig.org
+ // remove the first part of the domain (to something like
htdig.org)
+ // and see if that matches a config file entry
+ // but don't file down the name if there is only one dot, we
don't want
+ // 'foo.com' to reduce to 'com'
+ {
+ String tmp_host( name );
+ int first_dot_pos = 0, second_dot_pos = 0;
+
+ while( 1 )
+ {
+ first_dot_pos = tmp_host.indexOf( '.' );
+ if ( first_dot_pos != -1 )
+ {
+ second_dot_pos = tmp_host.indexOf( '.',
first_dot_pos+1 );
+ if ( second_dot_pos != -1 )
+ {
+ tmp_host = tmp_host.sub( first_dot_pos + 1 );
+
+ tmpPtr.obj=dcBlocks.Find(blockName);
+ tmpPtr.obj = tmpPtr.dict->Find(
tmp_host.get() );
+ if (tmpPtr.ptr) {
+ chr = tmpPtr.conf->Find(value);
+ if (chr[0] != 0)
+ return chr;
+ }
+ }
+ else // one dot
+ break;
+ }
+ else // no dots
+ break;
+ }
+ }
+ }
}
- else { // end "server"
- tmpPtr.obj=dcBlocks.Find(blockName);
- if (tmpPtr.ptr) {
- tmpPtr.obj = tmpPtr.dict->Find(name);
- if (tmpPtr.ptr) {
- chr = tmpPtr.conf->Find(value);
- if (chr[0] != 0)
- return chr;
- }
- }
+ else { // neither URL or server
+ tmpPtr.obj=dcBlocks.Find(blockName);
+ if (tmpPtr.ptr) {
+ tmpPtr.obj = tmpPtr.dict->Find(name);
+ if (tmpPtr.ptr) {
+ chr = tmpPtr.conf->Find(value);
+ if (chr[0] != 0)
+ return chr;
+ }
+ }
+ }
+
+ // If this parameter is defined in global then return it
+ chr=Find(value);
+ if (chr[0]!=0) {
+ return chr;
}
-
- // If this parameter is defined in global then return it
- chr=Find(value);
- if (chr[0]!=0) {
- return chr;
- }
#ifdef DEBUG
- cerr << "Could not find configuration option " << blockName<<":"
- <<name<<":"<<value<< "\n";
+ cerr << "Could not find configuration option " << blockName<<":"
+ <<name<<":"<<value<< "\n";
#endif
- return String();
+ return String();
}
//*********************************************************************
====================================
Jamie Anstice
Search Engineer
S.L.I. Systems
[EMAIL PROTECTED]
ph: 64 961 3262
mobile: 64 21 264 9347
_______________________________________________
htdig-general mailing list <[EMAIL PROTECTED]>
To unsubscribe, send a message to <[EMAIL PROTECTED]> with a
subject of unsubscribe
FAQ: http://htdig.sourceforge.net/FAQ.html