### Description
Add runtime flag -C [filename] which takes the given file name and dumps its compiled configuration (including include and import files)
### Expected behavior Dump complete configuration after inclusions to terminal / stdout and exit.
#### Actual observed behavior Flag does not exist
#### Debugging Data N/A
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
version: kamailio 5.5.0-dev3 (x86_64/linux) 76bb9b flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB poll method support: poll, epoll_lt, epoll_et, sigio_rt, select. id: 76bb9b compiled on 02:45:06 Oct 24 2020 with gcc 8.3.0
Just added `--cfg-print` that should do what you were looking for, to the extent of evaluating `include_file/import_file` and `ifdef/ifndef` conditions.
It does not replace the tokens defined with `define`, `subst` or the other token defining variants. If someone needs to go further into this, then a pull request is more than welcome.
Basic tests were done with default config file and an imported file. If there are issues, open a bug report.
As a side note, to be aware of, the empty lines are kept, so the output may have sequences of several empty lines, if the `#!ifdef ... #!endif` blocks had empty lines before and after.
Closed #2546.
Very important - for now the `--cfg-print` works if the main configuration file has the first line:
``` #!KAMAILIO ```
Daniel-Constantin Mierla writes:
Very important - for now the `--cfg-print` works if the main configuration file has the first line:
#!KAMAILIO
Can there be other stuff on the line after #!KAMAILIO?
For example emacs can be told about the major mode used in the file by checking if first non-blank line contains -*-<something>-*-.
So I would like the definition go like this:
`--cfg-print` works if the main configuration file starts with
#!KAMAILIO
-- Juha
On 10.11.20 13:16, Juha Heinanen wrote:
Daniel-Constantin Mierla writes:
Very important - for now the `--cfg-print` works if the main configuration file has the first line: #!KAMAILIO
Can there be other stuff on the line after #!KAMAILIO?
The parsing state is switched to printing config on matching #!KAMAILIO (and I just added the other variants #!SER, #!ALL, ...), which is expected to be in the first line. What is before, it is not printed (but actually parsed as usual).
I didn't want to mess very much the INITIAL state parsing, because any token defined in cfg.lex can theoretically be in the first line, so will make it too complex by adding conditions to each of them to check if --cfg-print is on or not.
The other variant is to try to start in another state, then on first char switch to INITIAL or CFGPRINTMODE, but I didn't have the time to dig into it, I went on easy way trying not to break anything.
So for now, if someone doesn't want the #!KAMAILIO (or the other variants) in the first line, can add it temporarily only when it uses the --cfg-print, then remove it. Of course, if someone wants to look more into it, is more than welcome to make pull requests.
Cheers, Daniel
For example emacs can be told about the major mode used in the file by checking if first non-blank line contains -*-<something>-*-.
So I would like the definition go like this:
`--cfg-print` works if the main configuration file starts with
#!KAMAILIO
Daniel-Constantin Mierla writes:
So for now, if someone doesn't want the #!KAMAILIO (or the other variants) in the first line, can add it temporarily only when it uses the --cfg-print, then remove it. Of course, if someone wants to look more into it, is more than welcome to make pull requests.
It is OK to have that in the first line, but my question was, can there be something else on the first line after #!KAMAILIO? So is the test
first_line == "#!KAMAILIO"
or
starts_with(first_line, "#!KAMAILIO")
?
-- juha
I gave --cfg-print a try. I have this in config:
loadmodule "tls" ... # -- tls params #!ifdef MOD_tls modparam("tls", "config", "/etc/sip-proxy/tls.cfg") modparam("tls", "cipher_list", "HIGH:!ADH:!AECDH") #!endif
# -- tm params
and --cfg-print gave this kind of output:
loadmodule "tls" ... # -- tls params
# -- tm params
Since tls module is loaded I would have expected tls modparams to show up in the output.
-- Juha
On 10.11.20 15:16, Juha Heinanen wrote:
I gave --cfg-print a try. I have this in config:
loadmodule "tls" ... # -- tls params #!ifdef MOD_tls modparam("tls", "config", "/etc/sip-proxy/tls.cfg") modparam("tls", "cipher_list", "HIGH:!ADH:!AECDH") #!endif
# -- tm params
and --cfg-print gave this kind of output:
loadmodule "tls" ... # -- tls params
# -- tm params
Since tls module is loaded I would have expected tls modparams to show up in the output.
It is not aware of the defines pushed from the C code, only those from command line (e.g., -A) or config file. Maybe these ones related to loadmodule can be caught in the lex parser, but the others pushed from the c code after effectively loading the module are not easy to do unless the flex parsing approach is changed. I am not planning to go myself that way, but I am open to contributions.
Cheers, Daniel
On 10.11.20 14:52, Juha Heinanen wrote:
Daniel-Constantin Mierla writes:
So for now, if someone doesn't want the #!KAMAILIO (or the other variants) in the first line, can add it temporarily only when it uses the --cfg-print, then remove it. Of course, if someone wants to look more into it, is more than welcome to make pull requests.
It is OK to have that in the first line, but my question was, can there be something else on the first line after #!KAMAILIO? So is the test
first_line == "#!KAMAILIO"
or
starts_with(first_line, "#!KAMAILIO")
?
Flex does token based parsing -- I haven't tried it, but it should work even if it is something before or after it. More constraints can be added, e.g., to be at the beginning of the line, or the only content in the line, but currently the cfg.lex doesn't have any.
Cheers, Daniel
Thank you!
On Tue, Nov 10, 2020 at 3:42 AM Daniel-Constantin Mierla < notifications@github.com> wrote:
Closed #2546 https://github.com/kamailio/kamailio/issues/2546.
— You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub https://github.com/kamailio/kamailio/issues/2546#event-3978479083, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP5VMSQG7LFFXUBH3OF4E4TSPERLJANCNFSM4TPZPM5A .
I've confirmed this is working as expected, thanks again!