Browse code

sqlops: removed ifdefs for WITH_XAVP

Daniel-Constantin Mierla authored on 18/04/2019 12:00:01
Showing 1 changed files
... ...
@@ -72,10 +72,8 @@ int sql_reconnect(sql_con_t *sc);
72 72
 
73 73
 int sql_do_query(sql_con_t *con, str *query, sql_result_t *res);
74 74
 int sql_do_query_async(sql_con_t *con, str *query);
75
-#ifdef WITH_XAVP
76 75
 int sql_do_xquery(sip_msg_t *msg, sql_con_t *con, pv_elem_t *query,
77 76
 		pv_elem_t *res);
78
-#endif
79 77
 int sql_do_pvquery(sip_msg_t *msg, sql_con_t *con, pv_elem_t *query,
80 78
 		pvname_list_t *res);
81 79
 int pv_get_sqlrows(sip_msg_t *msg,  pv_param_t *param,
Browse code

sqlops: option to start even when connecting to db fails

- new parameter connect_mode: 0 (default) - do not start if connecting
to db fails; 1 - start even if connecting to db fails
- started from GH #1706

Daniel-Constantin Mierla authored on 30/11/2018 08:20:30
Showing 1 changed files
... ...
@@ -25,7 +25,6 @@
25 25
  * - Module: \ref sqlops
26 26
  */
27 27
 
28
-		       
29 28
 #ifndef _SQL_API_H_
30 29
 #define _SQL_API_H_
31 30
 
... ...
@@ -68,7 +67,8 @@ typedef struct _sql_con
68 67
 
69 68
 int sql_parse_param(char *val);
70 69
 void sql_destroy(void);
71
-int sql_connect(void);
70
+int sql_connect(int mode);
71
+int sql_reconnect(sql_con_t *sc);
72 72
 
73 73
 int sql_do_query(sql_con_t *con, str *query, sql_result_t *res);
74 74
 int sql_do_query_async(sql_con_t *con, str *query);
Browse code

core, lib, modules: updated include paths for header files

Daniel-Constantin Mierla authored on 07/12/2016 11:07:22
Showing 1 changed files
... ...
@@ -29,9 +29,9 @@
29 29
 #ifndef _SQL_API_H_
30 30
 #define _SQL_API_H_
31 31
 
32
-#include "../../sr_module.h"
32
+#include "../../core/sr_module.h"
33 33
 #include "../../lib/srdb1/db.h"
34
-#include "../../pvar.h"
34
+#include "../../core/pvar.h"
35 35
 
36 36
 typedef struct _sql_col
37 37
 {
Browse code

core, lib, modules: restructured source code tree

- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,148 @@
1
+/**
2
+ * Copyright (C) 2008 Elena-Ramona Modroiu (asipto.com)
3
+ *
4
+ * This file is part of kamailio, a free SIP server.
5
+ *
6
+ * Kamailio is free software; you can redistribute it and/or modify
7
+ * it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation; either version 2 of the License, or
9
+ * (at your option) any later version
10
+ *
11
+ * Kamailio is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19
+ */
20
+
21
+/*! \file
22
+ * \ingroup sqlops
23
+ * \brief Kamailio SQL-operations :: API
24
+ *
25
+ * - Module: \ref sqlops
26
+ */
27
+
28
+		       
29
+#ifndef _SQL_API_H_
30
+#define _SQL_API_H_
31
+
32
+#include "../../sr_module.h"
33
+#include "../../lib/srdb1/db.h"
34
+#include "../../pvar.h"
35
+
36
+typedef struct _sql_col
37
+{
38
+	str name;
39
+    unsigned int colid;
40
+} sql_col_t;
41
+
42
+typedef struct _sql_val
43
+{
44
+	int flags;
45
+	int_str value;
46
+} sql_val_t;
47
+
48
+typedef struct _sql_result
49
+{
50
+	unsigned int resid;
51
+	str name;
52
+	int nrows;
53
+	int ncols;
54
+	sql_col_t *cols;
55
+	sql_val_t **vals;
56
+	struct _sql_result *next;
57
+} sql_result_t;
58
+
59
+typedef struct _sql_con
60
+{
61
+	str name;
62
+	unsigned int conid;
63
+	str db_url;
64
+	db1_con_t  *dbh;
65
+	db_func_t dbf;
66
+	struct _sql_con *next;
67
+} sql_con_t;
68
+
69
+int sql_parse_param(char *val);
70
+void sql_destroy(void);
71
+int sql_connect(void);
72
+
73
+int sql_do_query(sql_con_t *con, str *query, sql_result_t *res);
74
+int sql_do_query_async(sql_con_t *con, str *query);
75
+#ifdef WITH_XAVP
76
+int sql_do_xquery(sip_msg_t *msg, sql_con_t *con, pv_elem_t *query,
77
+		pv_elem_t *res);
78
+#endif
79
+int sql_do_pvquery(sip_msg_t *msg, sql_con_t *con, pv_elem_t *query,
80
+		pvname_list_t *res);
81
+int pv_get_sqlrows(sip_msg_t *msg,  pv_param_t *param,
82
+		pv_value_t *res);
83
+int pv_parse_con_name(pv_spec_p sp, str *in);
84
+
85
+sql_con_t* sql_get_connection(str *name);
86
+sql_result_t* sql_get_result(str *name);
87
+
88
+void sql_reset_result(sql_result_t *res);
89
+
90
+typedef int (*sqlops_do_query_f)(str *scon, str *squery, str *sres);
91
+int sqlops_do_query(str *scon, str *squery, str *sres);
92
+
93
+typedef int (*sqlops_get_value_f)(str *sres, int i, int j, sql_val_t **val);
94
+int sqlops_get_value(str *sres, int i, int j, sql_val_t **val);
95
+
96
+typedef int (*sqlops_is_null_f)(str *sres, int i, int j);
97
+int sqlops_is_null(str *res, int i, int j);
98
+
99
+typedef int (*sqlops_get_column_f)(str *sres, int i, str *col);
100
+int sqlops_get_column(str *sres, int i, str *name);
101
+
102
+typedef int (*sqlops_num_columns_f)(str *sres);
103
+int sqlops_num_columns(str *sres);
104
+
105
+typedef int (*sqlops_num_rows_f)(str *sres);
106
+int sqlops_num_rows(str *sres);
107
+
108
+typedef void (*sqlops_reset_result_f)(str *sres);
109
+void sqlops_reset_result(str *sres);
110
+
111
+typedef int (*sqlops_do_xquery_f)(sip_msg_t *msg, str *scon, str *squery, str *sxavp);
112
+int sqlops_do_xquery(sip_msg_t *msg, str *scon, str *squery, str *sxavp);
113
+
114
+typedef struct sqlops_api {
115
+	sqlops_do_query_f query;
116
+	sqlops_get_value_f value;
117
+	sqlops_is_null_f is_null;
118
+	sqlops_get_column_f column;
119
+	sqlops_reset_result_f reset;
120
+	sqlops_num_rows_f nrows;
121
+	sqlops_num_columns_f ncols;
122
+	sqlops_do_xquery_f xquery;
123
+} sqlops_api_t;
124
+
125
+typedef int (*bind_sqlops_f)(sqlops_api_t* api);
126
+
127
+/**
128
+ * @brief Load the SQLOps API
129
+ */
130
+static inline int sqlops_load_api(sqlops_api_t *sqb)
131
+{
132
+	bind_sqlops_f bindsqlops;
133
+
134
+	bindsqlops = (bind_sqlops_f)find_export("bind_sqlops", 0, 0);
135
+	if ( bindsqlops == 0) {
136
+		LM_ERR("cannot find bind_sqlops\n");
137
+		return -1;
138
+	}
139
+	if (bindsqlops(sqb)==-1)
140
+	{
141
+		LM_ERR("cannot bind sqlops api\n");
142
+		return -1;
143
+	}
144
+	return 0;
145
+}
146
+
147
+
148
+#endif