Browse code

kam_to_sr.sh: add a note that this script is now obselete

Henning Westerholt authored on 07/10/2018 07:16:20
Showing 1 changed files
... ...
@@ -1,5 +1,8 @@
1 1
 #!/usr/bin/env sh
2 2
 #
3
+# Note: This script is obselete, especially after the changes in commit
4
+# 1f70d062b0b9cf1e, the module interface unification.
5
+#
3 6
 # This is a simple script which attempts to convert kamailio modules so that
4 7
 # they can be used with the sip-router core. Most of the changes done by the
5 8
 # script deal with the changes in the database abstraction layer in the
Browse code

core: relocated some folders from root and utils to misc

- utils keeps only the applications related to kamailio c code
- the other are now in misc/tools
- utils/misc/vim moved to misc/extra/
- obsolete and scripts folders moved to misc/

Daniel-Constantin Mierla authored on 07/12/2016 11:46:38
Showing 1 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,111 @@
1
+#!/usr/bin/env sh
2
+#
3
+# This is a simple script which attempts to convert kamailio modules so that
4
+# they can be used with the sip-router core. Most of the changes done by the
5
+# script deal with the changes in the database abstraction layer in the
6
+# sip-router source tree. 
7
+#
8
+# Run this script in module directory to convert it from kamailio core to
9
+# sip-router core. The root of the tree should be two levels up, otherwise
10
+# relative paths to headers (../..) would not work and the module will not
11
+# compile.
12
+# 
13
+# Some of the changes done by the script:
14
+#
15
+#  * Extra defines in the Makefile to make the module link with libsrdb1
16
+#  * Path to database headers updated to point to lib/srdb1
17
+#  * db_con_t and db_res_t renamed to db1_con_t and db1_res_t in *.[ch]
18
+#  * Value type names such as DB_INT changed to DB1_INT in *.[ch]
19
+#
20
+# NOTE: There is no guarantee that the update module would compile or even
21
+#       work. Make a backup before running the script. You have been warned!
22
+# 
23
+# Written by Jan Janak <jan@iptel.org>
24
+#
25
+
26
+if [ ! -f Makefile ] ; then
27
+	echo "ERROR: Could not find module Makefile"
28
+	echo "       Run this file in the module directory"
29
+	exit 1
30
+fi
31
+
32
+if ! egrep "Makefile\.modules" Makefile >/dev/null ; then
33
+	echo "ERROR: Doesn't look like a module..."
34
+	exit 1
35
+fi
36
+
37
+if ! egrep '^#[ \t]*include[ \t]*".*\/db\/db(_(cap|con|id|key|op|pool|query|res|row|ut|val))?\.h[ \t]*"' *.[ch] >/dev/null ; then
38
+	echo "The module does not seem to include old database headers..."
39
+	exit 0
40
+fi
41
+
42
+echo -n "Updating Makefile..."
43
+cp Makefile Makefile.backup
44
+cat Makefile.backup | gawk '
45
+BEGIN {
46
+    serlibpath_seen = 0
47
+    libs_seen = 0
48
+    defs_seen = 0
49
+}
50
+
51
+# If the define already exists then skip it, this ensures that
52
+# we do not add the same line more than once.
53
+/^[ \t]*DEFS[ \t]*\+?=.*OPENSER_MOD_INTERFACE/ {
54
+    defs_seen = 1
55
+}
56
+
57
+/^[ \t]*DEFS[ \t]*\+?=.*KAMAILIO_MOD_INTERFACE/ {
58
+    defs_seen = 1
59
+}
60
+
61
+/^[ \t]*SER_LIBS[ \t]*\+?=.*srdb1\/srdb1/ {
62
+    libs_seen = 1
63
+}
64
+
65
+/^[ \t]*SERLIBPATH[ \t]*=/ {
66
+    serlibpath_seen = 1
67
+}
68
+
69
+# Write everything just before the line including Makefile.modules,
70
+# this is most likely the last line in the Makefile
71
+/^[ \t]*include[ \t]+.*\/Makefile\.modules[ \t]*$/ {
72
+    if (serlibpath_seen == 0) print "SERLIBPATH=../../lib"
73
+    if (defs_seen == 0) print "DEFS+=-DKAMAILIO_MOD_INTERFACE"
74
+    if (libs_seen == 0) print "SER_LIBS+=$(SERLIBPATH)/srdb1/srdb1"
75
+}
76
+
77
+{ print $0 }
78
+
79
+' > Makefile
80
+echo "done."
81
+
82
+for file in *.[ch] ; do
83
+	echo -n "Updating file $file..."
84
+	cp $file $file.backup
85
+	cat $file.backup | gawk '
86
+
87
+/^#[ \t]*include[ \t]*".*\/db\/db(_(cap|con|id|key|op|pool|query|res|row|ut|val))?\.h[ \t]*"/ {
88
+    sub("/db/", "/lib/srdb1/", $0);
89
+}
90
+
91
+/(^|[^a-zA-Z0-9_])(db_(con|res)_t|struct[ \t]+db_(con|res))([^a-zA-Z0-9_]|$)/ {
92
+    gsub("struct[ \t]+db_con", "struct db1_con", $0);
93
+    gsub("struct[ \t]+db_res", "struct db1_res", $0);
94
+    gsub("db_con_t", "db1_con_t", $0);
95
+    gsub("db_res_t", "db1_res_t", $0);
96
+}
97
+
98
+/(^|[^a-zA-Z0-9_])DB_((BIG)?INT|DOUBLE|STR(ING)?|DATETIME|BLOB|BITMAP)([^a-zA-Z0-9_]|$)/ {
99
+    gsub("DB_INT", "DB1_INT", $0);
100
+    gsub("DB_BIGINT", "DB1_BIGINT", $0);
101
+    gsub("DB_DOUBLE", "DB1_DOUBLE", $0);
102
+    gsub("DB_STR", "DB1_STR", $0);
103
+    gsub("DB_DATETIME", "DB1_DATETIME", $0);
104
+    gsub("DB_BLOB", "DB1_BLOB", $0);
105
+    gsub("DB_BITMAP", "DB1_BITMAP", $0);
106
+}
107
+
108
+{ print $0 }
109
+' >$file
110
+	echo "done."
111
+done