Hello,
just committed to GIT support for 'include' in config file. Hopefully this helps in nicer structuring and maintenance of your configs.
The syntax is simple:
include path_to_file
The path_to_file can be relative or absolute. If it is not absolute path, first attempt is to locate it relative to current directory, and if fails, relative to directory of the file that includes it. There is no restriction where include can be used or what can contain - any part of config file is ok. There is a limit of maximum 10 includes in depth, otherwise you can use as many includes as you want. Reporting of the cfg file syntax errors prints now the file name for easier troubleshooting. Example:
route { ... include /sr/checks.cfg ... }
--- /sr/checks.cfg ---
if (!mf_process_maxfwd_header("10")) { sl_send_reply("483","Too Many Hops"); exit; }
---
Testing and feedback is much appreciated.
Cheers, Daniel
2009/8/25 Daniel-Constantin Mierla miconda@gmail.com:
Hello,
just committed to GIT support for 'include' in config file. Hopefully this helps in nicer structuring and maintenance of your configs.
The syntax is simple:
include path_to_file
Really useful !!!
Just a question, how about the logs? The current logs display the line error and so, what would occur if there is a syntax error in an included file?
On 25.08.2009 20:21 Uhr, Iñaki Baz Castillo wrote:
2009/8/25 Daniel-Constantin Mierla miconda@gmail.com:
Hello,
just committed to GIT support for 'include' in config file. Hopefully this helps in nicer structuring and maintenance of your configs.
The syntax is simple:
include path_to_file
Really useful !!!
good.
Just a question, how about the logs? The current logs display the line error and so, what would occur if there is a syntax error in an included file?
yes, line is printed in kamailio 1.5.x, I am working to get line and file printed in SR for fixup and runtime errors - right now only log of syntax errors does this.
Cheers, Daniel
Great!
...added to wiki .... http://sip-router.org/wiki/cookbooks/core-cookbook/devel#include
klaus
Daniel-Constantin Mierla wrote:
Hello,
just committed to GIT support for 'include' in config file. Hopefully this helps in nicer structuring and maintenance of your configs.
The syntax is simple:
include path_to_file
The path_to_file can be relative or absolute. If it is not absolute path, first attempt is to locate it relative to current directory, and if fails, relative to directory of the file that includes it. There is no restriction where include can be used or what can contain - any part of config file is ok. There is a limit of maximum 10 includes in depth, otherwise you can use as many includes as you want. Reporting of the cfg file syntax errors prints now the file name for easier troubleshooting. Example:
route { ... include /sr/checks.cfg ... }
--- /sr/checks.cfg ---
if (!mf_process_maxfwd_header("10")) { sl_send_reply("483","Too Many Hops"); exit; }
Testing and feedback is much appreciated.
Cheers, Daniel
On 26.08.2009 1:51 Uhr, Klaus Darilion wrote:
Great!
...added to wiki .... http://sip-router.org/wiki/cookbooks/core-cookbook/devel#include
thanks, I was wondering if this really belongs to parameters section, since it can be used in route blocks as well. Maybe a new section is better -- not sure how to name it now.
Cheers, Daniel
klaus
Daniel-Constantin Mierla wrote:
Hello,
just committed to GIT support for 'include' in config file. Hopefully this helps in nicer structuring and maintenance of your configs.
The syntax is simple:
include path_to_file
The path_to_file can be relative or absolute. If it is not absolute path, first attempt is to locate it relative to current directory, and if fails, relative to directory of the file that includes it. There is no restriction where include can be used or what can contain
- any part of config file is ok. There is a limit of maximum 10
includes in depth, otherwise you can use as many includes as you want. Reporting of the cfg file syntax errors prints now the file name for easier troubleshooting. Example:
route { ... include /sr/checks.cfg ... }
--- /sr/checks.cfg ---
if (!mf_process_maxfwd_header("10")) { sl_send_reply("483","Too Many Hops"); exit; }
Testing and feedback is much appreciated.
Cheers, Daniel
sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
26 aug 2009 kl. 09.47 skrev Daniel-Constantin Mierla:
On 26.08.2009 1:51 Uhr, Klaus Darilion wrote:
Great!
...added to wiki .... http://sip-router.org/wiki/cookbooks/core-cookbook/devel#include
thanks, I was wondering if this really belongs to parameters section, since it can be used in route blocks as well. Maybe a new section is better -- not sure how to name it now.
It is important to mark such a construct as a configuration engine option, we've learned in Asterisk where we have two of them. One is #include that includes a file, another one is #exec that runs a script and takes stdout and includes that. Both of them are valid in all configuration files, parsed before the app gets the configuration data.
If you don't mark it a separate option, people will misunderstand it. Especially in Asterisk where we have both "#include" and "include=>" in the dialplan, which wasn't very clever choice of names looking at it from hindsight.
/O
On 26.08.2009 11:25 Uhr, Olle E. Johansson wrote:
26 aug 2009 kl. 09.47 skrev Daniel-Constantin Mierla:
On 26.08.2009 1:51 Uhr, Klaus Darilion wrote:
Great!
...added to wiki .... http://sip-router.org/wiki/cookbooks/core-cookbook/devel#include
thanks, I was wondering if this really belongs to parameters section, since it can be used in route blocks as well. Maybe a new section is better -- not sure how to name it now.
It is important to mark such a construct as a configuration engine option, we've learned in Asterisk where we have two of them. One is #include that includes a file, another one is #exec that runs a script and takes stdout and includes that. Both of them are valid in all configuration files, parsed before the app gets the configuration data.
If you don't mark it a separate option, people will misunderstand it. Especially in Asterisk where we have both "#include" and "include=>" in the dialplan, which wasn't very clever choice of names looking at it from hindsight.
was an option to get the c style, but in K/S the '#' marks beginning of a comment, so I sticked more or less to php version. Other chars like $, @... are used for some classes of variables... changing it is very simple, just need something which does not add confusion.
Cheers, Daniel
2009/8/26 Daniel-Constantin Mierla miconda@gmail.com:
was an option to get the c style, but in K/S the '#' marks beginning of a comment, so I sticked more or less to php version. Other chars like $, @... are used for some classes of variables...
changing it is very simple, just need something which does not add confusion.
include_file PATH_TO_FILE
:)
Iñaki Baz Castillo schrieb:
2009/8/26 Daniel-Constantin Mierla miconda@gmail.com:
was an option to get the c style, but in K/S the '#' marks beginning of a comment, so I sticked more or less to php version. Other chars like $, @... are used for some classes of variables...
changing it is very simple, just need something which does not add confusion.
include_file PATH_TO_FILE
+1
26 aug 2009 kl. 10.49 skrev Klaus Darilion:
Iñaki Baz Castillo schrieb:
2009/8/26 Daniel-Constantin Mierla miconda@gmail.com:
was an option to get the c style, but in K/S the '#' marks beginning of a comment, so I sticked more or less to php version. Other chars like $, @... are used for some classes of variables... changing it is very simple, just need something which does not add confusion.
include_file PATH_TO_FILE
+1
++1
/O
To understand that people prefer "include_file" over "include"? Shall we wait more opinions or update now since it is early stage...
Cheers, Daniel
On 26.08.2009 11:56 Uhr, Olle E. Johansson wrote:
26 aug 2009 kl. 10.49 skrev Klaus Darilion:
Iñaki Baz Castillo schrieb:
2009/8/26 Daniel-Constantin Mierla miconda@gmail.com:
was an option to get the c style, but in K/S the '#' marks beginning of a comment, so I sticked more or less to php version. Other chars like $, @... are used for some classes of variables... changing it is very simple, just need something which does not add confusion.
include_file PATH_TO_FILE
+1
++1
/O _______________________________________________ sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
2009/8/26 Daniel-Constantin Mierla miconda@gmail.com:
To understand that people prefer "include_file" over "include"? Shall we wait more opinions or update now since it is early stage...
include what? => include file
:)
Imagine in a future you want to extend it as Asterisk #exec. It could be called "include_script" :)
The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it.
From: sr-dev-bounces@lists.sip-router.org [mailto:sr-dev-bounces@lists.sip-router.org] On Behalf Of Daniel-Constantin Mierla Sent: Wednesday, August 26, 2009 6:30 AM To: Olle E. Johansson Cc: sr-dev Subject: Re: [sr-dev] [SR-Users] support for 'include' in cfg file
To understand that people prefer "include_file" over "include"? Shall we wait more opinions or update now since it is early stage...
Cheers, Daniel
+1 for include_file, for the reasons already stated by Olle.
- Brad
On Wed, Aug 26, 2009 at 9:47 AM, Daniel-Constantin Mierlamiconda@gmail.com wrote:
On 26.08.2009 1:51 Uhr, Klaus Darilion wrote:
Great!
...added to wiki .... http://sip-router.org/wiki/cookbooks/core-cookbook/devel#include
thanks, I was wondering if this really belongs to parameters section, since it can be used in route blocks as well. Maybe a new section is better -- not sure how to name it now.
Maybe we should have a section about general config file syntax, such as comments, identifiers, reserved keywords, included files. This directive would then fit in nicely.
By the way, wouldn't it make more sense to require that the filename is enclosed between a pair of quotes? Unix filenames may contain pretty much anything except '/' and that could result in all kinds of strange errors when not quoted. Also it would be consistend with loadmodule and loadpath.
Jan.
Cheers, Daniel
klaus
Daniel-Constantin Mierla wrote:
Hello,
just committed to GIT support for 'include' in config file. Hopefully this helps in nicer structuring and maintenance of your configs.
The syntax is simple:
include path_to_file
The path_to_file can be relative or absolute. If it is not absolute path, first attempt is to locate it relative to current directory, and if fails, relative to directory of the file that includes it. There is no restriction where include can be used or what can contain - any part of config file is ok. There is a limit of maximum 10 includes in depth, otherwise you can use as many includes as you want. Reporting of the cfg file syntax errors prints now the file name for easier troubleshooting. Example:
route { ... include /sr/checks.cfg ... }
--- /sr/checks.cfg ---
if (!mf_process_maxfwd_header("10")) { sl_send_reply("483","Too Many Hops"); exit; }
Testing and feedback is much appreciated.
Cheers, Daniel
sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
On 26.08.2009 11:44 Uhr, Jan Janak wrote:
On Wed, Aug 26, 2009 at 9:47 AM, Daniel-Constantin Mierlamiconda@gmail.com wrote:
On 26.08.2009 1:51 Uhr, Klaus Darilion wrote:
Great!
...added to wiki .... http://sip-router.org/wiki/cookbooks/core-cookbook/devel#include
thanks, I was wondering if this really belongs to parameters section, since it can be used in route blocks as well. Maybe a new section is better -- not sure how to name it now.
Maybe we should have a section about general config file syntax, such as comments, identifiers, reserved keywords, included files. This directive would then fit in nicely.
By the way, wouldn't it make more sense to require that the filename is enclosed between a pair of quotes? Unix filenames may contain pretty much anything except '/' and that could result in all kinds of strange errors when not quoted. Also it would be consistend with loadmodule and loadpath.
yes, enclosing in quotes would be recommended. Shall we force all the time the double quotes?
Cheers, Daniel
klaus
Daniel-Constantin Mierla wrote:
Hello,
just committed to GIT support for 'include' in config file. Hopefully this helps in nicer structuring and maintenance of your configs.
The syntax is simple:
include path_to_file
The path_to_file can be relative or absolute. If it is not absolute path, first attempt is to locate it relative to current directory, and if fails, relative to directory of the file that includes it. There is no restriction where include can be used or what can contain - any part of config file is ok. There is a limit of maximum 10 includes in depth, otherwise you can use as many includes as you want. Reporting of the cfg file syntax errors prints now the file name for easier troubleshooting. Example:
route { ... include /sr/checks.cfg ... }
--- /sr/checks.cfg ---
if (!mf_process_maxfwd_header("10")) { sl_send_reply("483","Too Many Hops"); exit; }
Testing and feedback is much appreciated.
Cheers, Daniel
sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
On Wed, Aug 26, 2009 at 10:55 AM, Daniel-Constantin Mierlamiconda@gmail.com wrote:
On 26.08.2009 11:44 Uhr, Jan Janak wrote:
On Wed, Aug 26, 2009 at 9:47 AM, Daniel-Constantin Mierlamiconda@gmail.com wrote:
On 26.08.2009 1:51 Uhr, Klaus Darilion wrote:
Great!
...added to wiki .... http://sip-router.org/wiki/cookbooks/core-cookbook/devel#include
thanks, I was wondering if this really belongs to parameters section, since it can be used in route blocks as well. Maybe a new section is better -- not sure how to name it now.
Maybe we should have a section about general config file syntax, such as comments, identifiers, reserved keywords, included files. This directive would then fit in nicely.
By the way, wouldn't it make more sense to require that the filename is enclosed between a pair of quotes? Unix filenames may contain pretty much anything except '/' and that could result in all kinds of strange errors when not quoted. Also it would be consistend with loadmodule and loadpath.
yes, enclosing in quotes would be recommended. Shall we force all the time the double quotes?
Yes, please. That way it would be obvious that what the include directive expects is a string and not an expression to be evaluated.
thanks, Jan.
26 aug 2009 kl. 11.03 skrev Jan Janak:
On Wed, Aug 26, 2009 at 10:55 AM, Daniel-Constantin Mierlamiconda@gmail.com wrote:
On 26.08.2009 11:44 Uhr, Jan Janak wrote:
On Wed, Aug 26, 2009 at 9:47 AM, Daniel-Constantin Mierlamiconda@gmail.com wrote:
On 26.08.2009 1:51 Uhr, Klaus Darilion wrote:
Great!
...added to wiki .... http://sip-router.org/wiki/cookbooks/core-cookbook/devel#include
thanks, I was wondering if this really belongs to parameters section, since it can be used in route blocks as well. Maybe a new section is better -- not sure how to name it now.
Maybe we should have a section about general config file syntax, such as comments, identifiers, reserved keywords, included files. This directive would then fit in nicely.
By the way, wouldn't it make more sense to require that the filename is enclosed between a pair of quotes? Unix filenames may contain pretty much anything except '/' and that could result in all kinds of strange errors when not quoted. Also it would be consistend with loadmodule and loadpath.
yes, enclosing in quotes would be recommended. Shall we force all the time the double quotes?
Yes, please. That way it would be obvious that what the include directive expects is a string and not an expression to be evaluated.
And just to be very clear in the documentation - "Note that you can't use any type of avp's in this statement as it is processed at startup, not at runtime."
/O
2009/8/26 Olle E. Johansson oej@edvina.net:
And just to be very clear in the documentation - "Note that you can't use any type of avp's in this statement as it is processed at startup, not at runtime."
Sorry, is that true? I understood that the included file text is justinserted in the main config file being parse, no more, so the included file could also contain AVP's and everything. Am I wrong?
On 26.08.2009 12:09 Uhr, Iñaki Baz Castillo wrote:
2009/8/26 Olle E. Johansson oej@edvina.net:
And just to be very clear in the documentation - "Note that you can't use any type of avp's in this statement as it is processed at startup, not at runtime."
Sorry, is that true? I understood that the included file text is justinserted in the main config file being parse,
Yes, kind of. One cfg tree is built from the content of all files.
no more, so the included file could also contain AVP's and everything.
Yes, can contain anything that is valid in at the position of include directive.
Am I wrong?
Probably Olle meant that you cannot do: $avp(x) = "my_file"; include $avp(x)
Cheers, Daniel
2009/8/26 Daniel-Constantin Mierla miconda@gmail.com:
Am I wrong?
Probably Olle meant that you cannot do: $avp(x) = "my_file"; include $avp(x)
ahhh ok
On 26.08.2009 12:03 Uhr, Jan Janak wrote:
On Wed, Aug 26, 2009 at 10:55 AM, Daniel-Constantin Mierlamiconda@gmail.com wrote:
On 26.08.2009 11:44 Uhr, Jan Janak wrote:
On Wed, Aug 26, 2009 at 9:47 AM, Daniel-Constantin Mierlamiconda@gmail.com wrote:
On 26.08.2009 1:51 Uhr, Klaus Darilion wrote:
Great!
...added to wiki .... http://sip-router.org/wiki/cookbooks/core-cookbook/devel#include
thanks, I was wondering if this really belongs to parameters section, since it can be used in route blocks as well. Maybe a new section is better -- not sure how to name it now.
Maybe we should have a section about general config file syntax, such as comments, identifiers, reserved keywords, included files. This directive would then fit in nicely.
By the way, wouldn't it make more sense to require that the filename is enclosed between a pair of quotes? Unix filenames may contain pretty much anything except '/' and that could result in all kinds of strange errors when not quoted. Also it would be consistend with loadmodule and loadpath.
yes, enclosing in quotes would be recommended. Shall we force all the time the double quotes?
Yes, please. That way it would be obvious that what the include directive expects is a string and not an expression to be evaluated.
done. Just that it cannot be a string like elsewhere in the config for now. Expanding grammar to support hex, octet representation of chars, whitespace, etc. is a bit more complex to implement in order to cope with comments on the same line after the include. But I have it in mind for future.
Cheers, Daniel
Hello,
note: following most of opinions expressed on devel list regarding the directive name (to be more suggestive about what it does), "include" has been replaced with "include_file". See: http://sip-router.org/wiki/cookbooks/core-cookbook/devel#include_file
Cheers, Daniel
On 25.08.2009 20:15 Uhr, Daniel-Constantin Mierla wrote:
Hello,
just committed to GIT support for 'include' in config file. Hopefully this helps in nicer structuring and maintenance of your configs.
The syntax is simple:
include path_to_file
The path_to_file can be relative or absolute. If it is not absolute path, first attempt is to locate it relative to current directory, and if fails, relative to directory of the file that includes it. There is no restriction where include can be used or what can contain - any part of config file is ok. There is a limit of maximum 10 includes in depth, otherwise you can use as many includes as you want. Reporting of the cfg file syntax errors prints now the file name for easier troubleshooting. Example:
route { ... include /sr/checks.cfg ... }
--- /sr/checks.cfg ---
if (!mf_process_maxfwd_header("10")) { sl_send_reply("483","Too Many Hops"); exit; }
Testing and feedback is much appreciated.
Cheers, Daniel