<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hello,</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.</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:</p>
    <p>#!define IDLOOP $var(i) = 0; \<br>
                      while($var(i)<5) { \<br>
                          xlog("++++ $var(i)\n"); \<br>
                          $var(i) = $var(i) + 1; \<br>
                      }</p>
    <p>See the core cookbook for more details.</p>
    <p>Anyhow, as using env variable values as quoted string is useful
      and setting them with quotes might look odd, I added #!defenvs:</p>
    <p>  * <a class="moz-txt-link-freetext" href="https://www.kamailio.org/wiki/cookbooks/devel/core#defenvs">https://www.kamailio.org/wiki/cookbooks/devel/core#defenvs</a></p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <div class="moz-cite-prefix">On 30.11.21 22:40, Ben Kaufman wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:DM4PR11MB5407C3294AA9B07D2672FF34DD679@DM4PR11MB5407.namprd11.prod.outlook.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style>@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;}p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}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]-->
      <div class="WordSection1">
        <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<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:10.0pt;font-family:"Courier New"">##
            Tested in 5.5.2<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:10.0pt;font-family:"Courier New"">loadmodule
            "xlog"<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:10.0pt;font-family:"Courier New"">loadmodule
            "pv"<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:10.0pt;font-family:"Courier New"">loadmodule
            "evrexec"<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:10.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:10.0pt;font-family:"Courier New"">modparam("evrexec",
            "exec", "name=evrexec:timer;wait=1000;workers=1;")<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:10.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:10.0pt;font-family:"Courier New"">#!defenv
            HOME<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:10.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:10.0pt;font-family:"Courier New"">request_route{<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:10.0pt;font-family:"Courier New"">   
            forward();<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:10.0pt;font-family:"Courier New"">}<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:10.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:10.0pt;font-family:"Courier New"">event_route[evrexec:timer]
            {<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:10.0pt;font-family:"Courier New"">   
            xlog("L_N", "HOME: " + HOME + "\n");<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:10.0pt;font-family:"Courier New"">}<o:p></o:p></span></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <table class="MsoNormalTable" style="border-collapse:collapse"
          cellspacing="0" cellpadding="0" border="0">
          <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"><br>
              </td>
            </tr>
          </tbody>
        </table>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
      </div>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre class="moz-quote-pre" wrap="">__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
  * <a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a>
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe:
  * <a class="moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla -- <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
<a class="moz-txt-link-abbreviated" href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a class="moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a>
Kamailio Advanced Training - Online
  Feb 21-24, 2022 (America Timezone)
  * <a class="moz-txt-link-freetext" href="https://www.asipto.com/sw/kamailio-advanced-training-online/">https://www.asipto.com/sw/kamailio-advanced-training-online/</a></pre>
  </body>
</html>