<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<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 class="moz-cite-prefix">On 10.11.20 09:52, Henning Westerholt
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:AM0PR05MB6595CE7A252C889B2CF28174C5E90@AM0PR05MB6595.eurprd05.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 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:Menlo;
panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
p.gmail-p1, li.gmail-p1, div.gmail-p1
{mso-style-name:gmail-p1;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.gmail-s1
{mso-style-name:gmail-s1;}
span.E-MailFormatvorlage20
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
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"><span style="mso-fareast-language:EN-US">Hi
Brandon,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"
lang="EN-GB">not having looked that much into it yet, but
some comments.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"
lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"
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.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"
lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"
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.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"
lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"
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.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"
lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"
lang="EN-GB">Maybe it is a good idea to look into how other
programs have implemented this.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"
lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"
lang="EN-GB">Cheers,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"
lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"
lang="EN-GB">Henning<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"
lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"
lang="EN-GB">-- <o:p>
</o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"
lang="EN-GB">Henning Westerholt –
</span><span style="mso-fareast-language:EN-US"><a
href="https://skalatan.de/blog/" moz-do-not-send="true"><span
style="color:#0563C1" lang="EN-GB">https://skalatan.de/blog/</span></a></span><span
style="mso-fareast-language:EN-US" lang="EN-GB"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"
lang="EN-GB">Kamailio services –
</span><span style="mso-fareast-language:EN-US"><a
href="https://gilawa.com/" moz-do-not-send="true"><span
style="color:#0563C1" lang="EN-GB">https://gilawa.com</span></a></span><span
style="mso-fareast-language:EN-US">
<span lang="EN-GB"><o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"
lang="EN-GB"><o:p> </o:p></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 class="moz-txt-link-rfc2396E" href="mailto:sr-dev-bounces@lists.kamailio.org"><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 class="moz-txt-link-rfc2396E" href="mailto:sr-dev@lists.sip-router.org"><sr-dev@lists.sip-router.org></a><br>
<b>Subject:</b> [sr-dev] Simple Feature / Help<o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">Hello all,<o:p></o:p></p>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></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.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">i.e.
kamailio -C /path/to/root/file.cfg<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">[ DUMPS
COMPILED CONFIGURATION INCLUDING / IMPORTS &
INCLUSIONS ]<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">Similar to
nginx -T<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">I attempted
to research what files are involved and it looks like:<o:p></o:p></p>
</div>
<div>
<p class="gmail-p1"
style="mso-margin-top-alt:0cm;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"><o:p> </o:p></span></p>
<p class="gmail-p1"
style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:0cm;margin-left:35.4pt;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal"><span
class="gmail-s1"><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"><o:p></o:p></span></p>
</div>
<div>
<p class="gmail-p1"
style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:0cm;margin-left:35.4pt;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal"><span
class="gmail-s1"><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"><o:p></o:p></span></p>
<p class="gmail-p1"
style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:0cm;margin-left:35.4pt;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal"><span
class="gmail-s1"><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"><o:p></o:p></span></p>
<p class="gmail-p1"
style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:0cm;margin-left:35.4pt;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal"><span
class="gmail-s1"><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"><o:p></o:p></span></p>
<p class="gmail-p1"
style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:0cm;margin-left:35.4pt;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal"><span
class="gmail-s1"><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"><o:p></o:p></span></p>
<p class="gmail-p1"
style="mso-margin-top-alt:0cm;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"><o:p> </o:p></span></p>
<p class="gmail-p1"
style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:0cm;margin-left:35.4pt;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal"><span
class="gmail-s1"><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"><o:p></o:p></span></p>
<p class="gmail-p1"
style="mso-margin-top-alt:0cm;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"><o:p> </o:p></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.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></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 ?
<o:p></o:p></p>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">Any further
direction or help with this is appreciated.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">- Brandon<o:p></o:p></p>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
Kamailio (SER) - Development Mailing List
<a class="moz-txt-link-abbreviated" href="mailto:sr-dev@lists.kamailio.org">sr-dev@lists.kamailio.org</a>
<a class="moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev</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>
Funding: <a class="moz-txt-link-freetext" href="https://www.paypal.me/dcmierla">https://www.paypal.me/dcmierla</a></pre>
</body>
</html>