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@lists.kamailio.org> On Behalf Of Brandon Armstead
Sent: Monday, November 9, 2020 8:43 PM
To: Kamailio Devel List <sr-dev@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