Module: sip-router
Branch: master
Commit: ec898038f34decb415e3adb696f2c0ff2ab007ed
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=ec89803…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Tue Feb 17 19:13:11 2009 +0100
Kamailio to sip-router module conversion script.
This is a simple script which attempts to convert modules that use kamalio
core to sip-router core.
Signed-off-by: Jan Janak <jan(a)iptel.org>
---
scripts/kam_to_sr.sh | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 107 insertions(+), 0 deletions(-)
diff --git a/scripts/kam_to_sr.sh b/scripts/kam_to_sr.sh
new file mode 100755
index 0000000..330ee07
--- /dev/null
+++ b/scripts/kam_to_sr.sh
@@ -0,0 +1,107 @@
+#!/usr/bin/env sh
+#
+# This is a simple script which attempts to convert kamailio modules so that
+# they can be used with the sip-router core. Most of the changes done by the
+# script deal with the changes in the database abstraction layer in the
+# sip-router source tree.
+#
+# Run this script in module directory to convert it from kamailio core to
+# sip-router core. The root of the tree should be two levels up, otherwise
+# relative paths to headers (../..) would not work and the module will not
+# compile.
+#
+# Some of the changes done by the script:
+#
+# * Extra defines in the Makefile to make the module link with libsrdb1
+# * Path to database headers updated to point to lib/srdb1
+# * db_con_t and db_res_t renamed to db1_con_t and db1_res_t in *.[ch]
+# * Value type names such as DB_INT changed to DB1_INT in *.[ch]
+#
+# NOTE: There is no guarantee that the update module would compile or even
+# work. Make a backup before running the script. You have been warned!
+#
+# Written by Jan Janak <jan(a)iptel.org>
+#
+
+if [ ! -f Makefile ] ; then
+ echo "ERROR: Could not find module Makefile"
+ echo " Run this file in the module directory"
+ exit 1
+fi
+
+if ! egrep "Makefile\.modules" Makefile >/dev/null ; then
+ echo "ERROR: Doesn't look like a module..."
+ exit 1
+fi
+
+if ! egrep '^#[ \t]*include[ \t]*".*\/db\/db(_(cap|id|key|op|pool|query|res|row|ut|val))?\.h[ \t]*"' *.[ch] >/dev/null ; then
+ echo "The module does not seem to include old database headers..."
+ exit 0
+fi
+
+echo -n "Updating Makefile..."
+cp Makefile Makefile.backup
+cat Makefile.backup | gawk '
+BEGIN {
+ serlibpath_seen = 0
+ libs_seen = 0
+ defs_seen = 0
+}
+
+# If the define already exists then skip it, this ensures that
+# we do not add the same line more than once.
+/^[ \t]*DEFS[ \t]*\+?=.*OPENSER_MOD_INTERFACE/ {
+ defs_seen = 1
+}
+
+/^[ \t]*SER_LIBS[ \t]*\+?=.*srdb1\/srdb1/ {
+ libs_seen = 1
+}
+
+/^[ \t]*SERLIBPATH[ \t]*=/ {
+ serlibpath_seen = 1
+}
+
+# Write everything just before the line including Makefile.modules,
+# this is most likely the last line in the Makefile
+/^[ \t]*include[ \t]+.*\/Makefile\.modules[ \t]*$/ {
+ if (serlibpath_seen == 0) print "SERLIBPATH=../../lib"
+ if (defs_seen == 0) print "DEFS+=-DOPENSER_MOD_INTERFACE"
+ if (libs_seen == 0) print "SER_LIBS+=$(SERLIBPATH)/srdb1/srdb1"
+}
+
+{ print $0 }
+
+' > Makefile
+echo "done."
+
+for file in *.[ch] ; do
+ echo -n "Updating file $file..."
+ cp $file $file.backup
+ cat $file.backup | gawk '
+
+/^#[ \t]*include[ \t]*".*\/db\/db(_(cap|id|key|op|pool|query|res|row|ut|val))?\.h[ \t]*"/ {
+ sub("/db/", "/lib/srdb1/", $0);
+}
+
+/[^a-zA-Z0-9_](db_(con|res)_t|struct[ \t]+db_(con|res))[^a-zA-Z0-9_]/ {
+ gsub("struct[ \t]+db_con", "struct db1_con", $0);
+ gsub("struct[ \t]+db_res", "struct db1_res", $0);
+ gsub("db_con_t", "db1_con_t", $0);
+ gsub("db_res_t", "db1_res_t", $0);
+}
+
+/[^a-zA-Z0-9_]DB_((BIG)?INT|DOUBLE|STR(ING)?|DATETIME|BLOB|BITMAP)[^a-zA-Z0-9_]/ {
+ gsub("DB_INT", "DB1_INT", $0);
+ gsub("DB_BIGINT", "DB1_BIGINT", $0);
+ gsub("DB_DOUBLE", "DB1_DOUBLE", $0);
+ gsub("DB_STR", "DB1_STR", $0);
+ gsub("DB_DATETIME", "DB1_DATETIME", $0);
+ gsub("DB_BLOB", "DB1_BLOB", $0);
+ gsub("DB_BITMAP", "DB1_BITMAP", $0);
+}
+
+{ print $0 }
+' >$file
+ echo "done."
+done
Module: sip-router
Branch: master
Commit: beb252b7d97cba59830a321b0a4c8981c35ca0c8
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=beb252b…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Tue Feb 17 19:15:16 2009 +0100
SER to sip-router module conversion script.
This is a simple script which attempts to convert modules that use ser core to
sip-router core.
Signed-off-by: Jan Janak <jan(a)iptel.org>
---
scripts/ser_to_sr.sh | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 107 insertions(+), 0 deletions(-)
diff --git a/scripts/ser_to_sr.sh b/scripts/ser_to_sr.sh
new file mode 100755
index 0000000..6826426
--- /dev/null
+++ b/scripts/ser_to_sr.sh
@@ -0,0 +1,107 @@
+#!/usr/bin/env sh
+#
+# This is a simple script which attempts to convert ser modules so that they
+# can be used with the sip-router core. Most of the changes done by the script
+# deal with the changes in the database abstraction layer in the sip-router
+# source tree.
+#
+# Run this script in module directory to convert it from ser core to
+# sip-router core. The root of the tree should be two levels up, otherwise
+# relative paths to headers (../..) would not work and the module will not
+# compile.
+#
+# Some of the changes done by the script:
+#
+# * Extra defines in the Makefile to make the module link with libsrdb2
+# * Path to database headers updated to point to lib/srdb2
+# * Database flag names renamed from DB_* to SRDB_*
+# (DB_DISABLED -> SRDB_DISABLED)
+#
+# NOTE: There is no guarantee that the update module would compile or even
+# work. Make a backup before running the script. You have been warned!
+#
+# Written by Jan Janak <jan(a)iptel.org>
+#
+
+if [ ! -f Makefile ] ; then
+ echo "ERROR: Could not find module Makefile"
+ echo " Run this file in the module directory"
+ exit 1
+fi
+
+if ! egrep "Makefile\.modules" Makefile >/dev/null ; then
+ echo "ERROR: Doesn't look like a module..."
+ exit 1
+fi
+
+if ! egrep '^#[ \t]*include[ \t]*".*\/db\/db(_(cmd|con|ctx|drv|fld|gen|pool|rec|res|uri))?\.h[ \t]*"' *.[ch] >/dev/null ; then
+ echo "The module does not seem to include old database headers..."
+ exit 0
+fi
+
+echo -n "Updating Makefile..."
+cp Makefile Makefile.backup
+cat Makefile.backup | gawk '
+BEGIN {
+ serlibpath_seen = 0
+ libs_seen = 0
+ defs_seen = 0
+}
+
+# If the define already exists then skip it, this ensures that
+# we do not add the same line more than once.
+/^[ \t]*DEFS[ \t]*\+?=.*SER_MOD_INTERFACE/ {
+ defs_seen = 1
+}
+
+/^[ \t]*SER_LIBS[ \t]*\+?=.*srdb2\/srdb2/ {
+ libs_seen = 1
+}
+
+/^[ \t]*SERLIBPATH[ \t]*=/ {
+ serlibpath_seen = 1
+}
+
+# Write everything just before the line including Makefile.modules,
+# this is most likely the last line in the Makefile
+/^[ \t]*include[ \t]+.*\/Makefile\.modules[ \t]*$/ {
+ if (serlibpath_seen == 0) print "SERLIBPATH=../../lib"
+ if (defs_seen == 0) print "DEFS+=-DSER_MOD_INTERFACE"
+ if (libs_seen == 0) print "SER_LIBS+=$(SERLIBPATH)/srdb2/srdb2"
+}
+
+{ print $0 }
+
+' > Makefile
+echo "done."
+
+for file in *.[ch] ; do
+ echo -n "Updating file $file..."
+ cp $file $file.backup
+ cat $file.backup | gawk '
+
+/^#[ \t]*include[ \t]*".*\/db\/db(_(cmd|con|ctx|drv|fld|gen|pool|rec|res|uri))?\.h[ \t]*"/ {
+ sub("/db/", "/lib/srdb2/", $0);
+}
+
+/[^a-zA-Z0-9_]DB_(LOAD_SER|DISABLED|CANON|IS_(TO|FROM)|FOR_SERWEB|PENDING|((CALLER|CALLEE)_)?DELETED|MULTIVALUE|FILL_ON_REG|REQUIRED|DIR)[^a-zA-Z0-9_]/ {
+ gsub("DB_LOAD_SER", "SRDB_LOAD_SER", $0);
+ gsub("DB_DISABLED", "SRDB_DISABLED", $0);
+ gsub("DB_CANON", "SRDB_CANON", $0);
+ gsub("DB_IS_TO", "SRDB_IS_TO", $0);
+ gsub("DB_IS_FROM", "SRDB_IS_FROM", $0);
+ gsub("DB_FOR_SERWEB", "SRDB_FOR_SERWEB", $0);
+ gsub("DB_PENDING", "SRDB_PENDING", $0);
+ gsub("DB_DELETED", "SRDB_DELETED", $0);
+ gsub("DB_CALLER_DELETED", "SRDB_CALLER_DELETED", $0);
+ gsub("DB_CALLEE_DELETED", "SRDB_CALLEE_DELETED", $0);
+ gsub("DB_MULTIVALUE", "SRDB_MULTIVALUE", $0);
+ gsub("DB_FILL_ON_REG", "SRDB_FILL_ON_REG", $0);
+ gsub("DB_REQUIRED", "SRDB_REQUIRED", $0);
+ gsub("DB_DIR", "SRDB_DIR", $0);
+}
+
+{ print $0 }
+' >$file
+ echo "done."
+done
Hi all,
the minutes for todays IRC meeting are now available in our wiki [1].
Among the discussed topics we decided about a date for the upcoming 1.5.0
release, this is scheduled for the 2th march 2009. The first release that
will use the new common sip-router core [2] is scheduled for May. After 1.5.0
we will also do a bug fix release (1.4.4) for our latest stable branch.
All dates can be found in our wiki as well at [3].
Cheers,
Henning
[1]http://www.kamailio.org/dokuwiki/doku.php/development:irc-meeting-minutes…
[2]http://sip-router.org/benefits/
[3]http://www.kamailio.org/dokuwiki/doku.php/development:release-policy#date…
--
Henning Westerholt - Development Consumer Products / DSL Core
1&1 Internet AG, Ernst-Frey-Str. 9, 76135 Karlsruhe, Germany
Module: sip-router
Branch: master
Commit: 2ba94ce0218a7e7ac0d849c0a9089dc57a59334b
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=2ba94ce…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Tue Feb 17 14:46:42 2009 +0100
Support for db driver names with "db_" prefix in libsrdb2.
This patch adds support for database driver names with "db_" prefix. We
adopted this kamailio convention for sip-router and all database driver
modules will have names starting with "db_", for example, the mysql
database driver will be named "db_mysql".
When searching for a database driver for database "foo", libsrdb2 will
first try to search for a module named "db_foo". If no such module can
be found then the library repeats the search for a module named just
"foo".
Signed-off-by: Jan Janak <jan(a)iptel.org>
---
lib/srdb2/db_drv.c | 42 ++++++++++++++++++++++++++++--------------
1 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/lib/srdb2/db_drv.c b/lib/srdb2/db_drv.c
index 52ae539..0cfcec8 100644
--- a/lib/srdb2/db_drv.c
+++ b/lib/srdb2/db_drv.c
@@ -62,28 +62,42 @@ void db_drv_free(db_drv_t* ptr)
*/
int db_drv_func(db_drv_func_t* func, str* module, char* func_name)
{
- char* buf;
-
- buf = pkg_malloc(module->len + 1);
- if (buf == NULL) {
+ static str prefix = STR_STATIC_INIT("db_");
+ char* buf = NULL, *name;
+
+ if ((buf = pkg_malloc(prefix.len + module->len + 1)) == NULL) {
LOG(L_ERR, "db_drv_func: No memory left\n");
- return -1;
+ goto error;
}
- memcpy(buf, module->s, module->len);
- buf[module->len] = '\0';
-
- if (find_module_by_name(buf) == 0) {
- ERR("db_drv_func: database driver for '%s' not found\n", buf);
- pkg_free(buf);
- return -1;
+
+ memcpy(buf, prefix.s, prefix.len);
+ memcpy(buf + prefix.len, module->s, module->len);
+ buf[prefix.len + module->len] = '\0';
+
+ /* First try to find the module with prefix "db_" */
+ name = buf;
+ if (find_module_by_name(name) == 0) {
+ /* Not found, so try without the prefix */
+ name = buf + prefix.len;
+ if (find_module_by_name(name) == 0) {
+ ERR("db_drv_func: database driver for '%.*s' not found\n", STR_FMT(module));
+ goto error;
+ }
}
- *func = (db_drv_func_t)find_mod_export(buf, func_name, 0, 0);
- pkg_free(buf);
+
+ *func = (db_drv_func_t)find_mod_export(name, func_name, 0, 0);
+
+ if (buf) pkg_free(buf);
if (*func) return 0;
else return 1;
+
+error:
+ if (buf) pkg_free(buf);
+ return -1;
}
+
/*
* Call function with name <func_name> in DB driver <module>, give
* it pointer <db_struct> as the pointer to the corresponding DB structure