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,242 @@
1
+/*
2
+ * Copyright (C) 2007-2008 1&1 Internet AG
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
+
22
+/**
23
+ * \file lib/srdb1/db_query.h
24
+ * \brief Query helper for database drivers
25
+ * \ingroup db1
26
+ *
27
+ * This helper methods for database queries are used from the database
28
+ * SQL driver to do the actual work. Each function uses some functions from
29
+ * the actual driver with function pointers to the concrete, specific
30
+ * implementation.
31
+*/
32
+
33
+#ifndef DB1_QUERY_H
34
+#define DB1_QUERY_H
35
+
36
+#include "db_key.h"
37
+#include "db_op.h"
38
+#include "db_val.h"
39
+#include "db_con.h"
40
+#include "db_row.h"
41
+#include "db_res.h"
42
+#include "db_cap.h"
43
+
44
+
45
+/**
46
+ * \brief Helper function for db queries
47
+ *
48
+ * This method evaluates the actual arguments for the database query and
49
+ * setups the string that is used for the query in the db module.
50
+ * Then its submit the query and stores the result if necessary. It uses for
51
+ * its work the implementation in the concrete database module.
52
+ *
53
+ * \param _h structure representing database connection
54
+ * \param _k key names, if not present the whole table will be returned
55
+ * \param _op operators
56
+ * \param _v values of the keys that must match
57
+ * \param _c column names that should be returned
58
+ * \param _n number of key/value pairs that are compared, if zero then no comparison is done
59
+ * \param _nc number of colums that should be returned
60
+ * \param _o order by the specificied column, optional
61
+ * \param _r the result that is returned, set to NULL if you want to use fetch_result later
62
+ * \param (*val2str) function pointer to the db specific val conversion function
63
+ * \param (*submit_query) function pointer to the db specific query submit function
64
+ * \param (*store_result) function pointer to the db specific store result function
65
+ * \return zero on success, negative on errors
66
+ */
67
+int db_do_query(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op,
68
+	const db_val_t* _v, const db_key_t* _c, const int _n, const int _nc,
69
+	const db_key_t _o, db1_res_t** _r, int (*val2str) (const db1_con_t*,
70
+	const db_val_t*, char*, int*), int (*submit_query)(const db1_con_t* _h,
71
+	const str* _c), int (*store_result)(const db1_con_t* _h, db1_res_t** _r));
72
+
73
+/**
74
+ * \brief Helper function for db queries with update lock
75
+ *
76
+ * This method evaluates the actual arguments for the database query and
77
+ * setups the string that is used for the query in the db module.
78
+ * Then its submit the query and stores the result if necessary. It uses for
79
+ * its work the implementation in the concrete database module.
80
+ *
81
+ * \param _h structure representing database connection
82
+ * \param _k key names, if not present the whole table will be returned
83
+ * \param _op operators
84
+ * \param _v values of the keys that must match
85
+ * \param _c column names that should be returned
86
+ * \param _n number of key/value pairs that are compared, if zero then no comparison is done
87
+ * \param _nc number of colums that should be returned
88
+ * \param _o order by the specificied column, optional
89
+ * \param _r the result that is returned, set to NULL if you want to use fetch_result later
90
+ * \param (*val2str) function pointer to the db specific val conversion function
91
+ * \param (*submit_query) function pointer to the db specific query submit function
92
+ * \param (*store_result) function pointer to the db specific store result function
93
+ * \return zero on success, negative on errors
94
+ */
95
+int db_do_query_lock(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op,
96
+	const db_val_t* _v, const db_key_t* _c, const int _n, const int _nc,
97
+	const db_key_t _o, db1_res_t** _r, int (*val2str) (const db1_con_t*,
98
+	const db_val_t*, char*, int*), int (*submit_query)(const db1_con_t* _h,
99
+	const str* _c), int (*store_result)(const db1_con_t* _h, db1_res_t** _r));
100
+
101
+/**
102
+ * \brief Helper function for raw db queries
103
+ *
104
+ * This method evaluates the actual arguments for the database raw query
105
+ * and setups the string that is used for the query in the db module.
106
+ * Then its submit the query and stores the result if necessary.
107
+ * It uses for its work the implementation in the concrete database module.
108
+ *
109
+ * \param _h structure representing database connection
110
+ * \param _s char holding the raw query
111
+ * \param _r the result that is returned
112
+ * \param (*submit_query) function pointer to the db specific query submit function
113
+ * \param (*store_result) function pointer to the db specific store result function
114
+ * \return zero on success, negative on errors
115
+ */
116
+int db_do_raw_query(const db1_con_t* _h, const str* _s, db1_res_t** _r,
117
+	int (*submit_query)(const db1_con_t* _h, const str* _c),
118
+	int (*store_result)(const db1_con_t* _h, db1_res_t** _r));
119
+
120
+
121
+/**
122
+ * \brief Helper function for db insert operations
123
+ *
124
+ * This method evaluates the actual arguments for the database operation
125
+ * and setups the string that is used for the insert operation in the db
126
+ * module. Then its submit the query for the operation. It uses for its work
127
+ * the implementation in the concrete database module.
128
+ *
129
+ * \param _h structure representing database connection
130
+ * \param _k key names
131
+ * \param _v values of the keys
132
+ * \param _n number of key/value pairs 
133
+ * \param (*val2str) function pointer to the db specific val conversion function
134
+ * \param (*submit_query) function pointer to the db specific query submit function
135
+ * \return zero on success, negative on errors
136
+ */
137
+int db_do_insert(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v,
138
+	const int _n, int (*val2str) (const db1_con_t*, const db_val_t*, char*, int*),
139
+	int (*submit_query)(const db1_con_t* _h, const str* _c));
140
+
141
+
142
+/**
143
+ * \brief Helper function for db delete operations
144
+ *
145
+ * This method evaluates the actual arguments for the database operation
146
+ * and setups the string that is used for the delete operation in the db
147
+ * module. Then its submit the query for the operation. It uses for its work
148
+ * the implementation in the concrete database module.
149
+ *
150
+ * \param _h structure representing database connection
151
+ * \param _k key names
152
+ * \param _o operators
153
+ * \param _v values of the keys that must match
154
+ * \param _n number of key/value pairs that are compared, if zero then the whole table is deleted
155
+ * \param (*val2str) function pointer to the db specific val conversion function
156
+ * \param (*submit_query) function pointer to the db specific query submit function
157
+ * \return zero on success, negative on errors
158
+ */
159
+int db_do_delete(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
160
+	const db_val_t* _v, const int _n, int (*val2str) (const db1_con_t*,
161
+	const db_val_t*, char*, int*), int (*submit_query)(const db1_con_t* _h,
162
+	const str* _c));
163
+
164
+
165
+/**
166
+ * \brief Helper function for db update operations
167
+ *
168
+ * This method evaluates the actual arguments for the database operation
169
+ * and setups the string that is used for the update operation in the db
170
+ * module. Then its submit the query for the operation. It uses for its work
171
+ * the implementation in the concrete database module.
172
+ *
173
+ * \param _h structure representing database connection
174
+ * \param _k key names, if not present the whole table will be returned
175
+ * \param _o operators
176
+ * \param _v values of the keys that must match
177
+ * \param _uk: updated columns
178
+ * \param _uv: updated values of the columns
179
+ * \param _n number of key/value pairs that are compared, if zero then no comparison is done
180
+ * \param _un: number of columns that should be updated
181
+ * \param (*val2str) function pointer to the db specific val conversion function
182
+ * \param (*submit_query) function pointer to the db specific query submit function
183
+ * \return zero on success, negative on errors
184
+ */
185
+int db_do_update(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
186
+	const db_val_t* _v, const db_key_t* _uk, const db_val_t* _uv, const int _n,
187
+	const int _un, int (*val2str) (const db1_con_t*, const db_val_t*, char*, int*),
188
+	int (*submit_query)(const db1_con_t* _h, const str* _c));
189
+
190
+
191
+/**
192
+ * \brief Helper function for db delete operations
193
+ *
194
+ * This helper method evaluates the actual arguments for the database operation
195
+ * and setups the string that is used for the replace operation in the db
196
+ * module. Then its submit the query for the operation. It uses for its work the
197
+ * implementation in the concrete database module.
198
+ *
199
+ * \param _h structure representing database connection
200
+ * \param _k key names, if not present the whole table will be returned
201
+ * \param _v values of the keys that must match
202
+ * \param _n number of key/value pairs that are compared, if zero then no comparison is done
203
+ * \param (*val2str) function pointer to the db specific val conversion function
204
+ * \param (*submit_query) function pointer to the db specific query submit function
205
+ * \return zero on success, negative on errors
206
+ */
207
+int db_do_replace(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v,
208
+	const int _n, int (*val2str) (const db1_con_t*, const db_val_t*, char*,
209
+	int*), int (*submit_query)(const db1_con_t* _h, const str* _c));
210
+
211
+
212
+/**
213
+ * \brief Helper function for db insert delayed operations
214
+ *
215
+ * This method evaluates the actual arguments for the database operation
216
+ * and setups the string that is used for the insert delayed operation in the db
217
+ * module. Then its submit the query for the operation. It uses for its work
218
+ * the implementation in the concrete database module.
219
+ *
220
+ * \param _h structure representing database connection
221
+ * \param _k key names
222
+ * \param _v values of the keys
223
+ * \param _n number of key/value pairs
224
+ * \param (*val2str) function pointer to the db specific val conversion function
225
+ * \param (*submit_query) function pointer to the db specific query submit function
226
+ * \return zero on success, negative on errors
227
+ */
228
+int db_do_insert_delayed(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v,
229
+	const int _n, int (*val2str) (const db1_con_t*, const db_val_t*, char*, int*),
230
+	int (*submit_query)(const db1_con_t* _h, const str* _c));
231
+
232
+
233
+/**
234
+ * \brief Initialisation function - should be called from db.c at start-up
235
+ *
236
+ * This initialises the db_query module, and should be called before any functions in db_query are called.
237
+ *
238
+ * \return zero on success, negative on errors
239
+ */
240
+int db_query_init(void);
241
+    
242
+#endif