<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        font-size:10.0pt;
        font-family:"Courier New";}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;}
span.EmailStyle23
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Thank you :)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">A follow up question would be on the usability of the #!defenv (and probably #!defenvs) usability with #!ifdef.  In the scenario below, if the environmental variable WITH_DEBUGGER is not defined, then Kamailio will fail to start, thus the
 #!ifdef is somewhat limited.  It makes sense for scenarios where someone might toggle the setting editing the config file, but it would be very convenient to toggle the environmental variable instead, particularly in containerized environments.   Any thoughts
 on how best to control this?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">#!defenv WITH_DEBUGGER<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">#!ifdef WITH_DEBUGGER<o:p></o:p></p>
<p class="MsoNormal">loadmodule "debugger"<o:p></o:p></p>
<p class="MsoNormal">. . . <o:p></o:p></p>
<p class="MsoNormal">#!endif<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" style="border-collapse:collapse">
<tbody>
<tr>
<td style="padding:0in 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:12.0pt;color:black">Ben Kaufman</span></b><span style="font-size:12.0pt;color:black"><o:p></o:p></span></p>
</td>
</tr>
<tr style="height:6.0pt">
<td style="padding:0in 0in 0in 0in;height:6.0pt"></td>
</tr>
</tbody>
</table>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> Daniel-Constantin Mierla <miconda@gmail.com> <br>
<b>Sent:</b> Monday, December 6, 2021 3:55 AM<br>
<b>To:</b> Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org>; Ben Kaufman <bkaufman@nexvortex.com><br>
<b>Subject:</b> Re: [SR-Users] Unquoted values from #!defenv<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p>Hello,<o:p></o:p></p>
<p>#!substdef does not set the value inside quoted string, it replaces inside a string value, so it does not put quotes around replacement part. So it does it it is written in the docs. There is #!substdefs witch can create a define with quoted value.<o:p></o:p></p>
<p>Note that defines are standalone-token replacement, you can define an ID to a number, to a keyword (e.g., src_ip), to a quoted string or even a multi-line script snippet, like:<o:p></o:p></p>
<p>#!define IDLOOP $var(i) = 0; \<br>
                while($var(i)<5) { \<br>
                    xlog("++++ $var(i)\n"); \<br>
                    $var(i) = $var(i) + 1; \<br>
                }<o:p></o:p></p>
<p>See the core cookbook for more details.<o:p></o:p></p>
<p>Anyhow, as using env variable values as quoted string is useful and setting them with quotes might look odd, I added #!defenvs:<o:p></o:p></p>
<p>  * <a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.kamailio.org%2Fwiki%2Fcookbooks%2Fdevel%2Fcore%23defenvs&data=04%7C01%7Cbkaufman%40nexvortex.com%7C6028b5b0b93344af8d0308d9b89e8a04%7Cafc1818e7b6848568913201b9396c4fc%7C1%7C0%7C637743813349298668%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000&sdata=Q2j9FAXfUTB2uNwKhu5OeEmQanN7xmMGDYb9JBJw6JY%3D&reserved=0">
https://www.kamailio.org/wiki/cookbooks/devel/core#defenvs</a><o:p></o:p></p>
<p>Cheers,<br>
Daniel<o:p></o:p></p>
<div>
<p class="MsoNormal">On 30.11.21 22:40, Ben Kaufman wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">Hello all,<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">Looking for some clarification regarding quoting and !#defenv .  I understand that the example below fails because the environmental variable HOME is not quoted, thus when used in the xlog() call it fails.  How is it possible to evaluate
 and/or use the value of the environmental variable if defined as a preprocessor variable?  Looking at the documentation the reason for this directive is “<span style="font-size:10.5pt;font-family:"Arial",sans-serif;color:#333333;background:white">It is a simplified
 alternative of using <strong><span style="font-family:"Arial",sans-serif">#!substdef</span></strong> with <strong><span style="font-family:"Arial",sans-serif">$env(NAME)</span></strong> in the replacement part.</span>” But #!substdef would allow setting the
 value inside of a quoted string, so does it really meet that requirement?<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">I’m aware that I could use $env(HOME) rather than a preprocessor directive of HOME.  I’m just trying to understand the usage of the #!defenv feature.<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">#!KAMAILIO</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">## Tested in 5.5.2</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">loadmodule "xlog"</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">loadmodule "pv"</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">loadmodule "evrexec"</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">modparam("evrexec", "exec", "name=evrexec:timer;wait=1000;workers=1;")</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">#!defenv HOME</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">request_route{</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">    forward();</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">}</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">event_route[evrexec:timer] {</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">    xlog("L_N", "HOME: " + HOME + "\n");</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">}</span><o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" style="border-collapse:collapse">
<tbody>
<tr>
<td style="padding:0in 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:12.0pt;color:black">Ben Kaufman</span></b><o:p></o:p></p>
</td>
</tr>
<tr style="height:6.0pt">
<td style="padding:0in 0in 0in 0in;height:6.0pt"></td>
</tr>
</tbody>
</table>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<pre>__________________________________________________________<o:p></o:p></pre>
<pre>Kamailio - Users Mailing List - Non Commercial Discussions<o:p></o:p></pre>
<pre>  * <a href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a><o:p></o:p></pre>
<pre>Important: keep the mailing list in the recipients, do not reply only to the sender!<o:p></o:p></pre>
<pre>Edit mailing list options or unsubscribe:<o:p></o:p></pre>
<pre>  * <a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.kamailio.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fsr-users&data=04%7C01%7Cbkaufman%40nexvortex.com%7C6028b5b0b93344af8d0308d9b89e8a04%7Cafc1818e7b6848568913201b9396c4fc%7C1%7C0%7C637743813349298668%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000&sdata=sg%2Bvyol603800duARWt2cyAY2zyk8b7RwtDdqxQvkVI%3D&reserved=0">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><o:p></o:p></pre>
</blockquote>
<pre>-- <o:p></o:p></pre>
<pre>Daniel-Constantin Mierla -- <a href="https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.asipto.com%2F&data=04%7C01%7Cbkaufman%40nexvortex.com%7C6028b5b0b93344af8d0308d9b89e8a04%7Cafc1818e7b6848568913201b9396c4fc%7C1%7C0%7C637743813349298668%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000&sdata=TSsHgbu0R21zntLh04F9ygSsdMhf2IFMu0gsQH0QdLE%3D&reserved=0">www.asipto.com</a><o:p></o:p></pre>
<pre><a href="https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.twitter.com%2Fmiconda&data=04%7C01%7Cbkaufman%40nexvortex.com%7C6028b5b0b93344af8d0308d9b89e8a04%7Cafc1818e7b6848568913201b9396c4fc%7C1%7C0%7C637743813349298668%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000&sdata=fC7l4GXE37%2FlnU3VEEFYtDfh3Paz7qngOegogfTYPfo%3D&reserved=0">www.twitter.com/miconda</a> -- <a href="https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.linkedin.com%2Fin%2Fmiconda&data=04%7C01%7Cbkaufman%40nexvortex.com%7C6028b5b0b93344af8d0308d9b89e8a04%7Cafc1818e7b6848568913201b9396c4fc%7C1%7C0%7C637743813349298668%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000&sdata=YwgDc3er7OybfRCfku6xVEz9d3JF%2BVI9fm9obQc5JyY%3D&reserved=0">www.linkedin.com/in/miconda</a><o:p></o:p></pre>
<pre>Kamailio Advanced Training - Online<o:p></o:p></pre>
<pre>  Feb 21-24, 2022 (America Timezone)<o:p></o:p></pre>
<pre>  * <a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.asipto.com%2Fsw%2Fkamailio-advanced-training-online%2F&data=04%7C01%7Cbkaufman%40nexvortex.com%7C6028b5b0b93344af8d0308d9b89e8a04%7Cafc1818e7b6848568913201b9396c4fc%7C1%7C0%7C637743813349298668%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000&sdata=%2FEHm83D99ywCJaMbJfzBqFRFMbbIyLd5etfUpLWmTF4%3D&reserved=0">https://www.asipto.com/sw/kamailio-advanced-training-online/</a><o:p></o:p></pre>
</div>
</body>
</html>