While compiling kamailio on CentOS I got the following warning:
route.c: In function 'comp_ip':
route.c:1596: warning: 'he' may be used uninitialized in this function
Regards,
Ovidiu Sas
Module: sip-router
Branch: tirpi/cfg_framework_multivalue
Commit: 675f88e144fdcbe2f776b58e1f890f470e3d4bdb
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=675f88e…
Author: Miklos Tirpak <miklos(a)iptel.org>
Committer: Miklos Tirpak <miklos(a)iptel.org>
Date: Wed Sep 29 13:58:07 2010 +0200
cfg framework: apply the values in the order they are set
Add the value change to the end of the list (within the same group_id)
to make sure that the values are changed in the order they are set in the script.
This is important when the same variable is changed multiple times,
the latest value must be kept in this case.
---
cfg/cfg_struct.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/cfg/cfg_struct.c b/cfg/cfg_struct.c
index 10d8ef7..358e4eb 100644
--- a/cfg/cfg_struct.c
+++ b/cfg/cfg_struct.c
@@ -948,7 +948,7 @@ int new_add_var(str *group_name, unsigned int group_id, str *var_name,
/* order the list by group_id, it will be easier to count the group instances */
for( add_var_p = &group->add_var;
- *add_var_p && ((*add_var_p)->group_id < group_id);
+ *add_var_p && ((*add_var_p)->group_id <= group_id);
add_var_p = &((*add_var_p)->next));
add_var->next = *add_var_p;
Module: sip-router
Branch: tirpi/cfg_framework_multivalue
Commit: 9235f7d58df3ec883d4749de3b37bd493bc9bde2
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=9235f7d…
Author: Miklos Tirpak <miklos(a)iptel.org>
Committer: Miklos Tirpak <miklos(a)iptel.org>
Date: Wed Sep 29 16:40:30 2010 +0200
cfg framework: group instance support in the script
Variables within group instances can be set from the script,
for example:
tm[2].reparse_invite = 0;
tm[2].default_reason = "New reason";
Any assignmnet within a group instance creates the entire instance if
it does not exist yet.
Note: does not work with core variables yet.
---
cfg.y | 10 ++++++++++
cfg/cfg.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
cfg/cfg.h | 19 +++++++++++++++++++
3 files changed, 79 insertions(+), 0 deletions(-)
diff --git a/cfg.y b/cfg.y
index d98372d..c43792b 100644
--- a/cfg.y
+++ b/cfg.y
@@ -1632,6 +1632,16 @@ cfg_var:
| cfg_var_id DOT cfg_var_id EQUAL error {
yyerror("number or string expected");
}
+ | cfg_var_id LBRACK NUMBER RBRACK DOT cfg_var_id EQUAL NUMBER {
+ if (cfg_ginst_var_int($1, $3, $6, $8)) {
+ yyerror("variable cannot be added to the group instance");
+ }
+ }
+ | cfg_var_id LBRACK NUMBER RBRACK DOT cfg_var_id EQUAL STRING {
+ if (cfg_ginst_var_string($1, $3, $6, $8)) {
+ yyerror("variable cannot be added to the group instance");
+ }
+ }
;
module_stm:
diff --git a/cfg/cfg.c b/cfg/cfg.c
index 88a34b2..2d0f640 100644
--- a/cfg/cfg.c
+++ b/cfg/cfg.c
@@ -227,6 +227,56 @@ int cfg_declare_str(char *group_name, char *var_name, char *val, char *descr)
return 0;
}
+/* Add a varibale to a group instance with integer type.
+ * The group instance is created if it does not exist.
+ * wrapper function for new_add_var()
+ */
+int cfg_ginst_var_int(char *group_name, unsigned int group_id, char *var_name,
+ int val)
+{
+ str gname, vname;
+
+ gname.s = group_name;
+ gname.len = strlen(group_name);
+ vname.s = var_name;
+ vname.len = strlen(var_name);
+
+ return new_add_var(&gname, group_id, &vname,
+ (void *)(long)val, CFG_VAR_INT);
+}
+
+/* Add a varibale to a group instance with string type.
+ * The group instance is created if it does not exist.
+ * wrapper function for new_add_var()
+ */
+int cfg_ginst_var_string(char *group_name, unsigned int group_id, char *var_name,
+ char *val)
+{
+ str gname, vname;
+
+ gname.s = group_name;
+ gname.len = strlen(group_name);
+ vname.s = var_name;
+ vname.len = strlen(var_name);
+
+ return new_add_var(&gname, group_id, &vname,
+ (void *)val, CFG_VAR_STRING);
+}
+
+/* Create a new group instance.
+ * wrapper function for new_add_var()
+ */
+int cfg_new_ginst(char *group_name, unsigned int group_id)
+{
+ str gname;
+
+ gname.s = group_name;
+ gname.len = strlen(group_name);
+
+ return new_add_var(&gname, group_id, NULL /* var */,
+ NULL /* val */, 0 /* type */);
+}
+
/* returns the handle of a cfg group */
void **cfg_get_handle(char *gname)
{
diff --git a/cfg/cfg.h b/cfg/cfg.h
index 8691805..b196d26 100644
--- a/cfg/cfg.h
+++ b/cfg/cfg.h
@@ -87,6 +87,25 @@ int cfg_declare_int(char *group_name, char *var_name,
/* declares a single variable with str type */
int cfg_declare_str(char *group_name, char *var_name, char *val, char *descr);
+/* Add a varibale to a group instance with integer type.
+ * The group instance is created if it does not exist.
+ * wrapper function for new_add_var()
+ */
+int cfg_ginst_var_int(char *group_name, unsigned int group_id, char *var_name,
+ int val);
+
+/* Add a varibale to a group instance with string type.
+ * The group instance is created if it does not exist.
+ * wrapper function for new_add_var()
+ */
+int cfg_ginst_var_string(char *group_name, unsigned int group_id, char *var_name,
+ char *val);
+
+/* Create a new group instance.
+ * wrapper function for new_add_var()
+ */
+int cfg_new_ginst(char *group_name, unsigned int group_id);
+
/* returns the handle of a cfg group */
void **cfg_get_handle(char *gname);