<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#ffffff" text="#000000">
Hello,<br>
<br>
just to let you know about some new features related to config
preprocessing. 3.0 added config preprocessor directives such as
'include_file' and 'define'. But the define could be used only to
control which parts of config file are active.<br>
<br>
Several days ago I committed the code to allow you 'define' values for
IDs, like:<br>
<br>
#!define MYINT 123
<br>
#!define MYSTR "xyz"<br>
<br>
The defined IDs are replaced at startup, during config parsing, e.g.,:
<br>
<br>
$var(x) = 100 + MYINT;
<br>
<br>
- is read as:
<br>
<br>
$var(x) = 100 + 123;<br>
<br>
Moreover, you can have multi-line defined IDs:<br>
<br>
#!define IDLOOP&nbsp;&nbsp;&nbsp;&nbsp; $var(i) = 0; \
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while($var(i)&lt;5) { \
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlog("++++ $var(i)\n"); \
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $var(i) = $var(i) + 1; \
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
<br>
<br>
- then in routing block
<br>
<br>
route {
<br>
&nbsp;&nbsp;&nbsp; ...
<br>
&nbsp;&nbsp;&nbsp; IDLOOP
<br>
&nbsp;&nbsp;&nbsp; ...
<br>
}
<br>
<br>
A completely new thing is the substitution preprocessor directive:<br>
<br>
#!subst "<i class="moz-txt-slash"><span class="moz-txt-tag">/</span>regexp/subst<span
 class="moz-txt-tag">/</span></i>"<br>
<br>
Defined IDs are not replaced within string values (because a cfg IDs is
a standalone alphanumeric token, not enclosed in single or double
quotes), so if you need to change something inside a string within
config file, then use substitution. For example, if you want to replace
the password in all db_url module parameters:<br>
<br>
#!subst "<i class="moz-txt-slash"><span class="moz-txt-tag">/</span>DBPASSWD/xyz<span
 class="moz-txt-tag">/</span></i>"<br>
<br>
modparam("acc", "db_url", "mysql://user:DBPASSWD@localhost/db")
<br>
modparam("auth_db", "db_url", "mysql://user:DBPASSWD@localhost/db")
<br>
<br>
The value of a 'subst' directive can be any valid perl-like
substitution expression, you can use wildcards, group tokens,
backreferences, ....<br>
<br>
Hope this will make your cfg scripting easier. Testing and feedback is
appreciated.<br>
<br>
Cheers,<br>
Daniel <br>
<pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla
* <a class="moz-txt-link-freetext" href="http://www.asipto.com/">http://www.asipto.com/</a>
* <a class="moz-txt-link-freetext" href="http://twitter.com/miconda">http://twitter.com/miconda</a>
* <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/danielconstantinmierla">http://www.linkedin.com/in/danielconstantinmierla</a> 
</pre>
</body>
</html>