[htdig3-dev] patch for config file include statement


Gilles Detillieux (grdetil@scrc.umanitoba.ca)
Thu, 21 Jan 1999 16:50:22 -0600 (CST)


* List: htdig3-dev@sob.htdig.org

Hi everyone. It's always seemed odd to me that htdig's config file didn't
allow you to include other files. This would be really handy for sites
that maintain multiple configs, but want to centralize the common stuff in
one file. So, I've added the feature (to the 011799 source on my system),
and it seems to work like a charm. The patch is below. I know it's past
the feature freeze, but it's a fairly simple addition. (As John Cleese
would say, "it's wah-fer thin.")

--- ./htlib/Configuration.cc.include Sat Jan 16 21:21:20 1999
+++ ./htlib/Configuration.cc Thu Jan 21 15:38:13 1999
@@ -339,6 +339,25 @@
             len--;
           }
 
+ if (mystrcasecmp(name, "include") == 0)
+ {
+ ParsedString ps(value);
+ String str(ps.get(dict));
+ if (str[0] != '/') // Given file name not fully qualified
+ {
+ str = filename; // so strip dir. name from current one
+ len = str.lastIndexOf('/') + 1;
+ if (len > 0)
+ str.chop(str.length() - len);
+ else
+ str = ""; // No slash in current filename
+ str << ps.get(dict);
+ }
+ Read(str.get());
+ line = 0;
+ continue;
+ }
+
         Add(name, value);
         line = 0;
     }

Example:

include: common.conf
search_results_wrapper: ${common_dir}/mywrapper.html

If the given file name is not fully qualified, it's taken relative to the
directory in which the config file that uses the include statement is found.
Variable expansion is permitted in the file name. Multiple includes, and
nested includes are permitted as well.

I was going to document it, but I couldn't decide whether I should describe
it as another attribute, in attrs.html, or just add a note in cf_general.html.
Suggestions? (It's not really an attribute, even though it looks like one,
because it's only allowed in config files, and it's interpreted right away.)

-- 
Gilles R. Detillieux              E-mail: <grdetil@scrc.umanitoba.ca>
Spinal Cord Research Centre       WWW:    http://www.scrc.umanitoba.ca/~grdetil
Dept. Physiology, U. of Manitoba  Phone:  (204)789-3766
Winnipeg, MB  R3E 3J7  (Canada)   Fax:    (204)789-3930
------------------------------------
To unsubscribe from the htdig3-dev mailing list, send a message to
htdig3-dev@htdig.org containing the single word "unsubscribe" in
the SUBJECT of the message.



This archive was generated by hypermail 2.0b3 on Thu Feb 04 1999 - 22:24:20 PST