aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Angelacos <nangel@alpinelinux.org>2011-10-21 01:18:01 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2011-10-20 20:12:42 +0000
commit324acb3452a5bfa16e711ef0b22be938f2c8cba8 (patch)
tree82fef7f228fd8393ac1d4abd1b441358ac31e715
parent648169f02de068509c7e0582fe269a8a8e05a3a7 (diff)
downloadalpine_aports-324acb3452a5bfa16e711ef0b22be938f2c8cba8.tar.bz2
alpine_aports-324acb3452a5bfa16e711ef0b22be938f2c8cba8.tar.xz
alpine_aports-324acb3452a5bfa16e711ef0b22be938f2c8cba8.zip
main/kamailio: upgrade to 3.2.0
enable lua
-rw-r--r--main/kamailio/0001-utils-Install-the-sqlite-scripts.patch66
-rw-r--r--main/kamailio/0001-utils-add-sqlite-support-to-kamctl-kamdbctl.patch1223
-rw-r--r--main/kamailio/APKBUILD37
-rw-r--r--main/kamailio/kamailio-3.1-backslash.patch44
-rw-r--r--main/kamailio/sqlite.patch712
5 files changed, 18 insertions, 2064 deletions
diff --git a/main/kamailio/0001-utils-Install-the-sqlite-scripts.patch b/main/kamailio/0001-utils-Install-the-sqlite-scripts.patch
deleted file mode 100644
index 0c72f64511..0000000000
--- a/main/kamailio/0001-utils-Install-the-sqlite-scripts.patch
+++ /dev/null
@@ -1,66 +0,0 @@
1From 3ced6fc0e5298ac6f2f6dade4d564078ec586ebf Mon Sep 17 00:00:00 2001
2From: Natanael Copa <ncopa@alpinelinux.org>
3Date: Thu, 26 May 2011 14:04:26 +0000
4Subject: [PATCH] utils: Install the sqlite scripts
5
6Fix the makefiles to actually install the sqlite scripts
7---
8 modules_k/db_sqlite/Makefile | 10 ++++++++++
9 utils/kamctl/Makefile | 23 +++++++++++++++++++++++
10 2 files changed, 33 insertions(+), 0 deletions(-)
11
12diff --git a/modules_k/db_sqlite/Makefile b/modules_k/db_sqlite/Makefile
13index 9a75593..1f1dd2d 100644
14--- a/modules_k/db_sqlite/Makefile
15+++ b/modules_k/db_sqlite/Makefile
16@@ -13,3 +13,13 @@ DEFS+=-DOPENSER_MOD_INTERFACE
17 SERLIBPATH=../../lib
18 SER_LIBS+=$(SERLIBPATH)/srdb1/srdb1
19 include ../../Makefile.modules
20+
21+ifeq ($(INSTALL_FLAVOUR),kamailio)
22+# extra install for kamailio
23+
24+install-sqlite-scripts: $(bin_prefix)/$(bin_dir)
25+ SQLITEON=yes make -C ../../utils/kamctl/ install-modules
26+
27+install-scripts: install-sqlite-scripts
28+
29+endif # INSTALL_FLAVOUR
30diff --git a/utils/kamctl/Makefile b/utils/kamctl/Makefile
31index 0f2643b..8b0f790 100644
32--- a/utils/kamctl/Makefile
33+++ b/utils/kamctl/Makefile
34@@ -245,6 +245,29 @@ install-modules: $(bin_prefix)/$(bin_dir)
35 fi ;\
36 done ;\
37 fi
38+ # install sqlite stuff
39+ if [ "$(SQLITEON)" = "yes" ]; then \
40+ mkdir -p $(modules_prefix)/$(lib_dir)/kamctl ; \
41+ sed -e "s#/usr/local/sbin#$(bin_target)#g" \
42+ < kamctl.sqlite > /tmp/kamctl.sqlite ; \
43+ $(INSTALL_CFG) /tmp/kamctl.sqlite \
44+ $(modules_prefix)/$(lib_dir)/kamctl/kamctl.sqlite ; \
45+ rm -fr /tmp/kamctl.sqlite ; \
46+ sed -e "s#/usr/local/share/kamailio#$(data_target)#g" \
47+ < kamdbctl.sqlite > /tmp/kamdbctl.sqlite ; \
48+ $(INSTALL_TOUCH) $(modules_prefix)/$(lib_dir)/kamctl/kamdbctl.sqlite ; \
49+ $(INSTALL_CFG) /tmp/kamdbctl.sqlite $(modules_prefix)/$(lib_dir)/kamctl/ ; \
50+ rm -fr /tmp/kamdbctl.sqlite ; \
51+ mkdir -p $(data_prefix)/$(data_dir)/sqlite ; \
52+ for FILE in $(wildcard sqlite/*) ; do \
53+ if [ -f $$FILE ] ; then \
54+ $(INSTALL_TOUCH) $$FILE \
55+ $(data_prefix)/$(data_dir)/sqlite/`basename "$$FILE"` ; \
56+ $(INSTALL_CFG) $$FILE \
57+ $(data_prefix)/$(data_dir)/sqlite/`basename "$$FILE"` ; \
58+ fi ;\
59+ done ; \
60+ fi
61
62
63 $(cfg_prefix)/$(cfg_dir):
64--
651.7.4.5
66
diff --git a/main/kamailio/0001-utils-add-sqlite-support-to-kamctl-kamdbctl.patch b/main/kamailio/0001-utils-add-sqlite-support-to-kamctl-kamdbctl.patch
deleted file mode 100644
index 30525faf85..0000000000
--- a/main/kamailio/0001-utils-add-sqlite-support-to-kamctl-kamdbctl.patch
+++ /dev/null
@@ -1,1223 +0,0 @@
1From 215a55e097c07b497747caf2a04c65cb11d783c6 Mon Sep 17 00:00:00 2001
2From: Natanael Copa <ncopa@alpinelinux.org>
3Date: Thu, 26 May 2011 07:07:19 +0000
4Subject: [PATCH] utils: add sqlite support to kamctl/kamdbctl
5
6I basically copied the postgrersql scripts and simplified them a bit
7---
8 utils/kamctl/kamctl | 6 +
9 utils/kamctl/kamctl.sqlite | 51 +++++++++
10 utils/kamctl/kamctlrc | 6 +-
11 utils/kamctl/kamdbctl | 13 ++
12 utils/kamctl/kamdbctl.sqlite | 152 ++++++++++++++++++++++++++
13 utils/kamctl/sqlite/acc-create.sql | 28 +++++
14 utils/kamctl/sqlite/alias_db-create.sql | 12 ++
15 utils/kamctl/sqlite/auth_db-create.sql | 15 +++
16 utils/kamctl/sqlite/avpops-create.sql | 15 +++
17 utils/kamctl/sqlite/carrierroute-create.sql | 42 +++++++
18 utils/kamctl/sqlite/cpl-create.sql | 10 ++
19 utils/kamctl/sqlite/dialog-create.sql | 29 +++++
20 utils/kamctl/sqlite/dialplan-create.sql | 13 ++
21 utils/kamctl/sqlite/dispatcher-create.sql | 11 ++
22 utils/kamctl/sqlite/domain-create.sql | 8 ++
23 utils/kamctl/sqlite/domainpolicy-create.sql | 13 ++
24 utils/kamctl/sqlite/drouting-create.sql | 39 +++++++
25 utils/kamctl/sqlite/group-create.sql | 19 +++
26 utils/kamctl/sqlite/htable-create.sql | 9 ++
27 utils/kamctl/sqlite/imc-create.sql | 19 +++
28 utils/kamctl/sqlite/lcr-create.sql | 43 +++++++
29 utils/kamctl/sqlite/matrix-create.sql | 9 ++
30 utils/kamctl/sqlite/msilo-create.sql | 16 +++
31 utils/kamctl/sqlite/mtree-create.sql | 8 ++
32 utils/kamctl/sqlite/pdt-create.sql | 9 ++
33 utils/kamctl/sqlite/permissions-create.sql | 21 ++++
34 utils/kamctl/sqlite/presence-create.sql | 92 ++++++++++++++++
35 utils/kamctl/sqlite/purple-create.sql | 9 ++
36 utils/kamctl/sqlite/registrar-create.sql | 22 ++++
37 utils/kamctl/sqlite/rls-create.sql | 42 +++++++
38 utils/kamctl/sqlite/siptrace-create.sql | 20 ++++
39 utils/kamctl/sqlite/speeddial-create.sql | 14 +++
40 utils/kamctl/sqlite/standard-create.sql | 5 +
41 utils/kamctl/sqlite/uac-create.sql | 16 +++
42 utils/kamctl/sqlite/uri_db-create.sql | 10 ++
43 utils/kamctl/sqlite/userblacklist-create.sql | 21 ++++
44 utils/kamctl/sqlite/usrloc-create.sql | 22 ++++
45 37 files changed, 887 insertions(+), 2 deletions(-)
46 create mode 100644 utils/kamctl/kamctl.sqlite
47 create mode 100644 utils/kamctl/kamdbctl.sqlite
48 create mode 100644 utils/kamctl/sqlite/acc-create.sql
49 create mode 100644 utils/kamctl/sqlite/alias_db-create.sql
50 create mode 100644 utils/kamctl/sqlite/auth_db-create.sql
51 create mode 100644 utils/kamctl/sqlite/avpops-create.sql
52 create mode 100644 utils/kamctl/sqlite/carrierroute-create.sql
53 create mode 100644 utils/kamctl/sqlite/cpl-create.sql
54 create mode 100644 utils/kamctl/sqlite/dialog-create.sql
55 create mode 100644 utils/kamctl/sqlite/dialplan-create.sql
56 create mode 100644 utils/kamctl/sqlite/dispatcher-create.sql
57 create mode 100644 utils/kamctl/sqlite/domain-create.sql
58 create mode 100644 utils/kamctl/sqlite/domainpolicy-create.sql
59 create mode 100644 utils/kamctl/sqlite/drouting-create.sql
60 create mode 100644 utils/kamctl/sqlite/group-create.sql
61 create mode 100644 utils/kamctl/sqlite/htable-create.sql
62 create mode 100644 utils/kamctl/sqlite/imc-create.sql
63 create mode 100644 utils/kamctl/sqlite/lcr-create.sql
64 create mode 100644 utils/kamctl/sqlite/matrix-create.sql
65 create mode 100644 utils/kamctl/sqlite/msilo-create.sql
66 create mode 100644 utils/kamctl/sqlite/mtree-create.sql
67 create mode 100644 utils/kamctl/sqlite/pdt-create.sql
68 create mode 100644 utils/kamctl/sqlite/permissions-create.sql
69 create mode 100644 utils/kamctl/sqlite/presence-create.sql
70 create mode 100644 utils/kamctl/sqlite/purple-create.sql
71 create mode 100644 utils/kamctl/sqlite/registrar-create.sql
72 create mode 100644 utils/kamctl/sqlite/rls-create.sql
73 create mode 100644 utils/kamctl/sqlite/siptrace-create.sql
74 create mode 100644 utils/kamctl/sqlite/speeddial-create.sql
75 create mode 100644 utils/kamctl/sqlite/standard-create.sql
76 create mode 100644 utils/kamctl/sqlite/uac-create.sql
77 create mode 100644 utils/kamctl/sqlite/uri_db-create.sql
78 create mode 100644 utils/kamctl/sqlite/userblacklist-create.sql
79 create mode 100644 utils/kamctl/sqlite/usrloc-create.sql
80
81diff --git a/utils/kamctl/kamctl b/utils/kamctl/kamctl
82index 2ec550a..c548849 100755
83--- a/utils/kamctl/kamctl
84+++ b/utils/kamctl/kamctl
85@@ -124,6 +124,12 @@ case $DBENGINE in
86 DBENGINELOADED=1
87 fi
88 ;;
89+ SQLITE|sqlite)
90+ if [ -f "$MYLIBDIR/kamctl.sqlite" ]; then
91+ . "$MYLIBDIR/kamctl.sqlite"
92+ DBENGINELOADED=1
93+ fi
94+ ;;
95
96 esac
97
98diff --git a/utils/kamctl/kamctl.sqlite b/utils/kamctl/kamctl.sqlite
99new file mode 100644
100index 0000000..8c3eb21
101--- /dev/null
102+++ b/utils/kamctl/kamctl.sqlite
103@@ -0,0 +1,51 @@
104+#
105+# $Id$
106+#
107+# control tool for maintaining Kamailio
108+#
109+#===================================================================
110+
111+##### ----------------------------------------------- #####
112+### SQLITE specific variables and functions
113+#
114+
115+##### ----------------------------------------------- #####
116+### load SQL base
117+#
118+if [ -f "$MYLIBDIR/kamctl.sqlbase" ]; then
119+ . "$MYLIBDIR/kamctl.sqlbase"
120+else
121+ echo "Cannot load SQL core functions '$MYLIBDIR/kamctl.sqlbase' - exiting ..."
122+ exit -1
123+fi
124+
125+DBNAME=$DB_PATH
126+
127+##### ----------------------------------------------- #####
128+### binaries
129+if [ -z "$SQLITE" ] ; then
130+ locate_tool sqlite3
131+ if [ -z "$TOOLPATH" ] ; then
132+ echo "error: 'sqlite3' tool not found: set SQLITE variable to correct tool path"
133+ exit
134+ fi
135+ SQLITE="$TOOLPATH"
136+fi
137+
138+
139+# input: sql query, optional sqlite3 command-line params
140+sqlite_query() {
141+ # if password not yet queried, query it now
142+ mecho "sqlite_query: $SQLITE $2 $DBNAME $1"
143+ $SQLITE $2 $DBNAME "$1"
144+}
145+
146+# input: sql query, optional sqlite3 command-line params
147+sqlite_ro_query() {
148+ sqlite_query "$@"
149+}
150+
151+DBCMD=sqlite_query
152+DBROCMD=sqlite_ro_query
153+DBRAWPARAMS=
154+
155diff --git a/utils/kamctl/kamctlrc b/utils/kamctl/kamctlrc
156index 5e888bd..ceb6f54 100644
157--- a/utils/kamctl/kamctlrc
158+++ b/utils/kamctl/kamctlrc
159@@ -12,7 +12,9 @@
160 ## chrooted directory
161 # $CHROOT_DIR="/path/to/chrooted/directory"
162
163-## database type: MYSQL, PGSQL, ORACLE, DB_BERKELEY, or DBTEXT, by default none is loaded
164+## database type: MYSQL, PGSQL, ORACLE, DB_BERKELEY, DBTEXT, or SQLITE
165+# by default none is loaded
166+#
167 # If you want to setup a database with kamdbctl, you must at least specify
168 # this parameter.
169 # DBENGINE=MYSQL
170@@ -23,7 +25,7 @@
171 ## database name (for ORACLE this is TNS name)
172 # DBNAME=openser
173
174-# database path used by dbtext or db_berkeley
175+# database path used by dbtext, db_berkeley or sqlite
176 # DB_PATH="/usr/local/etc/kamailio/dbtext"
177
178 ## database read/write user
179diff --git a/utils/kamctl/kamdbctl b/utils/kamctl/kamdbctl
180index c04bebd..d60f10f 100755
181--- a/utils/kamctl/kamdbctl
182+++ b/utils/kamctl/kamdbctl
183@@ -108,6 +108,15 @@ case $DBENGINE in
184 merr "could not load the script in $MYLIBDIR/kamdbctl.db_berkeley for database engine $DBENGINE"
185 fi
186 ;;
187+ SQLITE|sqlite)
188+ if [ -f "$MYLIBDIR/kamdbctl.sqlite" ]; then
189+ . "$MYLIBDIR/kamdbctl.sqlite"
190+ USED_DBENGINE="sqlite"
191+ DBNAME=$DB_PATH
192+ else
193+ merr "could not load the script in $MYLIBDIR/kamdbctl.sqlite for database engine $DBENGINE"
194+ fi
195+ ;;
196 esac
197
198 if [ -z "$USED_DBENGINE" ] ; then
199@@ -194,6 +203,10 @@ case $1 in
200 usage
201 exit 1
202 fi
203+ if [ "$USED_DBENGINE" = "sqlite" ]; then
204+ cp $DB_PATH $1
205+ exit $?
206+ fi
207 tmp_file=`mktemp /tmp/kamdbctl.XXXXXXXXXX` || exit 1
208 openser_dump $DBNAME $tmp_file
209 ret=$?
210diff --git a/utils/kamctl/kamdbctl.sqlite b/utils/kamctl/kamdbctl.sqlite
211new file mode 100644
212index 0000000..ecb51aa
213--- /dev/null
214+++ b/utils/kamctl/kamdbctl.sqlite
215@@ -0,0 +1,152 @@
216+# $Id$
217+#
218+# Script for adding and dropping Kamailio sqlite tables
219+#
220+
221+# path to the database schemas
222+DATA_DIR="/usr/local/share/kamailio"
223+if [ -d "$DATA_DIR/sqlite" ] ; then
224+ DB_SCHEMA="$DATA_DIR/sqlite"
225+else
226+ DB_SCHEMA="./sqlite"
227+fi
228+
229+#################################################################
230+# config vars
231+#################################################################
232+
233+CMD="sqlite3"
234+DUMP_CMD="sql_dump"
235+#################################################################
236+
237+sql_dump()
238+{
239+ $CMD ${1:-$DB_PATH} .dump
240+}
241+
242+# execute sql command with optional db name
243+sql_query()
244+{
245+ $CMD "$@"
246+}
247+
248+
249+openser_drop() # pars: <database name>
250+{
251+if [ $# -ne 1 ] ; then
252+ merr "openser_drop function takes one param"
253+ exit 1
254+fi
255+
256+if ! rm $1; then
257+ merr "Dropping database $1 failed!"
258+ exit 1
259+fi
260+
261+minfo "Database $1 dropped"
262+} #openser_drop
263+
264+
265+openser_create () # pars: <database name>
266+{
267+if [ $# -ne 1 ] ; then
268+ merr "openser_create function takes one param"
269+ exit 1
270+fi
271+
272+minfo "creating database $1 ..."
273+
274+if [ $? -ne 0 ] ; then
275+ merr "Creating database failed!"
276+ exit 1
277+fi
278+
279+#sql_query "$1" "CREATE FUNCTION "concat" (text,text) RETURNS text AS 'SELECT \$1 || \$2;' LANGUAGE 'sql';
280+# CREATE FUNCTION "rand" () RETURNS double precision AS 'SELECT random();' LANGUAGE 'sql';"
281+# emulate mysql proprietary functions used by the lcr module in postgresql
282+
283+#if [ $? -ne 0 ] ; then
284+# merr "Creating mysql emulation functions failed!"
285+# exit 1
286+#fi
287+
288+for TABLE in $STANDARD_MODULES; do
289+ mdbg "Creating core table: $TABLE"
290+ sql_query "$1" < $DB_SCHEMA/$TABLE-create.sql
291+ if [ $? -ne 0 ] ; then
292+ merr "Creating core tables failed!"
293+ exit 1
294+ fi
295+done
296+
297+if [ -e $DB_SCHEMA/extensions-create.sql ]
298+then
299+ minfo "Creating custom extensions tables"
300+ sql_query $1 < $DB_SCHEMA/extensions-create.sql
301+ if [ $? -ne 0 ] ; then
302+ merr "Creating custom extensions tables failed!"
303+ exit 1
304+ fi
305+fi
306+
307+minfo "Core Kamailio tables succesfully created."
308+
309+get_answer $INSTALL_PRESENCE_TABLES "Install presence related tables? (y/n): "
310+if [ "$ANSWER" = "y" ]; then
311+ presence_create $1
312+fi
313+
314+get_answer $INSTALL_EXTRA_TABLES "Install tables for $EXTRA_MODULES? (y/n): "
315+if [ "$ANSWER" = "y" ]; then
316+ extra_create $1
317+fi
318+} # openser_create
319+
320+
321+presence_create () # pars: <database name>
322+{
323+if [ $# -ne 1 ] ; then
324+ merr "presence_create function takes one param"
325+ exit 1
326+fi
327+
328+minfo "creating presence tables into $1 ..."
329+
330+sql_query "$1" < $DB_SCHEMA/presence-create.sql
331+
332+if [ $? -ne 0 ] ; then
333+ merr "Failed to create presence tables!"
334+ exit 1
335+fi
336+
337+sql_query "$1" < $DB_SCHEMA/rls-create.sql
338+
339+if [ $? -ne 0 ] ; then
340+ merr "Failed to create rls-presence tables!"
341+ exit 1
342+fi
343+
344+minfo "Presence tables succesfully created."
345+} # end presence_create
346+
347+
348+extra_create () # pars: <database name>
349+{
350+if [ $# -ne 1 ] ; then
351+ merr "extra_create function takes one param"
352+ exit 1
353+fi
354+
355+minfo "creating extra tables into $1 ..."
356+
357+for TABLE in $EXTRA_MODULES; do
358+ mdbg "Creating extra table: $TABLE"
359+ sql_query "$1" < $DB_SCHEMA/$TABLE-create.sql
360+ if [ $? -ne 0 ] ; then
361+ merr "Creating extra tables failed!"
362+ exit 1
363+ fi
364+done
365+
366+minfo "Extra tables succesfully created."
367+} # end extra_create
368diff --git a/utils/kamctl/sqlite/acc-create.sql b/utils/kamctl/sqlite/acc-create.sql
369new file mode 100644
370index 0000000..4d23363
371--- /dev/null
372+++ b/utils/kamctl/sqlite/acc-create.sql
373@@ -0,0 +1,28 @@
374+INSERT INTO version (table_name, table_version) values ('acc','4');
375+CREATE TABLE acc (
376+ id INTEGER PRIMARY KEY NOT NULL,
377+ method VARCHAR(16) DEFAULT '' NOT NULL,
378+ from_tag VARCHAR(64) DEFAULT '' NOT NULL,
379+ to_tag VARCHAR(64) DEFAULT '' NOT NULL,
380+ callid VARCHAR(64) DEFAULT '' NOT NULL,
381+ sip_code VARCHAR(3) DEFAULT '' NOT NULL,
382+ sip_reason VARCHAR(32) DEFAULT '' NOT NULL,
383+ time TIMESTAMP WITHOUT TIME ZONE NOT NULL
384+);
385+
386+CREATE INDEX acc_callid_idx ON acc (callid);
387+
388+INSERT INTO version (table_name, table_version) values ('missed_calls','3');
389+CREATE TABLE missed_calls (
390+ id INTEGER PRIMARY KEY NOT NULL,
391+ method VARCHAR(16) DEFAULT '' NOT NULL,
392+ from_tag VARCHAR(64) DEFAULT '' NOT NULL,
393+ to_tag VARCHAR(64) DEFAULT '' NOT NULL,
394+ callid VARCHAR(64) DEFAULT '' NOT NULL,
395+ sip_code VARCHAR(3) DEFAULT '' NOT NULL,
396+ sip_reason VARCHAR(32) DEFAULT '' NOT NULL,
397+ time TIMESTAMP WITHOUT TIME ZONE NOT NULL
398+);
399+
400+CREATE INDEX missed_calls_callid_idx ON missed_calls (callid);
401+
402diff --git a/utils/kamctl/sqlite/alias_db-create.sql b/utils/kamctl/sqlite/alias_db-create.sql
403new file mode 100644
404index 0000000..90656e9
405--- /dev/null
406+++ b/utils/kamctl/sqlite/alias_db-create.sql
407@@ -0,0 +1,12 @@
408+INSERT INTO version (table_name, table_version) values ('dbaliases','1');
409+CREATE TABLE dbaliases (
410+ id INTEGER PRIMARY KEY NOT NULL,
411+ alias_username VARCHAR(64) DEFAULT '' NOT NULL,
412+ alias_domain VARCHAR(64) DEFAULT '' NOT NULL,
413+ username VARCHAR(64) DEFAULT '' NOT NULL,
414+ domain VARCHAR(64) DEFAULT '' NOT NULL,
415+ CONSTRAINT dbaliases_alias_idx UNIQUE (alias_username, alias_domain)
416+);
417+
418+CREATE INDEX dbaliases_target_idx ON dbaliases (username, domain);
419+
420diff --git a/utils/kamctl/sqlite/auth_db-create.sql b/utils/kamctl/sqlite/auth_db-create.sql
421new file mode 100644
422index 0000000..7d6d1f8
423--- /dev/null
424+++ b/utils/kamctl/sqlite/auth_db-create.sql
425@@ -0,0 +1,15 @@
426+INSERT INTO version (table_name, table_version) values ('subscriber','6');
427+CREATE TABLE subscriber (
428+ id INTEGER PRIMARY KEY NOT NULL,
429+ username VARCHAR(64) DEFAULT '' NOT NULL,
430+ domain VARCHAR(64) DEFAULT '' NOT NULL,
431+ password VARCHAR(25) DEFAULT '' NOT NULL,
432+ email_address VARCHAR(64) DEFAULT '' NOT NULL,
433+ ha1 VARCHAR(64) DEFAULT '' NOT NULL,
434+ ha1b VARCHAR(64) DEFAULT '' NOT NULL,
435+ rpid VARCHAR(64) DEFAULT NULL,
436+ CONSTRAINT subscriber_account_idx UNIQUE (username, domain)
437+);
438+
439+CREATE INDEX subscriber_username_idx ON subscriber (username);
440+
441diff --git a/utils/kamctl/sqlite/avpops-create.sql b/utils/kamctl/sqlite/avpops-create.sql
442new file mode 100644
443index 0000000..007ecb5
444--- /dev/null
445+++ b/utils/kamctl/sqlite/avpops-create.sql
446@@ -0,0 +1,15 @@
447+INSERT INTO version (table_name, table_version) values ('usr_preferences','2');
448+CREATE TABLE usr_preferences (
449+ id INTEGER PRIMARY KEY NOT NULL,
450+ uuid VARCHAR(64) DEFAULT '' NOT NULL,
451+ username VARCHAR(128) DEFAULT 0 NOT NULL,
452+ domain VARCHAR(64) DEFAULT '' NOT NULL,
453+ attribute VARCHAR(32) DEFAULT '' NOT NULL,
454+ type INTEGER DEFAULT 0 NOT NULL,
455+ value VARCHAR(128) DEFAULT '' NOT NULL,
456+ last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL
457+);
458+
459+CREATE INDEX usr_preferences_ua_idx ON usr_preferences (uuid, attribute);
460+CREATE INDEX usr_preferences_uda_idx ON usr_preferences (username, domain, attribute);
461+
462diff --git a/utils/kamctl/sqlite/carrierroute-create.sql b/utils/kamctl/sqlite/carrierroute-create.sql
463new file mode 100644
464index 0000000..baafbee
465--- /dev/null
466+++ b/utils/kamctl/sqlite/carrierroute-create.sql
467@@ -0,0 +1,42 @@
468+INSERT INTO version (table_name, table_version) values ('carrierroute','3');
469+CREATE TABLE carrierroute (
470+ id INTEGER PRIMARY KEY NOT NULL,
471+ carrier INTEGER DEFAULT 0 NOT NULL,
472+ domain INTEGER DEFAULT 0 NOT NULL,
473+ scan_prefix VARCHAR(64) DEFAULT '' NOT NULL,
474+ flags INTEGER DEFAULT 0 NOT NULL,
475+ mask INTEGER DEFAULT 0 NOT NULL,
476+ prob REAL DEFAULT 0 NOT NULL,
477+ strip INTEGER DEFAULT 0 NOT NULL,
478+ rewrite_host VARCHAR(128) DEFAULT '' NOT NULL,
479+ rewrite_prefix VARCHAR(64) DEFAULT '' NOT NULL,
480+ rewrite_suffix VARCHAR(64) DEFAULT '' NOT NULL,
481+ description VARCHAR(255) DEFAULT NULL
482+);
483+
484+INSERT INTO version (table_name, table_version) values ('carrierfailureroute','2');
485+CREATE TABLE carrierfailureroute (
486+ id INTEGER PRIMARY KEY NOT NULL,
487+ carrier INTEGER DEFAULT 0 NOT NULL,
488+ domain INTEGER DEFAULT 0 NOT NULL,
489+ scan_prefix VARCHAR(64) DEFAULT '' NOT NULL,
490+ host_name VARCHAR(128) DEFAULT '' NOT NULL,
491+ reply_code VARCHAR(3) DEFAULT '' NOT NULL,
492+ flags INTEGER DEFAULT 0 NOT NULL,
493+ mask INTEGER DEFAULT 0 NOT NULL,
494+ next_domain INTEGER DEFAULT 0 NOT NULL,
495+ description VARCHAR(255) DEFAULT NULL
496+);
497+
498+INSERT INTO version (table_name, table_version) values ('carrier_name','1');
499+CREATE TABLE carrier_name (
500+ id INTEGER PRIMARY KEY NOT NULL,
501+ carrier VARCHAR(64) DEFAULT NULL
502+);
503+
504+INSERT INTO version (table_name, table_version) values ('domain_name','1');
505+CREATE TABLE domain_name (
506+ id INTEGER PRIMARY KEY NOT NULL,
507+ domain VARCHAR(64) DEFAULT NULL
508+);
509+
510diff --git a/utils/kamctl/sqlite/cpl-create.sql b/utils/kamctl/sqlite/cpl-create.sql
511new file mode 100644
512index 0000000..8beedf5
513--- /dev/null
514+++ b/utils/kamctl/sqlite/cpl-create.sql
515@@ -0,0 +1,10 @@
516+INSERT INTO version (table_name, table_version) values ('cpl','1');
517+CREATE TABLE cpl (
518+ id INTEGER PRIMARY KEY NOT NULL,
519+ username VARCHAR(64) NOT NULL,
520+ domain VARCHAR(64) DEFAULT '' NOT NULL,
521+ cpl_xml TEXT,
522+ cpl_bin TEXT,
523+ CONSTRAINT cpl_account_idx UNIQUE (username, domain)
524+);
525+
526diff --git a/utils/kamctl/sqlite/dialog-create.sql b/utils/kamctl/sqlite/dialog-create.sql
527new file mode 100644
528index 0000000..bb086a5
529--- /dev/null
530+++ b/utils/kamctl/sqlite/dialog-create.sql
531@@ -0,0 +1,29 @@
532+INSERT INTO version (table_name, table_version) values ('dialog','5');
533+CREATE TABLE dialog (
534+ id INTEGER PRIMARY KEY NOT NULL,
535+ hash_entry INTEGER NOT NULL,
536+ hash_id INTEGER NOT NULL,
537+ callid VARCHAR(255) NOT NULL,
538+ from_uri VARCHAR(128) NOT NULL,
539+ from_tag VARCHAR(64) NOT NULL,
540+ to_uri VARCHAR(128) NOT NULL,
541+ to_tag VARCHAR(64) NOT NULL,
542+ caller_cseq VARCHAR(7) NOT NULL,
543+ callee_cseq VARCHAR(7) NOT NULL,
544+ caller_route_set VARCHAR(512),
545+ callee_route_set VARCHAR(512),
546+ caller_contact VARCHAR(128) NOT NULL,
547+ callee_contact VARCHAR(128) NOT NULL,
548+ caller_sock VARCHAR(64) NOT NULL,
549+ callee_sock VARCHAR(64) NOT NULL,
550+ state INTEGER NOT NULL,
551+ start_time INTEGER NOT NULL,
552+ timeout INTEGER DEFAULT 0 NOT NULL,
553+ sflags INTEGER DEFAULT 0 NOT NULL,
554+ toroute INTEGER DEFAULT 0 NOT NULL,
555+ toroute_name VARCHAR(32),
556+ req_uri VARCHAR(128) NOT NULL
557+);
558+
559+CREATE INDEX dialog_hash_idx ON dialog (hash_entry, hash_id);
560+
561diff --git a/utils/kamctl/sqlite/dialplan-create.sql b/utils/kamctl/sqlite/dialplan-create.sql
562new file mode 100644
563index 0000000..1a85e50
564--- /dev/null
565+++ b/utils/kamctl/sqlite/dialplan-create.sql
566@@ -0,0 +1,13 @@
567+INSERT INTO version (table_name, table_version) values ('dialplan','1');
568+CREATE TABLE dialplan (
569+ id INTEGER PRIMARY KEY NOT NULL,
570+ dpid INTEGER NOT NULL,
571+ pr INTEGER NOT NULL,
572+ match_op INTEGER NOT NULL,
573+ match_exp VARCHAR(64) NOT NULL,
574+ match_len INTEGER NOT NULL,
575+ subst_exp VARCHAR(64) NOT NULL,
576+ repl_exp VARCHAR(32) NOT NULL,
577+ attrs VARCHAR(32) NOT NULL
578+);
579+
580diff --git a/utils/kamctl/sqlite/dispatcher-create.sql b/utils/kamctl/sqlite/dispatcher-create.sql
581new file mode 100644
582index 0000000..ec37fc4
583--- /dev/null
584+++ b/utils/kamctl/sqlite/dispatcher-create.sql
585@@ -0,0 +1,11 @@
586+INSERT INTO version (table_name, table_version) values ('dispatcher','4');
587+CREATE TABLE dispatcher (
588+ id INTEGER PRIMARY KEY NOT NULL,
589+ setid INTEGER DEFAULT 0 NOT NULL,
590+ destination VARCHAR(192) DEFAULT '' NOT NULL,
591+ flags INTEGER DEFAULT 0 NOT NULL,
592+ priority INTEGER DEFAULT 0 NOT NULL,
593+ attrs VARCHAR(128) DEFAULT '' NOT NULL,
594+ description VARCHAR(64) DEFAULT '' NOT NULL
595+);
596+
597diff --git a/utils/kamctl/sqlite/domain-create.sql b/utils/kamctl/sqlite/domain-create.sql
598new file mode 100644
599index 0000000..0b1fbe4
600--- /dev/null
601+++ b/utils/kamctl/sqlite/domain-create.sql
602@@ -0,0 +1,8 @@
603+INSERT INTO version (table_name, table_version) values ('domain','1');
604+CREATE TABLE domain (
605+ id INTEGER PRIMARY KEY NOT NULL,
606+ domain VARCHAR(64) DEFAULT '' NOT NULL,
607+ last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL,
608+ CONSTRAINT domain_domain_idx UNIQUE (domain)
609+);
610+
611diff --git a/utils/kamctl/sqlite/domainpolicy-create.sql b/utils/kamctl/sqlite/domainpolicy-create.sql
612new file mode 100644
613index 0000000..c7cb279
614--- /dev/null
615+++ b/utils/kamctl/sqlite/domainpolicy-create.sql
616@@ -0,0 +1,13 @@
617+INSERT INTO version (table_name, table_version) values ('domainpolicy','2');
618+CREATE TABLE domainpolicy (
619+ id INTEGER PRIMARY KEY NOT NULL,
620+ rule VARCHAR(255) NOT NULL,
621+ type VARCHAR(255) NOT NULL,
622+ att VARCHAR(255),
623+ val VARCHAR(128),
624+ description VARCHAR(255) NOT NULL,
625+ CONSTRAINT domainpolicy_rav_idx UNIQUE (rule, att, val)
626+);
627+
628+CREATE INDEX domainpolicy_rule_idx ON domainpolicy (rule);
629+
630diff --git a/utils/kamctl/sqlite/drouting-create.sql b/utils/kamctl/sqlite/drouting-create.sql
631new file mode 100644
632index 0000000..9c962fa
633--- /dev/null
634+++ b/utils/kamctl/sqlite/drouting-create.sql
635@@ -0,0 +1,39 @@
636+INSERT INTO version (table_name, table_version) values ('dr_gateways','3');
637+CREATE TABLE dr_gateways (
638+ gwid INTEGER PRIMARY KEY NOT NULL,
639+ type INTEGER DEFAULT 0 NOT NULL,
640+ address VARCHAR(128) NOT NULL,
641+ strip INTEGER DEFAULT 0 NOT NULL,
642+ pri_prefix VARCHAR(64) DEFAULT NULL,
643+ attrs VARCHAR(255) DEFAULT NULL,
644+ description VARCHAR(128) DEFAULT '' NOT NULL
645+);
646+
647+INSERT INTO version (table_name, table_version) values ('dr_rules','3');
648+CREATE TABLE dr_rules (
649+ ruleid INTEGER PRIMARY KEY NOT NULL,
650+ groupid VARCHAR(255) NOT NULL,
651+ prefix VARCHAR(64) NOT NULL,
652+ timerec VARCHAR(255) NOT NULL,
653+ priority INTEGER DEFAULT 0 NOT NULL,
654+ routeid VARCHAR(64) NOT NULL,
655+ gwlist VARCHAR(255) NOT NULL,
656+ description VARCHAR(128) DEFAULT '' NOT NULL
657+);
658+
659+INSERT INTO version (table_name, table_version) values ('dr_gw_lists','1');
660+CREATE TABLE dr_gw_lists (
661+ id INTEGER PRIMARY KEY NOT NULL,
662+ gwlist VARCHAR(255) NOT NULL,
663+ description VARCHAR(128) DEFAULT '' NOT NULL
664+);
665+
666+INSERT INTO version (table_name, table_version) values ('dr_groups','2');
667+CREATE TABLE dr_groups (
668+ id INTEGER PRIMARY KEY NOT NULL,
669+ username VARCHAR(64) NOT NULL,
670+ domain VARCHAR(128) DEFAULT '' NOT NULL,
671+ groupid INTEGER DEFAULT 0 NOT NULL,
672+ description VARCHAR(128) DEFAULT '' NOT NULL
673+);
674+
675diff --git a/utils/kamctl/sqlite/group-create.sql b/utils/kamctl/sqlite/group-create.sql
676new file mode 100644
677index 0000000..fbd91c5
678--- /dev/null
679+++ b/utils/kamctl/sqlite/group-create.sql
680@@ -0,0 +1,19 @@
681+INSERT INTO version (table_name, table_version) values ('grp','2');
682+CREATE TABLE grp (
683+ id INTEGER PRIMARY KEY NOT NULL,
684+ username VARCHAR(64) DEFAULT '' NOT NULL,
685+ domain VARCHAR(64) DEFAULT '' NOT NULL,
686+ grp VARCHAR(64) DEFAULT '' NOT NULL,
687+ last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL,
688+ CONSTRAINT grp_account_group_idx UNIQUE (username, domain, grp)
689+);
690+
691+INSERT INTO version (table_name, table_version) values ('re_grp','1');
692+CREATE TABLE re_grp (
693+ id INTEGER PRIMARY KEY NOT NULL,
694+ reg_exp VARCHAR(128) DEFAULT '' NOT NULL,
695+ group_id INTEGER DEFAULT 0 NOT NULL
696+);
697+
698+CREATE INDEX re_grp_group_idx ON re_grp (group_id);
699+
700diff --git a/utils/kamctl/sqlite/htable-create.sql b/utils/kamctl/sqlite/htable-create.sql
701new file mode 100644
702index 0000000..59fa681
703--- /dev/null
704+++ b/utils/kamctl/sqlite/htable-create.sql
705@@ -0,0 +1,9 @@
706+INSERT INTO version (table_name, table_version) values ('htable','1');
707+CREATE TABLE htable (
708+ id INTEGER PRIMARY KEY NOT NULL,
709+ key_name VARCHAR(64) DEFAULT '' NOT NULL,
710+ key_type INTEGER DEFAULT 0 NOT NULL,
711+ value_type INTEGER DEFAULT 0 NOT NULL,
712+ key_value VARCHAR(128) DEFAULT '' NOT NULL
713+);
714+
715diff --git a/utils/kamctl/sqlite/imc-create.sql b/utils/kamctl/sqlite/imc-create.sql
716new file mode 100644
717index 0000000..99d68c1
718--- /dev/null
719+++ b/utils/kamctl/sqlite/imc-create.sql
720@@ -0,0 +1,19 @@
721+INSERT INTO version (table_name, table_version) values ('imc_rooms','1');
722+CREATE TABLE imc_rooms (
723+ id INTEGER PRIMARY KEY NOT NULL,
724+ name VARCHAR(64) NOT NULL,
725+ domain VARCHAR(64) NOT NULL,
726+ flag INTEGER NOT NULL,
727+ CONSTRAINT imc_rooms_name_domain_idx UNIQUE (name, domain)
728+);
729+
730+INSERT INTO version (table_name, table_version) values ('imc_members','1');
731+CREATE TABLE imc_members (
732+ id INTEGER PRIMARY KEY NOT NULL,
733+ username VARCHAR(64) NOT NULL,
734+ domain VARCHAR(64) NOT NULL,
735+ room VARCHAR(64) NOT NULL,
736+ flag INTEGER NOT NULL,
737+ CONSTRAINT imc_members_account_room_idx UNIQUE (username, domain, room)
738+);
739+
740diff --git a/utils/kamctl/sqlite/lcr-create.sql b/utils/kamctl/sqlite/lcr-create.sql
741new file mode 100644
742index 0000000..bf93141
743--- /dev/null
744+++ b/utils/kamctl/sqlite/lcr-create.sql
745@@ -0,0 +1,43 @@
746+INSERT INTO version (table_name, table_version) values ('lcr_gw','2');
747+CREATE TABLE lcr_gw (
748+ id INTEGER PRIMARY KEY NOT NULL,
749+ lcr_id SMALLINT NOT NULL,
750+ gw_name VARCHAR(128),
751+ ip_addr VARCHAR(15),
752+ hostname VARCHAR(64),
753+ port SMALLINT,
754+ params VARCHAR(64),
755+ uri_scheme SMALLINT,
756+ transport SMALLINT,
757+ strip SMALLINT,
758+ prefix VARCHAR(16) DEFAULT NULL,
759+ tag VARCHAR(64) DEFAULT NULL,
760+ flags INTEGER DEFAULT 0 NOT NULL,
761+ defunct INTEGER DEFAULT NULL,
762+ CONSTRAINT lcr_gw_lcr_id_ip_addr_port_hostname_idx UNIQUE (lcr_id, ip_addr, port, hostname)
763+);
764+
765+INSERT INTO version (table_name, table_version) values ('lcr_rule_target','1');
766+CREATE TABLE lcr_rule_target (
767+ id INTEGER PRIMARY KEY NOT NULL,
768+ lcr_id SMALLINT NOT NULL,
769+ rule_id INTEGER NOT NULL,
770+ gw_id INTEGER NOT NULL,
771+ priority SMALLINT NOT NULL,
772+ weight INTEGER DEFAULT 1 NOT NULL,
773+ CONSTRAINT lcr_rule_target_rule_id_gw_id_idx UNIQUE (rule_id, gw_id)
774+);
775+
776+CREATE INDEX lcr_rule_target_lcr_id_idx ON lcr_rule_target (lcr_id);
777+
778+INSERT INTO version (table_name, table_version) values ('lcr_rule','1');
779+CREATE TABLE lcr_rule (
780+ id INTEGER PRIMARY KEY NOT NULL,
781+ lcr_id SMALLINT NOT NULL,
782+ prefix VARCHAR(16) DEFAULT NULL,
783+ from_uri VARCHAR(64) DEFAULT NULL,
784+ stopper INTEGER DEFAULT 0 NOT NULL,
785+ enabled INTEGER DEFAULT 1 NOT NULL,
786+ CONSTRAINT lcr_rule_lcr_id_prefix_from_uri_idx UNIQUE (lcr_id, prefix, from_uri)
787+);
788+
789diff --git a/utils/kamctl/sqlite/matrix-create.sql b/utils/kamctl/sqlite/matrix-create.sql
790new file mode 100644
791index 0000000..50f2ed8
792--- /dev/null
793+++ b/utils/kamctl/sqlite/matrix-create.sql
794@@ -0,0 +1,9 @@
795+INSERT INTO version (table_name, table_version) values ('matrix','1');
796+CREATE TABLE matrix (
797+ first INTEGER NOT NULL,
798+ second SMALLINT NOT NULL,
799+ res INTEGER NOT NULL
800+);
801+
802+CREATE INDEX matrix_matrix_idx ON matrix (first, second);
803+
804diff --git a/utils/kamctl/sqlite/msilo-create.sql b/utils/kamctl/sqlite/msilo-create.sql
805new file mode 100644
806index 0000000..7234112
807--- /dev/null
808+++ b/utils/kamctl/sqlite/msilo-create.sql
809@@ -0,0 +1,16 @@
810+INSERT INTO version (table_name, table_version) values ('silo','5');
811+CREATE TABLE silo (
812+ id INTEGER PRIMARY KEY NOT NULL,
813+ src_addr VARCHAR(128) DEFAULT '' NOT NULL,
814+ dst_addr VARCHAR(128) DEFAULT '' NOT NULL,
815+ username VARCHAR(64) DEFAULT '' NOT NULL,
816+ domain VARCHAR(64) DEFAULT '' NOT NULL,
817+ inc_time INTEGER DEFAULT 0 NOT NULL,
818+ exp_time INTEGER DEFAULT 0 NOT NULL,
819+ snd_time INTEGER DEFAULT 0 NOT NULL,
820+ ctype VARCHAR(32) DEFAULT 'text/plain' NOT NULL,
821+ body BYTEA DEFAULT '' NOT NULL
822+);
823+
824+CREATE INDEX silo_account_idx ON silo (username, domain);
825+
826diff --git a/utils/kamctl/sqlite/mtree-create.sql b/utils/kamctl/sqlite/mtree-create.sql
827new file mode 100644
828index 0000000..9b6f56f
829--- /dev/null
830+++ b/utils/kamctl/sqlite/mtree-create.sql
831@@ -0,0 +1,8 @@
832+INSERT INTO version (table_name, table_version) values ('mtree','1');
833+CREATE TABLE mtree (
834+ id INTEGER PRIMARY KEY NOT NULL,
835+ tprefix VARCHAR(32) DEFAULT '' NOT NULL,
836+ tvalue VARCHAR(128) DEFAULT '' NOT NULL,
837+ CONSTRAINT mtree_tprefix_idx UNIQUE (tprefix)
838+);
839+
840diff --git a/utils/kamctl/sqlite/pdt-create.sql b/utils/kamctl/sqlite/pdt-create.sql
841new file mode 100644
842index 0000000..46b517a
843--- /dev/null
844+++ b/utils/kamctl/sqlite/pdt-create.sql
845@@ -0,0 +1,9 @@
846+INSERT INTO version (table_name, table_version) values ('pdt','1');
847+CREATE TABLE pdt (
848+ id INTEGER PRIMARY KEY NOT NULL,
849+ sdomain VARCHAR(128) NOT NULL,
850+ prefix VARCHAR(32) NOT NULL,
851+ domain VARCHAR(128) DEFAULT '' NOT NULL,
852+ CONSTRAINT pdt_sdomain_prefix_idx UNIQUE (sdomain, prefix)
853+);
854+
855diff --git a/utils/kamctl/sqlite/permissions-create.sql b/utils/kamctl/sqlite/permissions-create.sql
856new file mode 100644
857index 0000000..ff3ac56
858--- /dev/null
859+++ b/utils/kamctl/sqlite/permissions-create.sql
860@@ -0,0 +1,21 @@
861+INSERT INTO version (table_name, table_version) values ('trusted','5');
862+CREATE TABLE trusted (
863+ id INTEGER PRIMARY KEY NOT NULL,
864+ src_ip VARCHAR(50) NOT NULL,
865+ proto VARCHAR(4) NOT NULL,
866+ from_pattern VARCHAR(64) DEFAULT NULL,
867+ tag VARCHAR(64)
868+);
869+
870+CREATE INDEX trusted_peer_idx ON trusted (src_ip);
871+
872+INSERT INTO version (table_name, table_version) values ('address','4');
873+CREATE TABLE address (
874+ id INTEGER PRIMARY KEY NOT NULL,
875+ grp SMALLINT DEFAULT 1 NOT NULL,
876+ ip_addr VARCHAR(15) NOT NULL,
877+ mask SMALLINT DEFAULT 32 NOT NULL,
878+ port SMALLINT DEFAULT 0 NOT NULL,
879+ tag VARCHAR(64)
880+);
881+
882diff --git a/utils/kamctl/sqlite/presence-create.sql b/utils/kamctl/sqlite/presence-create.sql
883new file mode 100644
884index 0000000..fe89b36
885--- /dev/null
886+++ b/utils/kamctl/sqlite/presence-create.sql
887@@ -0,0 +1,92 @@
888+INSERT INTO version (table_name, table_version) values ('presentity','3');
889+CREATE TABLE presentity (
890+ id INTEGER PRIMARY KEY NOT NULL,
891+ username VARCHAR(64) NOT NULL,
892+ domain VARCHAR(64) NOT NULL,
893+ event VARCHAR(64) NOT NULL,
894+ etag VARCHAR(64) NOT NULL,
895+ expires INTEGER NOT NULL,
896+ received_time INTEGER NOT NULL,
897+ body BYTEA NOT NULL,
898+ sender VARCHAR(128) NOT NULL,
899+ CONSTRAINT presentity_presentity_idx UNIQUE (username, domain, event, etag)
900+);
901+
902+INSERT INTO version (table_name, table_version) values ('active_watchers','9');
903+CREATE TABLE active_watchers (
904+ id INTEGER PRIMARY KEY NOT NULL,
905+ presentity_uri VARCHAR(128) NOT NULL,
906+ watcher_username VARCHAR(64) NOT NULL,
907+ watcher_domain VARCHAR(64) NOT NULL,
908+ to_user VARCHAR(64) NOT NULL,
909+ to_domain VARCHAR(64) NOT NULL,
910+ event VARCHAR(64) DEFAULT 'presence' NOT NULL,
911+ event_id VARCHAR(64),
912+ to_tag VARCHAR(64) NOT NULL,
913+ from_tag VARCHAR(64) NOT NULL,
914+ callid VARCHAR(128) NOT NULL,
915+ local_cseq INTEGER NOT NULL,
916+ remote_cseq INTEGER NOT NULL,
917+ contact VARCHAR(128) NOT NULL,
918+ record_route TEXT,
919+ expires INTEGER NOT NULL,
920+ status INTEGER DEFAULT 2 NOT NULL,
921+ reason VARCHAR(64) NOT NULL,
922+ version INTEGER DEFAULT 0 NOT NULL,
923+ socket_info VARCHAR(64) NOT NULL,
924+ local_contact VARCHAR(128) NOT NULL,
925+ CONSTRAINT active_watchers_active_watchers_idx UNIQUE (presentity_uri, callid, to_tag, from_tag)
926+);
927+
928+INSERT INTO version (table_name, table_version) values ('watchers','3');
929+CREATE TABLE watchers (
930+ id INTEGER PRIMARY KEY NOT NULL,
931+ presentity_uri VARCHAR(128) NOT NULL,
932+ watcher_username VARCHAR(64) NOT NULL,
933+ watcher_domain VARCHAR(64) NOT NULL,
934+ event VARCHAR(64) DEFAULT 'presence' NOT NULL,
935+ status INTEGER NOT NULL,
936+ reason VARCHAR(64),
937+ inserted_time INTEGER NOT NULL,
938+ CONSTRAINT watchers_watcher_idx UNIQUE (presentity_uri, watcher_username, watcher_domain, event)
939+);
940+
941+INSERT INTO version (table_name, table_version) values ('xcap','3');
942+CREATE TABLE xcap (
943+ id INTEGER PRIMARY KEY NOT NULL,
944+ username VARCHAR(64) NOT NULL,
945+ domain VARCHAR(64) NOT NULL,
946+ doc BYTEA NOT NULL,
947+ doc_type INTEGER NOT NULL,
948+ etag VARCHAR(64) NOT NULL,
949+ source INTEGER NOT NULL,
950+ doc_uri VARCHAR(128) NOT NULL,
951+ port INTEGER NOT NULL,
952+ CONSTRAINT xcap_account_doc_type_idx UNIQUE (username, domain, doc_type, doc_uri)
953+);
954+
955+CREATE INDEX xcap_source_idx ON xcap (source);
956+
957+INSERT INTO version (table_name, table_version) values ('pua','6');
958+CREATE TABLE pua (
959+ id INTEGER PRIMARY KEY NOT NULL,
960+ pres_uri VARCHAR(128) NOT NULL,
961+ pres_id VARCHAR(64) NOT NULL,
962+ event INTEGER NOT NULL,
963+ expires INTEGER NOT NULL,
964+ desired_expires INTEGER NOT NULL,
965+ flag INTEGER NOT NULL,
966+ etag VARCHAR(64) NOT NULL,
967+ tuple_id VARCHAR(64),
968+ watcher_uri VARCHAR(128) NOT NULL,
969+ call_id VARCHAR(128) NOT NULL,
970+ to_tag VARCHAR(64) NOT NULL,
971+ from_tag VARCHAR(64) NOT NULL,
972+ cseq INTEGER NOT NULL,
973+ record_route TEXT,
974+ contact VARCHAR(128) NOT NULL,
975+ remote_contact VARCHAR(128) NOT NULL,
976+ version INTEGER NOT NULL,
977+ extra_headers TEXT NOT NULL
978+);
979+
980diff --git a/utils/kamctl/sqlite/purple-create.sql b/utils/kamctl/sqlite/purple-create.sql
981new file mode 100644
982index 0000000..b58c53e
983--- /dev/null
984+++ b/utils/kamctl/sqlite/purple-create.sql
985@@ -0,0 +1,9 @@
986+INSERT INTO version (table_name, table_version) values ('purplemap','1');
987+CREATE TABLE purplemap (
988+ id INTEGER PRIMARY KEY NOT NULL,
989+ sip_user VARCHAR(128) NOT NULL,
990+ ext_user VARCHAR(128) NOT NULL,
991+ ext_prot VARCHAR(16) NOT NULL,
992+ ext_pass VARCHAR(64)
993+);
994+
995diff --git a/utils/kamctl/sqlite/registrar-create.sql b/utils/kamctl/sqlite/registrar-create.sql
996new file mode 100644
997index 0000000..68f2adc
998--- /dev/null
999+++ b/utils/kamctl/sqlite/registrar-create.sql
1000@@ -0,0 +1,22 @@
1001+INSERT INTO version (table_name, table_version) values ('aliases','1004');
1002+CREATE TABLE aliases (
1003+ id INTEGER PRIMARY KEY NOT NULL,
1004+ username VARCHAR(64) DEFAULT '' NOT NULL,
1005+ domain VARCHAR(64) DEFAULT NULL,
1006+ contact VARCHAR(255) DEFAULT '' NOT NULL,
1007+ received VARCHAR(128) DEFAULT NULL,
1008+ path VARCHAR(128) DEFAULT NULL,
1009+ expires TIMESTAMP WITHOUT TIME ZONE DEFAULT '2020-05-28 21:32:15' NOT NULL,
1010+ q REAL DEFAULT 1.0 NOT NULL,
1011+ callid VARCHAR(255) DEFAULT 'Default-Call-ID' NOT NULL,
1012+ cseq INTEGER DEFAULT 13 NOT NULL,
1013+ last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL,
1014+ flags INTEGER DEFAULT 0 NOT NULL,
1015+ cflags INTEGER DEFAULT 0 NOT NULL,
1016+ user_agent VARCHAR(255) DEFAULT '' NOT NULL,
1017+ socket VARCHAR(64) DEFAULT NULL,
1018+ methods INTEGER DEFAULT NULL
1019+);
1020+
1021+CREATE INDEX aliases_alias_idx ON aliases (username, domain, contact);
1022+
1023diff --git a/utils/kamctl/sqlite/rls-create.sql b/utils/kamctl/sqlite/rls-create.sql
1024new file mode 100644
1025index 0000000..b15120d
1026--- /dev/null
1027+++ b/utils/kamctl/sqlite/rls-create.sql
1028@@ -0,0 +1,42 @@
1029+INSERT INTO version (table_name, table_version) values ('rls_presentity','0');
1030+CREATE TABLE rls_presentity (
1031+ id INTEGER PRIMARY KEY NOT NULL,
1032+ rlsubs_did VARCHAR(255) NOT NULL,
1033+ resource_uri VARCHAR(128) NOT NULL,
1034+ content_type VARCHAR(64) NOT NULL,
1035+ presence_state BYTEA NOT NULL,
1036+ expires INTEGER NOT NULL,
1037+ updated INTEGER NOT NULL,
1038+ auth_state INTEGER NOT NULL,
1039+ reason VARCHAR(64) NOT NULL,
1040+ CONSTRAINT rls_presentity_rls_presentity_idx UNIQUE (rlsubs_did, resource_uri)
1041+);
1042+
1043+CREATE INDEX rls_presentity_updated_idx ON rls_presentity (updated);
1044+
1045+INSERT INTO version (table_name, table_version) values ('rls_watchers','1');
1046+CREATE TABLE rls_watchers (
1047+ id INTEGER PRIMARY KEY NOT NULL,
1048+ presentity_uri VARCHAR(128) NOT NULL,
1049+ to_user VARCHAR(64) NOT NULL,
1050+ to_domain VARCHAR(64) NOT NULL,
1051+ watcher_username VARCHAR(64) NOT NULL,
1052+ watcher_domain VARCHAR(64) NOT NULL,
1053+ event VARCHAR(64) DEFAULT 'presence' NOT NULL,
1054+ event_id VARCHAR(64),
1055+ to_tag VARCHAR(64) NOT NULL,
1056+ from_tag VARCHAR(64) NOT NULL,
1057+ callid VARCHAR(64) NOT NULL,
1058+ local_cseq INTEGER NOT NULL,
1059+ remote_cseq INTEGER NOT NULL,
1060+ contact VARCHAR(64) NOT NULL,
1061+ record_route TEXT,
1062+ expires INTEGER NOT NULL,
1063+ status INTEGER DEFAULT 2 NOT NULL,
1064+ reason VARCHAR(64) NOT NULL,
1065+ version INTEGER DEFAULT 0 NOT NULL,
1066+ socket_info VARCHAR(64) NOT NULL,
1067+ local_contact VARCHAR(128) NOT NULL,
1068+ CONSTRAINT rls_watchers_rls_watcher_idx UNIQUE (presentity_uri, callid, to_tag, from_tag)
1069+);
1070+
1071diff --git a/utils/kamctl/sqlite/siptrace-create.sql b/utils/kamctl/sqlite/siptrace-create.sql
1072new file mode 100644
1073index 0000000..a784d0b
1074--- /dev/null
1075+++ b/utils/kamctl/sqlite/siptrace-create.sql
1076@@ -0,0 +1,20 @@
1077+INSERT INTO version (table_name, table_version) values ('sip_trace','2');
1078+CREATE TABLE sip_trace (
1079+ id INTEGER PRIMARY KEY NOT NULL,
1080+ time_stamp TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL,
1081+ callid VARCHAR(255) DEFAULT '' NOT NULL,
1082+ traced_user VARCHAR(128) DEFAULT '' NOT NULL,
1083+ msg TEXT NOT NULL,
1084+ method VARCHAR(50) DEFAULT '' NOT NULL,
1085+ status VARCHAR(128) DEFAULT '' NOT NULL,
1086+ fromip VARCHAR(50) DEFAULT '' NOT NULL,
1087+ toip VARCHAR(50) DEFAULT '' NOT NULL,
1088+ fromtag VARCHAR(64) DEFAULT '' NOT NULL,
1089+ direction VARCHAR(4) DEFAULT '' NOT NULL
1090+);
1091+
1092+CREATE INDEX sip_trace_traced_user_idx ON sip_trace (traced_user);
1093+CREATE INDEX sip_trace_date_idx ON sip_trace (time_stamp);
1094+CREATE INDEX sip_trace_fromip_idx ON sip_trace (fromip);
1095+CREATE INDEX sip_trace_callid_idx ON sip_trace (callid);
1096+
1097diff --git a/utils/kamctl/sqlite/speeddial-create.sql b/utils/kamctl/sqlite/speeddial-create.sql
1098new file mode 100644
1099index 0000000..64e1ae6
1100--- /dev/null
1101+++ b/utils/kamctl/sqlite/speeddial-create.sql
1102@@ -0,0 +1,14 @@
1103+INSERT INTO version (table_name, table_version) values ('speed_dial','2');
1104+CREATE TABLE speed_dial (
1105+ id INTEGER PRIMARY KEY NOT NULL,
1106+ username VARCHAR(64) DEFAULT '' NOT NULL,
1107+ domain VARCHAR(64) DEFAULT '' NOT NULL,
1108+ sd_username VARCHAR(64) DEFAULT '' NOT NULL,
1109+ sd_domain VARCHAR(64) DEFAULT '' NOT NULL,
1110+ new_uri VARCHAR(128) DEFAULT '' NOT NULL,
1111+ fname VARCHAR(64) DEFAULT '' NOT NULL,
1112+ lname VARCHAR(64) DEFAULT '' NOT NULL,
1113+ description VARCHAR(64) DEFAULT '' NOT NULL,
1114+ CONSTRAINT speed_dial_speed_dial_idx UNIQUE (username, domain, sd_domain, sd_username)
1115+);
1116+
1117diff --git a/utils/kamctl/sqlite/standard-create.sql b/utils/kamctl/sqlite/standard-create.sql
1118new file mode 100644
1119index 0000000..0add99d
1120--- /dev/null
1121+++ b/utils/kamctl/sqlite/standard-create.sql
1122@@ -0,0 +1,5 @@
1123+CREATE TABLE version (
1124+ table_name VARCHAR(32) NOT NULL,
1125+ table_version INTEGER DEFAULT 0 NOT NULL
1126+);
1127+
1128diff --git a/utils/kamctl/sqlite/uac-create.sql b/utils/kamctl/sqlite/uac-create.sql
1129new file mode 100644
1130index 0000000..f0cf80d
1131--- /dev/null
1132+++ b/utils/kamctl/sqlite/uac-create.sql
1133@@ -0,0 +1,16 @@
1134+INSERT INTO version (table_name, table_version) values ('uacreg','1');
1135+CREATE TABLE uacreg (
1136+ id INTEGER PRIMARY KEY NOT NULL,
1137+ l_uuid VARCHAR(64) DEFAULT '' NOT NULL,
1138+ l_username VARCHAR(64) DEFAULT '' NOT NULL,
1139+ l_domain VARCHAR(128) DEFAULT '' NOT NULL,
1140+ r_username VARCHAR(64) DEFAULT '' NOT NULL,
1141+ r_domain VARCHAR(128) DEFAULT '' NOT NULL,
1142+ realm VARCHAR(64) DEFAULT '' NOT NULL,
1143+ auth_username VARCHAR(64) DEFAULT '' NOT NULL,
1144+ auth_password VARCHAR(64) DEFAULT '' NOT NULL,
1145+ auth_proxy VARCHAR(64) DEFAULT '' NOT NULL,
1146+ expires INTEGER DEFAULT 0 NOT NULL,
1147+ CONSTRAINT uacreg_l_uuid_idx UNIQUE (l_uuid)
1148+);
1149+
1150diff --git a/utils/kamctl/sqlite/uri_db-create.sql b/utils/kamctl/sqlite/uri_db-create.sql
1151new file mode 100644
1152index 0000000..8e291fc
1153--- /dev/null
1154+++ b/utils/kamctl/sqlite/uri_db-create.sql
1155@@ -0,0 +1,10 @@
1156+INSERT INTO version (table_name, table_version) values ('uri','1');
1157+CREATE TABLE uri (
1158+ id INTEGER PRIMARY KEY NOT NULL,
1159+ username VARCHAR(64) DEFAULT '' NOT NULL,
1160+ domain VARCHAR(64) DEFAULT '' NOT NULL,
1161+ uri_user VARCHAR(64) DEFAULT '' NOT NULL,
1162+ last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL,
1163+ CONSTRAINT uri_account_idx UNIQUE (username, domain, uri_user)
1164+);
1165+
1166diff --git a/utils/kamctl/sqlite/userblacklist-create.sql b/utils/kamctl/sqlite/userblacklist-create.sql
1167new file mode 100644
1168index 0000000..34d9eb1
1169--- /dev/null
1170+++ b/utils/kamctl/sqlite/userblacklist-create.sql
1171@@ -0,0 +1,21 @@
1172+INSERT INTO version (table_name, table_version) values ('userblacklist','1');
1173+CREATE TABLE userblacklist (
1174+ id INTEGER PRIMARY KEY NOT NULL,
1175+ username VARCHAR(64) DEFAULT '' NOT NULL,
1176+ domain VARCHAR(64) DEFAULT '' NOT NULL,
1177+ prefix VARCHAR(64) DEFAULT '' NOT NULL,
1178+ whitelist SMALLINT DEFAULT 0 NOT NULL
1179+);
1180+
1181+CREATE INDEX userblacklist_userblacklist_idx ON userblacklist (username, domain, prefix);
1182+
1183+INSERT INTO version (table_name, table_version) values ('globalblacklist','1');
1184+CREATE TABLE globalblacklist (
1185+ id INTEGER PRIMARY KEY NOT NULL,
1186+ prefix VARCHAR(64) DEFAULT '' NOT NULL,
1187+ whitelist SMALLINT DEFAULT 0 NOT NULL,
1188+ description VARCHAR(255) DEFAULT NULL
1189+);
1190+
1191+CREATE INDEX globalblacklist_globalblacklist_idx ON globalblacklist (prefix);
1192+
1193diff --git a/utils/kamctl/sqlite/usrloc-create.sql b/utils/kamctl/sqlite/usrloc-create.sql
1194new file mode 100644
1195index 0000000..6eb7d07
1196--- /dev/null
1197+++ b/utils/kamctl/sqlite/usrloc-create.sql
1198@@ -0,0 +1,22 @@
1199+INSERT INTO version (table_name, table_version) values ('location','1004');
1200+CREATE TABLE location (
1201+ id INTEGER PRIMARY KEY NOT NULL,
1202+ username VARCHAR(64) DEFAULT '' NOT NULL,
1203+ domain VARCHAR(64) DEFAULT NULL,
1204+ contact VARCHAR(255) DEFAULT '' NOT NULL,
1205+ received VARCHAR(128) DEFAULT NULL,
1206+ path VARCHAR(128) DEFAULT NULL,
1207+ expires TIMESTAMP WITHOUT TIME ZONE DEFAULT '2020-05-28 21:32:15' NOT NULL,
1208+ q REAL DEFAULT 1.0 NOT NULL,
1209+ callid VARCHAR(255) DEFAULT 'Default-Call-ID' NOT NULL,
1210+ cseq INTEGER DEFAULT 13 NOT NULL,
1211+ last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL,
1212+ flags INTEGER DEFAULT 0 NOT NULL,
1213+ cflags INTEGER DEFAULT 0 NOT NULL,
1214+ user_agent VARCHAR(255) DEFAULT '' NOT NULL,
1215+ socket VARCHAR(64) DEFAULT NULL,
1216+ methods INTEGER DEFAULT NULL
1217+);
1218+
1219+CREATE INDEX location_account_contact_idx ON location (username, domain, contact);
1220+
1221--
12221.7.4.5
1223
diff --git a/main/kamailio/APKBUILD b/main/kamailio/APKBUILD
index 9933495068..b97dd43f2a 100644
--- a/main/kamailio/APKBUILD
+++ b/main/kamailio/APKBUILD
@@ -1,9 +1,9 @@
1# Contributor: Michael Mason <ms13sp@gmail.com> 1# Contributor: Michael Mason <ms13sp@gmail.com>
2# Maintainer: Natanael Copa <ncopa@alpinelinux.org> 2# Maintainer: Nathan Angelacos <nangel@alpinelinux.org>
3pkgname=kamailio 3pkgname=kamailio
4pkgver=3.1.4 4pkgver=3.2.0
5pkgrel=1 5pkgrel=0
6pkgdesc="Open Source SIP Server" 6pkgdesc="Open Source SIP Proxy"
7url="http://www.kamailio.org/" 7url="http://www.kamailio.org/"
8pkgusers="kamailio" 8pkgusers="kamailio"
9pkggroups="kamailio" 9pkggroups="kamailio"
@@ -12,31 +12,29 @@ license="GPL"
12depends= 12depends=
13arch=all 13arch=all
14makedepends="bison flex expat-dev postgresql-dev pcre-dev mysql-dev 14makedepends="bison flex expat-dev postgresql-dev pcre-dev mysql-dev
15 libxml2-dev curl-dev unixodbc-dev confuse-dev ncurses-dev sqlite-dev" 15 libxml2-dev curl-dev unixodbc-dev confuse-dev ncurses-dev sqlite-dev lua-dev"
16install="$pkgname.pre-install $pkgname.pre-upgrade" 16install="$pkgname.pre-install $pkgname.pre-upgrade"
17subpackages="$pkgname-doc $pkgname-postgres $pkgname-presence $pkgname-pcre 17subpackages="$pkgname-doc $pkgname-postgres $pkgname-presence $pkgname-pcre
18 $pkgname-mediaproxy $pkgname-unixodbc $pkgname-mysql $pkgname-sqlite" 18 $pkgname-mediaproxy $pkgname-unixodbc $pkgname-mysql $pkgname-sqlite $pkgname-lua"
19source="http://www.kamailio.org/pub/kamailio/$pkgver/src/kamailio-${pkgver}_src.tar.gz 19source="http://www.kamailio.org/pub/kamailio/$pkgver/src/kamailio-${pkgver}_src.tar.gz
20 kamailio.cfg 20 kamailio.cfg
21 kamailio.initd 21 kamailio.initd
22 kamailio-3.1-backslash.patch
23 sqlite.patch
24 0001-utils-add-sqlite-support-to-kamctl-kamdbctl.patch
25 0001-utils-Install-the-sqlite-scripts.patch
26 " 22 "
27 23
28_builddir="$srcdir"/$pkgname-$pkgver 24_builddir="$srcdir"/$pkgname-$pkgver
29 25
30 26
31_default="carrierroute xmlrpc tm" 27_default="carrierroute xmlrpc tm"
32_presence="presence presence_xml presence_mwi pua pua_bla pua_mi pua_usrloc pua_xmpp rls xcap_client presence_dialoginfo pua_dialoginfo" 28_presence="presence presence_xml presence_mwi pua pua_bla pua_mi pua_usrloc pua_xmpp rls xcap_client presence_dialoginfo pua_dialoginfo presence_reginfo"
33_pcre="dialplan lcr regex" 29_pcre="dialplan lcr regex"
34_postgres="db_postgres" 30_postgres="db_postgres"
35_mysql="db_mysql" 31_mysql="db_mysql"
36_mediaproxy="mediaproxy" 32_mediaproxy="mediaproxy"
37_odbc="db_unixodbc" 33_odbc="db_unixodbc"
34_sqlite="db_sqlite"
35_lua="app_lua"
38# Makefile does not handle newline 36# Makefile does not handle newline
39_modules="$_default $_postgres $_mediaproxy $_odbc $_presence $_mysql $_pcre" 37_modules="$_default $_postgres $_mediaproxy $_odbc $_presence $_mysql $_pcre $_lua $_sqlite"
40 38
41 39
42prepare() { 40prepare() {
@@ -116,6 +114,11 @@ _mv_mod_k() {
116} 114}
117 115
118 116
117lua() {
118 pkgdesc="Lua script support for kamailio"
119 _mv_mod app_lua
120}
121
119mysql() { 122mysql() {
120 pkgdesc="MySQL support for kamailio" 123 pkgdesc="MySQL support for kamailio"
121 depends="kamailio mysql-client" 124 depends="kamailio mysql-client"
@@ -149,7 +152,7 @@ sqlite() {
149 _mv_mod_k db_sqlite || return 1 152 _mv_mod_k db_sqlite || return 1
150 mkdir -p "$subpkgdir"/usr/share/kamailio \ 153 mkdir -p "$subpkgdir"/usr/share/kamailio \
151 "$subpkgdir"/usr/lib/kamailio/kamctl 154 "$subpkgdir"/usr/lib/kamailio/kamctl
152 mv "$pkgdir"/usr/share/kamailio/sqlite \ 155 mv "$pkgdir"/usr/share/kamailio/db_sqlite \
153 "$subpkgdir"/usr/share/kamailio/ || return 1 156 "$subpkgdir"/usr/share/kamailio/ || return 1
154 mv "$pkgdir"/usr/lib/kamailio/kamctl/*.sqlite \ 157 mv "$pkgdir"/usr/lib/kamailio/kamctl/*.sqlite \
155 "$subpkgdir"/usr/lib/kamailio/kamctl/ || return 1 158 "$subpkgdir"/usr/lib/kamailio/kamctl/ || return 1
@@ -178,10 +181,6 @@ unixodbc() {
178 _mv_mod_k $_odbc 181 _mv_mod_k $_odbc
179} 182}
180 183
181md5sums="15124e1f09108b63c6929ca97cdbce9a kamailio-3.1.4_src.tar.gz 184md5sums="d2b452e5ec4927b2ec8decdda5966bd9 kamailio-3.2.0_src.tar.gz
182a3c959ec568c43a905710e7d25cd8c25 kamailio.cfg 185a3c959ec568c43a905710e7d25cd8c25 kamailio.cfg
183c0dc4e13d9e57feb99f016d3ee443c0b kamailio.initd 186c0dc4e13d9e57feb99f016d3ee443c0b kamailio.initd"
1848454687f047f703c5cb443db3a0003a8 kamailio-3.1-backslash.patch
185199df21eaa4856dcacdcc438f72765f1 sqlite.patch
1869611a1246bc522cbfa5d8d99b3a55ac8 0001-utils-add-sqlite-support-to-kamctl-kamdbctl.patch
1878751c968e57d7c1bd7342d83d5a8d48d 0001-utils-Install-the-sqlite-scripts.patch"
diff --git a/main/kamailio/kamailio-3.1-backslash.patch b/main/kamailio/kamailio-3.1-backslash.patch
deleted file mode 100644
index 85e0f3fbf0..0000000000
--- a/main/kamailio/kamailio-3.1-backslash.patch
+++ /dev/null
@@ -1,44 +0,0 @@
1diff --git a/utils/kamctl/kamdbctl.base b/utils/kamctl/kamdbctl.base
2index acc7d4a..3a50270 100644
3--- a/utils/kamctl/kamdbctl.base
4+++ b/utils/kamctl/kamdbctl.base
5@@ -32,14 +32,14 @@ INSTALL_PRESENCE_TABLES=${INSTALL_PRESENCE_TABLES:-ask}
6
7 # Used by dbtext and db_berkeley to define tables to be created, used by
8 # postgres to do the grants
9-STANDARD_TABLES=${STANDARD_TABLES:-version acc dbaliases domain grp
10- uri speed_dial lcr_gw lcr_rule lcr_rule_target pdt subscriber
11- location re_grp trusted address missed_calls usr_preferences
12+STANDARD_TABLES=${STANDARD_TABLES:-version acc dbaliases domain grp \
13+ uri speed_dial lcr_gw lcr_rule lcr_rule_target pdt subscriber \
14+ location re_grp trusted address missed_calls usr_preferences \
15 aliases silo dialog dispatcher dialplan}
16-EXTRA_TABLES=${EXTRA_TABLES:-imc_members imc_rooms cpl sip_trace domainpolicy
17- carrierroute carrier_name domain_name carrierfailureroute userblacklist
18+EXTRA_TABLES=${EXTRA_TABLES:-imc_members imc_rooms cpl sip_trace domainpolicy \
19+ carrierroute carrier_name domain_name carrierfailureroute userblacklist \
20 globalblacklist htable purplemap uacreg}
21-PRESENCE_TABLES=${PRESENCE_TABLES:-presentity active_watchers watchers xcap
22+PRESENCE_TABLES=${PRESENCE_TABLES:-presentity active_watchers watchers xcap \
23 pua rls_presentity rls_watchers}
24
25 # SQL definitions
26@@ -62,11 +62,11 @@ GREP=${GREP:-grep}
27 SED=${SED:-sed}
28
29 # define what modules should be installed
30-STANDARD_MODULES=${STANDARD_MODULES:-standard acc lcr domain group permissions
31- registrar usrloc msilo alias_db uri_db
32- speeddial avpops auth_db pdt dialog dispatcher
33+STANDARD_MODULES=${STANDARD_MODULES:-standard acc lcr domain group permissions \
34+ registrar usrloc msilo alias_db uri_db \
35+ speeddial avpops auth_db pdt dialog dispatcher \
36 dialplan}
37-EXTRA_MODULES=${EXTRA_MODULES:-imc cpl siptrace domainpolicy carrierroute
38+EXTRA_MODULES=${EXTRA_MODULES:-imc cpl siptrace domainpolicy carrierroute \
39 userblacklist htable purple uac}
40
41 ############################################################
42--
431.7.1
44
diff --git a/main/kamailio/sqlite.patch b/main/kamailio/sqlite.patch
deleted file mode 100644
index 38cae2ec90..0000000000
--- a/main/kamailio/sqlite.patch
+++ /dev/null
@@ -1,712 +0,0 @@
1Index: kamailio-3.1.1/modules_k/db_sqlite/Makefile
2===================================================================
3--- /dev/null 1970-01-01 00:00:00.000000000 +0000
4+++ kamailio-3.1.1/modules_k/db_sqlite/Makefile 2011-01-05 14:19:03.000000000 +0200
5@@ -0,0 +1,15 @@
6+# $Id$
7+#
8+# WARNING: do not run this directly, it should be run by the master Makefile
9+
10+include ../../Makefile.defs
11+auto_gen=
12+NAME=db_sqlite.so
13+
14+LIBS +=-lsqlite3
15+
16+DEFS+=-DOPENSER_MOD_INTERFACE
17+
18+SERLIBPATH=../../lib
19+SER_LIBS+=$(SERLIBPATH)/srdb1/srdb1
20+include ../../Makefile.modules
21Index: kamailio-3.1.1/modules_k/db_sqlite/db_sqlite.c
22===================================================================
23--- /dev/null 1970-01-01 00:00:00.000000000 +0000
24+++ kamailio-3.1.1/modules_k/db_sqlite/db_sqlite.c 2011-01-05 14:21:13.000000000 +0200
25@@ -0,0 +1,90 @@
26+/*
27+ * $Id$
28+ *
29+ * SQlite module interface
30+ *
31+ * Copyright (C) 2010 Timo Teräs
32+ *
33+ * This file is part of Kamailio, a free SIP server.
34+ *
35+ * Kamailio is free software; you can redistribute it and/or modify
36+ * it under the terms of the GNU General Public License as published by
37+ * the Free Software Foundation; either version 2 of the License, or
38+ * (at your option) any later version
39+ *
40+ * Kamailio is distributed in the hope that it will be useful,
41+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
42+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43+ * GNU General Public License for more details.
44+ *
45+ * You should have received a copy of the GNU General Public License
46+ * along with this program; if not, write to the Free Software
47+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
48+ */
49+
50+#include <sys/time.h>
51+#include <sqlite3.h>
52+
53+#include "../../sr_module.h"
54+#include "../../lib/srdb1/db.h"
55+#include "dbase.h"
56+
57+MODULE_VERSION
58+
59+static int sqlite_bind_api(db_func_t *dbb)
60+{
61+ if(dbb==NULL)
62+ return -1;
63+
64+ memset(dbb, 0, sizeof(db_func_t));
65+
66+ dbb->use_table = db_sqlite_use_table;
67+ dbb->init = db_sqlite_init;
68+ dbb->close = db_sqlite_close;
69+ dbb->free_result = db_sqlite_free_result;
70+ dbb->query = db_sqlite_query;
71+ dbb->insert = db_sqlite_insert;
72+ dbb->delete = db_sqlite_delete;
73+ dbb->update = db_sqlite_update;
74+ dbb->raw_query = db_sqlite_raw_query;
75+
76+ return 0;
77+}
78+
79+static cmd_export_t cmds[] = {
80+ {"db_bind_api", (cmd_function)sqlite_bind_api, 0, 0, 0, 0},
81+ {0, 0, 0, 0, 0, 0}
82+};
83+
84+static int sqlite_mod_init(void)
85+{
86+ sqlite3_initialize();
87+
88+ LM_INFO("SQlite library version %s (compiled using %s)\n",
89+ sqlite3_libversion(),
90+ SQLITE_VERSION);
91+ return 0;
92+}
93+
94+
95+static void sqlite_mod_destroy(void)
96+{
97+ LM_INFO("SQlite terminate\n");
98+
99+ sqlite3_shutdown();
100+}
101+
102+struct module_exports exports = {
103+ "db_sqlite",
104+ DEFAULT_DLFLAGS, /* dlopen flags */
105+ cmds, /* module commands */
106+ 0, /* module parameters */
107+ 0, /* exported statistics */
108+ 0, /* exported MI functions */
109+ 0, /* exported pseudo-variables */
110+ 0, /* extra processes */
111+ sqlite_mod_init, /* module initialization function */
112+ 0, /* response function*/
113+ sqlite_mod_destroy, /* destroy function */
114+ 0 /* per-child init function */
115+};
116Index: kamailio-3.1.1/modules_k/db_sqlite/dbase.c
117===================================================================
118--- /dev/null 1970-01-01 00:00:00.000000000 +0000
119+++ kamailio-3.1.1/modules_k/db_sqlite/dbase.c 2011-01-05 14:20:47.000000000 +0200
120@@ -0,0 +1,515 @@
121+/*
122+ * $Id$
123+ *
124+ * SQlite module core functions
125+ *
126+ * Copyright (C) 2010 Timo Teräs
127+ *
128+ * This file is part of Kamailio, a free SIP server.
129+ *
130+ * Kamailio is free software; you can redistribute it and/or modify
131+ * it under the terms of the GNU General Public License as published by
132+ * the Free Software Foundation; either version 2 of the License, or
133+ * (at your option) any later version
134+ *
135+ * Kamailio is distributed in the hope that it will be useful,
136+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
137+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
138+ * GNU General Public License for more details.
139+ *
140+ * You should have received a copy of the GNU General Public License
141+ * along with this program; if not, write to the Free Software
142+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
143+ */
144+
145+#include "../../mem/mem.h"
146+#include "../../dprint.h"
147+#include "../../lib/srdb1/db_pool.h"
148+#include "../../lib/srdb1/db_ut.h"
149+#include "../../lib/srdb1/db_res.h"
150+#include "../../lib/srdb1/db_query.h"
151+#include "dbase.h"
152+
153+static time_t sqlite_to_timet(double rT)
154+{
155+ return 86400.0*(rT - 2440587.5) + 0.5;
156+}
157+
158+static double timet_to_sqlite(time_t t)
159+{
160+ return ((((double) t) - 0.5) / 86400.0) + 2440587.5;
161+}
162+
163+/*
164+ * Initialize database module
165+ * No function should be called before this
166+ */
167+
168+static struct sqlite_connection * db_sqlite_new_connection(const struct db_id* id)
169+{
170+ struct sqlite_connection *con;
171+ int rc;
172+
173+ con = pkg_malloc(sizeof(*con));
174+ if (!con) {
175+ LM_ERR("failed to allocate driver connection\n");
176+ return NULL;
177+ }
178+
179+ memset(con, 0, sizeof(*con));
180+ con->hdr.ref = 1;
181+ con->hdr.id = (struct db_id*) id; /* set here - freed on error */
182+
183+ rc = sqlite3_open_v2(id->database, &con->conn,
184+ SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
185+ if (rc != SQLITE_OK) {
186+ pkg_free(con);
187+ LM_ERR("failed to open sqlite database '%s'\n", id->database);
188+ return NULL;
189+ }
190+
191+ return con;
192+}
193+
194+db1_con_t* db_sqlite_init(const str* _url)
195+{
196+ return db_do_init(_url, (void *) db_sqlite_new_connection);
197+}
198+
199+
200+/*
201+ * Shut down database module
202+ * No function should be called after this
203+ */
204+
205+static void db_sqlite_free_connection(struct sqlite_connection* con)
206+{
207+ if (!con) return;
208+
209+ sqlite3_close(con->conn);
210+ free_db_id(con->hdr.id);
211+ pkg_free(con);
212+}
213+
214+void db_sqlite_close(db1_con_t* _h)
215+{
216+ db_do_close(_h, db_sqlite_free_connection);
217+}
218+
219+/*
220+ * Release a result set from memory
221+ */
222+int db_sqlite_free_result(db1_con_t* _h, db1_res_t* _r)
223+{
224+ if (!_h || !_r) {
225+ LM_ERR("invalid parameter value\n");
226+ return -1;
227+ }
228+
229+ if (db_free_result(_r) < 0)
230+ {
231+ LM_ERR("failed to free result structure\n");
232+ return -1;
233+ }
234+ return 0;
235+}
236+
237+/*
238+ * Store name of table that will be used by
239+ * subsequent database functions
240+ */
241+int db_sqlite_use_table(db1_con_t* _h, const str* _t)
242+{
243+ return db_use_table(_h, _t);
244+}
245+
246+/*
247+ * Reset query context
248+ */
249+static void db_sqlite_cleanup_query(const db1_con_t* _c)
250+{
251+ struct sqlite_connection *conn = CON_SQLITE(_c);
252+ int rc;
253+
254+ if (conn->stmt != NULL) {
255+ rc = sqlite3_finalize(conn->stmt);
256+ if (rc != SQLITE_OK)
257+ LM_ERR("finalize failed: %s\n",
258+ sqlite3_errmsg(conn->conn));
259+ }
260+
261+ conn->stmt = NULL;
262+ conn->bindpos = 0;
263+}
264+
265+/*
266+ * Convert value to sql-string as db bind index
267+ */
268+static int db_sqlite_val2str(const db1_con_t* _c, const db_val_t* _v, char* _s, int* _len)
269+{
270+ struct sqlite_connection *conn;
271+ int ret;
272+
273+ if (!_c || !_v || !_s || !_len || *_len <= 0) {
274+ LM_ERR("invalid parameter value\n");
275+ return -1;
276+ }
277+
278+ conn = CON_SQLITE(_c);
279+ if (conn->bindpos >= DB_SQLITE_MAX_BINDS) {
280+ LM_ERR("too many bindings, recompile with larger DB_SQLITE_MAX_BINDS\n");
281+ return -2;
282+ }
283+
284+ conn->bindarg[conn->bindpos] = _v;
285+ ret = snprintf(_s, *_len, "?%u", ++conn->bindpos);
286+ if ((unsigned)ret >= (unsigned) *_len)
287+ return -11;
288+
289+ *_len = ret;
290+ return 0;
291+}
292+
293+/*
294+ * Send an SQL query to the server
295+ */
296+static int db_sqlite_submit_query(const db1_con_t* _h, const str* _s)
297+{
298+ struct sqlite_connection *conn = CON_SQLITE(_h);
299+ sqlite3_stmt *stmt;
300+ const db_val_t *val;
301+ int rc, i;
302+
303+ LM_DBG("submit_query: %.*s\n", _s->len, _s->s);
304+
305+ rc = sqlite3_prepare_v2(conn->conn, _s->s, _s->len, &stmt, NULL);
306+ if (rc != SQLITE_OK) {
307+ LM_ERR("failed to prepare statement: %s\n",
308+ sqlite3_errmsg(conn->conn));
309+ return -1;
310+ }
311+ conn->stmt = stmt;
312+
313+ for (i = 1; i <= conn->bindpos; i++) {
314+ val = conn->bindarg[i-1];
315+ if (VAL_NULL(val)) {
316+ rc = sqlite3_bind_null(stmt, i);
317+ } else switch (VAL_TYPE(val)) {
318+ case DB1_INT:
319+ rc = sqlite3_bind_int(stmt, i, VAL_INT(val));
320+ break;
321+ case DB1_BIGINT:
322+ rc = sqlite3_bind_int64(stmt, i, VAL_BIGINT(val));
323+ break;
324+ case DB1_DOUBLE:
325+ rc = sqlite3_bind_double(stmt, i, VAL_DOUBLE(val));
326+ break;
327+ case DB1_STRING:
328+ rc = sqlite3_bind_text(stmt, i,
329+ VAL_STRING(val), -1, NULL);
330+ break;
331+ case DB1_STR:
332+ rc = sqlite3_bind_text(stmt, i,
333+ VAL_STR(val).s, VAL_STR(val).len, NULL);
334+ break;
335+ case DB1_DATETIME:
336+ rc = sqlite3_bind_double(stmt, i, timet_to_sqlite(VAL_TIME(val)));
337+ break;
338+ case DB1_BLOB:
339+ rc = sqlite3_bind_blob(stmt, i,
340+ VAL_BLOB(val).s, VAL_BLOB(val).len,
341+ NULL);
342+ break;
343+ case DB1_BITMAP:
344+ rc = sqlite3_bind_int(stmt, i, VAL_BITMAP(val));
345+ break;
346+ default:
347+ LM_ERR("unknown bind value type %d\n", VAL_TYPE(val));
348+ return -1;
349+ }
350+ if (rc != SQLITE_OK) {
351+ LM_ERR("Parameter bind failed: %s\n",
352+ sqlite3_errmsg(conn->conn));
353+ return -1;
354+ }
355+ }
356+
357+ return 0;
358+}
359+
360+static int decltype_to_dbtype(const char *decltype)
361+{
362+ /* SQlite3 has dynamic typing. It does not store the actual
363+ * exact type, instead it uses 'affinity' depending on the
364+ * value. We have to go through the declaration types to see
365+ * what to return. */
366+ if (strstr(decltype, "INT") != NULL ||
367+ strncasecmp(decltype, "SERIAL", 6) == 0)
368+ return DB1_INT;
369+ if (strstr(decltype, "CHAR") != NULL)
370+ return DB1_STRING;
371+ if (strstr(decltype, "TEXT") != NULL)
372+ return DB1_STR;
373+ if (strstr(decltype, "REAL") != NULL ||
374+ strstr(decltype, "FLOA") != NULL ||
375+ strstr(decltype, "DOUB") != NULL)
376+ return DB1_DOUBLE;
377+ if (strstr(decltype, "BLOB") != NULL)
378+ return DB1_BLOB;
379+ if (strncasecmp(decltype, "TIME", 4) == 0 ||
380+ strncasecmp(decltype, "DATE", 4) == 0)
381+ return DB1_DATETIME;
382+
383+ LM_ERR("sqlite decltype '%s' not recognized, defaulting to int",
384+ decltype);
385+ return DB1_INT;
386+}
387+
388+static str* str_dup(const char *_s)
389+{
390+ str *s;
391+ int len = strlen(_s);
392+
393+ s = (str*) pkg_malloc(sizeof(str)+len+1);
394+ s->len = len;
395+ s->s = ((char*)s) + sizeof(str);
396+ memcpy(s->s, _s, len);
397+ s->s[len] = '\0';
398+
399+ return s;
400+}
401+
402+static void str_assign(str* s, const char *_s, int len)
403+{
404+ s->s = (char *) pkg_malloc(len + 1);
405+ s->len = len;
406+ memcpy(s->s, _s, len);
407+ s->s[len] = 0;
408+}
409+
410+/*
411+ * Read database answer and fill the structure
412+ */
413+int db_sqlite_store_result(const db1_con_t* _h, db1_res_t** _r)
414+{
415+ struct sqlite_connection *conn = CON_SQLITE(_h);
416+ db1_res_t *res;
417+ int i, rc, num_rows = 0, num_alloc = 0;
418+ db_row_t *rows = NULL, *row;
419+ db_val_t *val;
420+
421+ res = db_new_result();
422+ if (res == NULL)
423+ goto no_mem;
424+
425+ while (1) {
426+ rc = sqlite3_step(conn->stmt);
427+ if (rc == SQLITE_DONE) {
428+ *_r = res;
429+ return 0;
430+ }
431+ if (rc != SQLITE_ROW) {
432+ LM_INFO("sqlite3_step failed: %s\n", sqlite3_errmsg(conn->conn));
433+ goto err;
434+ }
435+ if (num_rows == 0) {
436+ /* get column types */
437+ rc = sqlite3_column_count(conn->stmt);
438+ if (db_allocate_columns(res, rc) != 0)
439+ goto err;
440+ RES_COL_N(res) = rc;
441+
442+ for (i = 0; i < RES_COL_N(res); i++) {
443+ RES_NAMES(res)[i] = str_dup(sqlite3_column_name(conn->stmt, i));
444+ RES_TYPES(res)[i] = decltype_to_dbtype(sqlite3_column_decltype(conn->stmt, i));
445+ }
446+ }
447+ if (num_rows >= num_alloc) {
448+ if (num_alloc)
449+ num_alloc *= 2;
450+ else
451+ num_alloc = 8;
452+ rows = pkg_realloc(rows, sizeof(db_row_t) * num_alloc);
453+ if (rows == NULL)
454+ goto no_mem;
455+ RES_ROWS(res) = rows;
456+ }
457+
458+ row = &RES_ROWS(res)[num_rows];
459+ num_rows++;
460+ RES_ROW_N(res) = num_rows; /* rows in this result set */
461+ RES_NUM_ROWS(res) = num_rows; /* rows in total */
462+
463+ if (db_allocate_row(res, row) != 0)
464+ goto no_mem;
465+
466+ for (i = 0, val = ROW_VALUES(row); i < RES_COL_N(res); i++, val++) {
467+ VAL_TYPE(val) = RES_TYPES(res)[i];
468+ VAL_NULL(val) = 0;
469+ VAL_FREE(val) = 0;
470+ if (sqlite3_column_type(conn->stmt, i) == SQLITE_NULL) {
471+ VAL_NULL(val) = 1;
472+ } else switch (VAL_TYPE(val)) {
473+ case DB1_INT:
474+ VAL_INT(val) = sqlite3_column_int(conn->stmt, i);
475+ break;
476+ case DB1_BIGINT:
477+ VAL_BIGINT(val) = sqlite3_column_int64(conn->stmt, i);
478+ break;
479+ case DB1_STRING:
480+ /* first field of struct str* is the char* so we can just
481+ * do whatever DB1_STR case does */
482+ case DB1_STR:
483+ str_assign(&VAL_STR(val),
484+ (const char*) sqlite3_column_text(conn->stmt, i),
485+ sqlite3_column_bytes(conn->stmt, i));
486+ VAL_FREE(val) = 1;
487+ break;
488+ case DB1_DOUBLE:
489+ VAL_DOUBLE(val) = sqlite3_column_double(conn->stmt, i);
490+ break;
491+ case DB1_DATETIME:
492+ VAL_TIME(val) = sqlite_to_timet(sqlite3_column_double(conn->stmt, i));
493+ break;
494+ case DB1_BLOB:
495+ str_assign(&VAL_BLOB(val),
496+ (const char*) sqlite3_column_blob(conn->stmt, i),
497+ sqlite3_column_bytes(conn->stmt, i));
498+ VAL_FREE(val) = 1;
499+ break;
500+ default:
501+ LM_ERR("unhandled db-type\n");
502+ goto err;
503+ }
504+ }
505+ }
506+
507+no_mem:
508+ LM_ERR("no private memory left\n");
509+err:
510+ if (res)
511+ db_free_result(res);
512+ return -1;
513+}
514+
515+/*
516+ * Query table for specified rows
517+ * _h: structure representing database connection
518+ * _k: key names
519+ * _op: operators
520+ * _v: values of the keys that must match
521+ * _c: column names to return
522+ * _n: number of key=values pairs to compare
523+ * _nc: number of columns to return
524+ * _o: order by the specified column
525+ */
526+int db_sqlite_query(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op,
527+ const db_val_t* _v, const db_key_t* _c, int _n, int _nc,
528+ const db_key_t _o, db1_res_t** _r)
529+{
530+ int rc;
531+
532+ rc = db_do_query(_h, _k, _op, _v, _c, _n, _nc, _o, _r,
533+ db_sqlite_val2str,
534+ db_sqlite_submit_query,
535+ db_sqlite_store_result);
536+ db_sqlite_cleanup_query(_h);
537+
538+ return rc;
539+}
540+
541+static int db_sqlite_commit(const db1_con_t* _h)
542+{
543+ struct sqlite_connection *conn = CON_SQLITE(_h);
544+ int rc;
545+
546+ rc = sqlite3_step(conn->stmt);
547+ if (rc != SQLITE_DONE && rc != SQLITE_OK) {
548+ LM_ERR("sqlite commit failed: %s\n",
549+ sqlite3_errmsg(conn->conn));
550+ return -1;
551+ }
552+
553+ return 0;
554+}
555+
556+/*
557+ * Insert a row into specified table
558+ * _h: structure representing database connection
559+ * _k: key names
560+ * _v: values of the keys
561+ * _n: number of key=value pairs
562+ */
563+int db_sqlite_insert(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v,
564+ int _n)
565+{
566+ int rc = -1;
567+
568+ rc = db_do_insert(_h, _k, _v, _n,
569+ db_sqlite_val2str,
570+ db_sqlite_submit_query);
571+ if (rc == 0)
572+ rc = db_sqlite_commit(_h);
573+ db_sqlite_cleanup_query(_h);
574+
575+ return rc;
576+}
577+
578+
579+/*
580+ * Delete a row from the specified table
581+ * _h: structure representing database connection
582+ * _k: key names
583+ * _o: operators
584+ * _v: values of the keys that must match
585+ * _n: number of key=value pairs
586+ */
587+int db_sqlite_delete(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
588+ const db_val_t* _v, int _n)
589+{
590+ int rc;
591+
592+ rc = db_do_delete(_h, _k, _o, _v, _n,
593+ db_sqlite_val2str,
594+ db_sqlite_submit_query);
595+ if (rc == 0)
596+ rc = db_sqlite_commit(_h);
597+ db_sqlite_cleanup_query(_h);
598+
599+ return rc;
600+}
601+
602+
603+/*
604+ * Update some rows in the specified table
605+ * _h: structure representing database connection
606+ * _k: key names
607+ * _o: operators
608+ * _v: values of the keys that must match
609+ * _uk: updated columns
610+ * _uv: updated values of the columns
611+ * _n: number of key=value pairs
612+ * _un: number of columns to update
613+ */
614+int db_sqlite_update(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
615+ const db_val_t* _v, const db_key_t* _uk, const db_val_t* _uv,
616+ int _n, int _un)
617+{
618+ int rc;
619+
620+ rc = db_do_update(_h, _k, _o, _v, _uk, _uv, _n, _un,
621+ db_sqlite_val2str,
622+ db_sqlite_submit_query);
623+ if (rc == 0)
624+ rc = db_sqlite_commit(_h);
625+ db_sqlite_cleanup_query(_h);
626+
627+ return rc;
628+}
629+
630+int db_sqlite_raw_query(const db1_con_t* _h, const str* _s, db1_res_t** _r)
631+{
632+ return db_do_raw_query(_h, _s, _r,
633+ db_sqlite_submit_query,
634+ db_sqlite_store_result);
635+}
636Index: kamailio-3.1.1/modules_k/db_sqlite/dbase.h
637===================================================================
638--- /dev/null 1970-01-01 00:00:00.000000000 +0000
639+++ kamailio-3.1.1/modules_k/db_sqlite/dbase.h 2011-01-05 14:20:47.000000000 +0200
640@@ -0,0 +1,72 @@
641+/*
642+ * $Id$
643+ *
644+ * SQlite module core functions
645+ *
646+ * Copyright (C) 2010 Timo Teräs
647+ *
648+ * This file is part of Kamailio, a free SIP server.
649+ *
650+ * Kamailio is free software; you can redistribute it and/or modify
651+ * it under the terms of the GNU General Public License as published by
652+ * the Free Software Foundation; either version 2 of the License, or
653+ * (at your option) any later version
654+ *
655+ * Kamailio is distributed in the hope that it will be useful,
656+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
657+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
658+ * GNU General Public License for more details.
659+ *
660+ * You should have received a copy of the GNU General Public License
661+ * along with this program; if not, write to the Free Software
662+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
663+ */
664+
665+
666+#ifndef DBASE_H
667+#define DBASE_H
668+
669+#include <sqlite3.h>
670+
671+#include "../../lib/srdb1/db_pool.h"
672+#include "../../lib/srdb1/db_con.h"
673+#include "../../lib/srdb1/db_res.h"
674+#include "../../lib/srdb1/db_key.h"
675+#include "../../lib/srdb1/db_op.h"
676+#include "../../lib/srdb1/db_val.h"
677+
678+#define DB_SQLITE_MAX_BINDS 64
679+
680+struct sqlite_connection {
681+ struct pool_con hdr;
682+
683+ sqlite3 *conn;
684+ int bindpos;
685+
686+ sqlite3_stmt *stmt;
687+ const db_val_t *bindarg[DB_SQLITE_MAX_BINDS];
688+};
689+
690+#define CON_SQLITE(db_con) ((struct sqlite_connection *) db_con->tail)
691+
692+db1_con_t* db_sqlite_init(const str* _sqlurl);
693+void db_sqlite_close(db1_con_t* _h);
694+
695+int db_sqlite_free_result(db1_con_t* _h, db1_res_t* _r);
696+
697+int db_sqlite_query(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op,
698+ const db_val_t* _v, const db_key_t* _c, int _n, int _nc,
699+ const db_key_t _o, db1_res_t** _r);
700+int db_sqlite_insert(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v,
701+ int _n);
702+int db_sqlite_delete(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
703+ const db_val_t* _v, int _n);
704+int db_sqlite_update(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
705+ const db_val_t* _v, const db_key_t* _uk, const db_val_t* _uv,
706+ int _n, int _un);
707+int db_sqlite_raw_query(const db1_con_t* _h, const str* _s, db1_res_t** _r);
708+
709+int db_sqlite_use_table(db1_con_t* _h, const str* _t);
710+
711+
712+#endif /* DBASE_H */