[sr-dev] Simple Feature / Help

Brandon Armstead brandon at cryy.com
Tue Nov 10 16:19:42 CET 2020


Thanks!

On Tue, Nov 10, 2020 at 3:54 AM Daniel-Constantin Mierla <miconda at gmail.com>
wrote:

> Hello,
>
> the default config parsing is "compiling on the fly", is not keeping any
> copy of the entire input in the memory.
>
> 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.
>
> 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.
>
> If another behaviour is desired, then pull requests are welcome.
>
> Cheers,
> Daniel
> On 10.11.20 09:52, Henning Westerholt wrote:
>
> Hi Brandon,
>
>
>
> not having looked that much into it yet, but some comments.
>
>
>
> Adding the “-C” option is probably the easiest part; it is done inside
> main.c in the existing block for the other configuration options.
>
>
>
> 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.
>
>
>
> 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.
>
>
>
> Maybe it is a good idea to look into how other programs have implemented
> this.
>
>
>
> Cheers,
>
>
>
> Henning
>
>
>
> --
>
> Henning Westerholt – https://skalatan.de/blog/
>
> Kamailio services – https://gilawa.com
>
>
>
> *From:* sr-dev <sr-dev-bounces at lists.kamailio.org>
> <sr-dev-bounces at lists.kamailio.org> *On Behalf Of *Brandon Armstead
> *Sent:* Monday, November 9, 2020 8:43 PM
> *To:* Kamailio Devel List <sr-dev at lists.sip-router.org>
> <sr-dev at lists.sip-router.org>
> *Subject:* [sr-dev] Simple Feature / Help
>
>
>
> Hello all,
>
>
>
>     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.
>
>
>
> i.e. kamailio -C /path/to/root/file.cfg
>
>
>
> [ DUMPS COMPILED CONFIGURATION INCLUDING / IMPORTS & INCLUSIONS ]
>
>
>
> Similar to nginx -T
>
>
>
> I attempted to research what files are involved and it looks like:
>
>
>
> src/main.c
>
> src/core/cfg.lex
>
> src/core/lex.yy.c
>
> src/core/cfg.tab.c
>
> src/core/cfg.tab.h
>
>
>
> Problems, I'm having:
>
>
>
> 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.
>
>
>
> 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 ?
>
>
>
> Any further direction or help with this is appreciated.
>
>
>
> - Brandon
>
> _______________________________________________
> Kamailio (SER) - Development Mailing Listsr-dev at lists.kamailio.orghttps://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
>
> --
> Daniel-Constantin Mierla -- www.asipto.comwww.twitter.com/miconda -- www.linkedin.com/in/miconda
> Funding: https://www.paypal.me/dcmierla
>
> _______________________________________________
> Kamailio (SER) - Development Mailing List
> sr-dev at lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20201110/84c4bf22/attachment-0001.htm>


More information about the sr-dev mailing list