<div dir="auto">Thanks!</div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 10, 2020 at 3:54 AM Daniel-Constantin Mierla <<a href="mailto:miconda@gmail.com">miconda@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div>
    <p>Hello,</p>
    <p>the default config parsing is "compiling on the fly", is not
      keeping any copy of the entire input in the memory.</p>
    <p>It would be possible to print the execution tree compiled by the
      kamailio config interpreter upon parsing the input, but it is far
      from getting a reusable config file.</p>
    <p>I pushed a commit to add --cfg-print command line paramter that
      does a different mode of parsing, evaluating only include/import
      file directives and ifdef/ifndef conditions. The result is printed
      to stdout.</p>
    <p>If another behaviour is desired, then pull requests are welcome.</p>
    <p>Cheers,<br>
      Daniel<br>
    </p></div><div>
    <div>On 10.11.20 09:52, Henning Westerholt
      wrote:<br>
    </div>
    </div><div><blockquote type="cite"></blockquote></div><div><blockquote type="cite">
      
      
      
      <div>
        <p class="MsoNormal"><span>Hi
            Brandon,<u></u><u></u></span></p>
        <p class="MsoNormal"><span><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB">not having looked that much into it yet, but
            some comments.<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB">Adding the “-C” option is probably the easiest
            part; it is done inside main.c in the existing block for the
            other configuration options.<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB">About dumping the kamailio cfg after its has
            been parsed – the main problem is here probably that the
            internal state from the cfg file parser will be not that
            useful, as it will in another format.<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB">Have a look to the cfg.lex and INCLUDEFILE
            definition if you did not find it already. The actual
            implementation of this one is around line 1357.<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB">Maybe it is a good idea to look into how other
            programs have implemented this.<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB">Cheers,<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB">Henning<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB">-- <u></u>
            <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB">Henning Westerholt –
          </span><span><a href="https://skalatan.de/blog/" target="_blank"><span style="color:#0563c1" lang="EN-GB">https://skalatan.de/blog/</span></a></span><span lang="EN-GB"><u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB">Kamailio services –
          </span><span><a href="https://gilawa.com/" target="_blank"><span style="color:#0563c1" lang="EN-GB">https://gilawa.com</span></a></span><span>
            <span lang="EN-GB"><u></u><u></u></span></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
        <div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
          <p class="MsoNormal" style="margin-left:35.4pt"><b>From:</b>
            sr-dev <a href="mailto:sr-dev-bounces@lists.kamailio.org" target="_blank"><sr-dev-bounces@lists.kamailio.org></a>
            <b>On Behalf Of </b>Brandon Armstead<br>
            <b>Sent:</b> Monday, November 9, 2020 8:43 PM<br>
            <b>To:</b> Kamailio Devel List
            <a href="mailto:sr-dev@lists.sip-router.org" target="_blank"><sr-dev@lists.sip-router.org></a><br>
            <b>Subject:</b> [sr-dev] Simple Feature / Help<u></u><u></u></p>
        </div>
        <p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
        <div>
          <p class="MsoNormal" style="margin-left:35.4pt">Hello all,<u></u><u></u></p>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt">    I'm
              looking to add a -C [filename] flag that will read the
              root kamailio.cfg file and its included files and dump the
              compiled result and exit.<u></u><u></u></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt">i.e.
              kamailio -C /path/to/root/file.cfg<u></u><u></u></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt">[ DUMPS
              COMPILED CONFIGURATION INCLUDING / IMPORTS &
              INCLUSIONS ]<u></u><u></u></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt">Similar to
              nginx -T<u></u><u></u></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt">I attempted
              to research what files are involved and it looks like:<u></u><u></u></p>
          </div>
          <div>
            <p style="margin-right:0cm;margin-bottom:0cm;margin-left:35.4pt;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal"><span style="font-size:8.5pt;font-family:"Menlo",serif;color:black"><u></u> <u></u></span></p>
            <p style="margin-right:0cm;margin-bottom:0cm;margin-left:35.4pt;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal"><span><span style="font-size:8.5pt;font-family:"Menlo",serif;color:black">src/main.c</span></span><span style="font-size:8.5pt;font-family:"Menlo",serif;color:black"><u></u><u></u></span></p>
          </div>
          <div>
            <p style="margin-right:0cm;margin-bottom:0cm;margin-left:35.4pt;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal"><span><span style="font-size:8.5pt;font-family:"Menlo",serif;color:black">src/core/cfg.lex</span></span><span style="font-size:8.5pt;font-family:"Menlo",serif;color:black"><u></u><u></u></span></p>
            <p style="margin-right:0cm;margin-bottom:0cm;margin-left:35.4pt;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal"><span><span style="font-size:8.5pt;font-family:"Menlo",serif;color:black">src/core/lex.yy.c</span></span><span style="font-size:8.5pt;font-family:"Menlo",serif;color:black"><u></u><u></u></span></p>
            <p style="margin-right:0cm;margin-bottom:0cm;margin-left:35.4pt;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal"><span><span style="font-size:8.5pt;font-family:"Menlo",serif;color:black">src/core/cfg.tab.c</span></span><span style="font-size:8.5pt;font-family:"Menlo",serif;color:black"><u></u><u></u></span></p>
            <p style="margin-right:0cm;margin-bottom:0cm;margin-left:35.4pt;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal"><span><span style="font-size:8.5pt;font-family:"Menlo",serif;color:black">src/core/cfg.tab.h</span></span><span style="font-size:8.5pt;font-family:"Menlo",serif;color:black"><u></u><u></u></span></p>
            <p style="margin-right:0cm;margin-bottom:0cm;margin-left:35.4pt;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal"><span style="font-size:8.5pt;font-family:"Menlo",serif;color:black"><u></u> <u></u></span></p>
            <p style="margin-right:0cm;margin-bottom:0cm;margin-left:35.4pt;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal"><span><span style="font-size:8.5pt;font-family:"Menlo",serif;color:black">Problems,
                  I'm having:</span></span><span style="font-size:8.5pt;font-family:"Menlo",serif;color:black"><u></u><u></u></span></p>
            <p style="margin-right:0cm;margin-bottom:0cm;margin-left:35.4pt;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal"><span style="font-size:8.5pt;font-family:"Menlo",serif;color:black"><u></u> <u></u></span></p>
            <p class="MsoNormal" style="margin-left:35.4pt">1) It looks
              like I need to add the -C option similar to the -c option,
              which I've done and it does not recognize the new -C flag.<u></u><u></u></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
          </div>
          <p class="MsoNormal" style="margin-left:35.4pt">2) I'm not
            entirely sure how to access the compiled configuration from
            memory, it looks like yyparse maybe involved in compiling
            the configuration?  sr_push_yy_state seems to do some
            compiling, but how do I access the result from src/main.c ?
            <u></u><u></u></p>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt">Any further
              direction or help with this is appreciated.<u></u><u></u></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt">- Brandon<u></u><u></u></p>
          </div>
        </div>
      </div>
      <br>
      <fieldset></fieldset>
      </blockquote></div><div><blockquote type="cite"><pre>_______________________________________________
Kamailio (SER) - Development Mailing List
<a href="mailto:sr-dev@lists.kamailio.org" target="_blank">sr-dev@lists.kamailio.org</a>
<a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev" target="_blank">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev</a>
</pre></blockquote></div><div><blockquote type="cite">
    </blockquote>
    <pre cols="72">-- 
Daniel-Constantin Mierla -- <a href="http://www.asipto.com" target="_blank">www.asipto.com</a>
<a href="http://www.twitter.com/miconda" target="_blank">www.twitter.com/miconda</a> -- <a href="http://www.linkedin.com/in/miconda" target="_blank">www.linkedin.com/in/miconda</a>
Funding: <a href="https://www.paypal.me/dcmierla" target="_blank">https://www.paypal.me/dcmierla</a></pre>
  </div>

_______________________________________________<br>
Kamailio (SER) - Development Mailing List<br>
<a href="mailto:sr-dev@lists.kamailio.org" target="_blank">sr-dev@lists.kamailio.org</a><br>
<a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev" rel="noreferrer" target="_blank">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev</a><br>
</blockquote></div></div>