Browse code

SER 2.0 database api moved to lib/srdb2.

Jan Janak authored on 12/02/2009 13:11:53
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,89 +0,0 @@
1
-/*
2
- * $Id$
3
- *
4
- * Copyright (C) 2001-2003 FhG FOKUS
5
- * Copyright (C) 2006-2007 iptelorg GmbH
6
- *
7
- * This file is part of ser, a free SIP server.
8
- *
9
- * ser is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License as published by
11
- * the Free Software Foundation; either version 2 of the License, or
12
- * (at your option) any later version
13
- *
14
- * For a license to use the ser software under conditions
15
- * other than those described here, or to purchase support for this
16
- * software, please contact iptel.org by e-mail at the following addresses:
17
- *    info@iptel.org
18
- *
19
- * ser is distributed in the hope that it will be useful,
20
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
- * GNU General Public License for more details.
23
- *
24
- * You should have received a copy of the GNU General Public License 
25
- * along with this program; if not, write to the Free Software 
26
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27
- */
28
-
29
-#ifndef _DB_H
30
-#define _DB_H  1
31
-
32
-/**
33
- * \defgroup DB_API Database Abstraction Layer
34
- *
35
- * @{
36
- */
37
-
38
-
39
-#include "db_gen.h"
40
-#include "db_ctx.h"
41
-#include "db_uri.h"
42
-#include "db_cmd.h"
43
-#include "db_res.h"
44
-#include "db_rec.h"
45
-#include "db_fld.h"
46
-
47
-#ifdef __cplusplus
48
-extern "C" {
49
-#endif /* __cplusplus */
50
-
51
-
52
-/*
53
- * Various database flags shared by modules 
54
- */
55
-#define DB_LOAD_SER   (1 << 0)  /* The row should be loaded by SER */
56
-#define DB_DISABLED   (1 << 1)  /* The row is disabled */
57
-#define DB_CANON      (1 << 2)  /* Canonical entry (domain or uri) */
58
-#define DB_IS_TO      (1 << 3)  /* The URI can be used in To */
59
-#define DB_IS_FROM    (1 << 4)  /* The URI can be used in From */
60
-#define DB_FOR_SERWEB (1 << 5)  /* Credentials instance can be used by serweb */
61
-#define DB_PENDING    (1 << 6)
62
-#define DB_DELETED    (1 << 7)
63
-#define DB_CALLER_DELETED (1 << 8) /* Accounting table */
64
-#define DB_CALLEE_DELETED (1 << 9) /* Accounting table */
65
-#define DB_MULTIVALUE     (1 << 10) /* Attr_types table */
66
-#define DB_FILL_ON_REG    (1 << 11) /* Attr_types table */
67
-#define DB_REQUIRED       (1 << 12) /* Attr_types table */
68
-#define DB_DIR            (1 << 13) /* Domain_settings table */
69
-
70
-
71
-struct db_gen;
72
-
73
-
74
-DBLIST_HEAD(_db_root);
75
-
76
-/** \brief The root of all DB API structures
77
- *
78
- *  This is the root linked list of all database
79
- *  structures allocated in SER
80
- */
81
-extern struct _db_root db_root;
82
-
83
-#ifdef __cplusplus
84
-}
85
-#endif /* __cplusplus */
86
-
87
-/** @} */
88
-
89
-#endif /* _DB_H */
Browse code

- the root db structure renamed to avoid conflicts with variables in modules - database flags added

Jan Janak authored on 05/04/2007 11:37:52
Showing 1 changed files
... ...
@@ -48,17 +48,37 @@
48 48
 extern "C" {
49 49
 #endif /* __cplusplus */
50 50
 
51
+
52
+/*
53
+ * Various database flags shared by modules 
54
+ */
55
+#define DB_LOAD_SER   (1 << 0)  /* The row should be loaded by SER */
56
+#define DB_DISABLED   (1 << 1)  /* The row is disabled */
57
+#define DB_CANON      (1 << 2)  /* Canonical entry (domain or uri) */
58
+#define DB_IS_TO      (1 << 3)  /* The URI can be used in To */
59
+#define DB_IS_FROM    (1 << 4)  /* The URI can be used in From */
60
+#define DB_FOR_SERWEB (1 << 5)  /* Credentials instance can be used by serweb */
61
+#define DB_PENDING    (1 << 6)
62
+#define DB_DELETED    (1 << 7)
63
+#define DB_CALLER_DELETED (1 << 8) /* Accounting table */
64
+#define DB_CALLEE_DELETED (1 << 9) /* Accounting table */
65
+#define DB_MULTIVALUE     (1 << 10) /* Attr_types table */
66
+#define DB_FILL_ON_REG    (1 << 11) /* Attr_types table */
67
+#define DB_REQUIRED       (1 << 12) /* Attr_types table */
68
+#define DB_DIR            (1 << 13) /* Domain_settings table */
69
+
70
+
51 71
 struct db_gen;
52 72
 
53 73
 
54
-DBLIST_HEAD(db_root);
74
+DBLIST_HEAD(_db_root);
55 75
 
56 76
 /** \brief The root of all DB API structures
57 77
  *
58 78
  *  This is the root linked list of all database
59 79
  *  structures allocated in SER
60 80
  */
61
-extern struct db_root db;
81
+extern struct _db_root db_root;
62 82
 
63 83
 #ifdef __cplusplus
64 84
 }
Browse code

- doxygen tags fixed - variable names aligned for better readability - gcc warning fixed

Jan Janak authored on 04/04/2007 12:24:18
Showing 1 changed files
... ...
@@ -31,9 +31,7 @@
31 31
 
32 32
 /**
33 33
  * \defgroup DB_API Database Abstraction Layer
34
- * \brief brief description
35 34
  *
36
- * I wonder where this text goes.
37 35
  * @{
38 36
  */
39 37
 
Browse code

- new db api, revision 2.0

Jan Janak authored on 04/04/2007 09:06:43
Showing 1 changed files
... ...
@@ -25,9 +25,19 @@
25 25
  * along with this program; if not, write to the Free Software 
26 26
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27 27
  */
28
+
28 29
 #ifndef _DB_H
29 30
 #define _DB_H  1
30 31
 
32
+/**
33
+ * \defgroup DB_API Database Abstraction Layer
34
+ * \brief brief description
35
+ *
36
+ * I wonder where this text goes.
37
+ * @{
38
+ */
39
+
40
+
31 41
 #include "db_gen.h"
32 42
 #include "db_ctx.h"
33 43
 #include "db_uri.h"
... ...
@@ -42,12 +52,20 @@ extern "C" {
42 52
 
43 53
 struct db_gen;
44 54
 
55
+
45 56
 DBLIST_HEAD(db_root);
46 57
 
58
+/** \brief The root of all DB API structures
59
+ *
60
+ *  This is the root linked list of all database
61
+ *  structures allocated in SER
62
+ */
47 63
 extern struct db_root db;
48 64
 
49 65
 #ifdef __cplusplus
50 66
 }
51 67
 #endif /* __cplusplus */
52 68
 
69
+/** @} */
70
+
53 71
 #endif /* _DB_H */
Browse code

- global db api data

Jan Janak authored on 29/03/2007 11:22:24
Showing 1 changed files
... ...
@@ -1,7 +1,8 @@
1 1
 /*
2 2
  * $Id$
3 3
  *
4
- * Copyright (C) 2001-2003 FhG Fokus
4
+ * Copyright (C) 2001-2003 FhG FOKUS
5
+ * Copyright (C) 2006-2007 iptelorg GmbH
5 6
  *
6 7
  * This file is part of ser, a free SIP server.
7 8
  *
... ...
@@ -24,168 +25,29 @@
24 25
  * along with this program; if not, write to the Free Software 
25 26
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26 27
  */
27
-/*
28
- * History:
29
- * --------
30
- *  2004-06-06  removed db_* macros and global dbf (andrei)
31
- */
32
-
33
-
34
-#ifndef DB_H
35
-#define DB_H
28
+#ifndef _DB_H
29
+#define _DB_H  1
36 30
 
37
-#include "db_key.h"
38
-#include "db_op.h"
39
-#include "db_val.h"
40
-#include "db_con.h"
41
-#include "db_row.h"
31
+#include "db_gen.h"
32
+#include "db_ctx.h"
33
+#include "db_uri.h"
34
+#include "db_cmd.h"
42 35
 #include "db_res.h"
43
-#include "db_cap.h"
44
-
45
-/*
46
- * Various database flags shared by modules 
47
- */
48
-#define DB_LOAD_SER   (1 << 0)  /* The row should be loaded by SER */
49
-#define DB_DISABLED   (1 << 1)  /* The row is disabled */
50
-#define DB_CANON      (1 << 2)  /* Canonical entry (domain or uri) */
51
-#define DB_IS_TO      (1 << 3)  /* The URI can be used in To */
52
-#define DB_IS_FROM    (1 << 4)  /* The URI can be used in From */
53
-#define DB_FOR_SERWEB (1 << 5)  /* Credentials instance can be used by serweb */
54
-#define DB_PENDING    (1 << 6)
55
-#define DB_DELETED    (1 << 7)
56
-#define DB_CALLER_DELETED (1 << 8) /* Accounting table */
57
-#define DB_CALLEE_DELETED (1 << 9) /* Accounting table */
58
-#define DB_MULTIVALUE     (1 << 10) /* Attr_types table */
59
-#define DB_FILL_ON_REG    (1 << 11) /* Attr_types table */
60
-#define DB_REQUIRED       (1 << 12) /* Attr_types table */
61
-#define DB_DIR            (1 << 13) /* Domain_settings table */
36
+#include "db_rec.h"
37
+#include "db_fld.h"
62 38
 
39
+#ifdef __cplusplus
40
+extern "C" {
41
+#endif /* __cplusplus */
63 42
 
64
-/*
65
- * Specify table name that will be used for
66
- * subsequent operations
67
- */
68
-typedef int (*db_use_table_f)(db_con_t* _h, const char* _t);
43
+struct db_gen;
69 44
 
45
+DBLIST_HEAD(db_root);
70 46
 
71
-/*
72
- * Initialize database connection and
73
- * obtain the connection handle
74
- */
75
-typedef db_con_t* (*db_init_f) (const char* _sqlurl);
76
-
77
-
78
-/*
79
- * Close a database connection and free
80
- * all memory used
81
- */
82
-typedef void (*db_close_f) (db_con_t* _h); 
83
-
84
-
85
-/*
86
- * Query table for specified rows
87
- * _h: structure representing database connection
88
- * _k: key names
89
- * _op: conditions
90
- * _v: values of the keys that must match
91
- * _c: column names to return
92
- * _n: nmber of key=values pairs to compare
93
- * _nc: number of columns to return
94
- * _o: order by the specified column
95
- * _r: Result will be stored in this variable
96
- *     NULL if there is no result
97
- */
98
-typedef int (*db_query_f) (db_con_t* _h, db_key_t* _k, 
99
-			   db_op_t* _op, db_val_t* _v, 
100
-			   db_key_t* _c, int _n, int _nc,
101
-			   db_key_t _o, db_res_t** _r);
102
-
103
-
104
-/*
105
- * Raw SQL query, database specific !
106
- */
107
-typedef int (*db_raw_query_f) (db_con_t* _h, char* _s, db_res_t** _r);
108
-
109
-
110
-/*
111
- * Free a result allocated by db_query
112
- * _h: structure representing database connection
113
- * _r: db_res structure
114
- */
115
-typedef int (*db_free_result_f) (db_con_t* _h, db_res_t* _r);
116
-
117
-
118
-/*
119
- * Insert a row into specified table
120
- * _h: structure representing database connection
121
- * _k: key names
122
- * _v: values of the keys
123
- * _n: number of key=value pairs
124
- */
125
-typedef int (*db_insert_f) (db_con_t* _h, db_key_t* _k, db_val_t* _v, int _n);
126
-
127
-
128
-/*
129
- * Delete a row from the specified table
130
- * _h: structure representing database connection
131
- * _k: key names
132
- * _o: operators
133
- * _v: values of the keys that must match
134
- * _n: number of key=value pairs
135
- */
136
-typedef int (*db_delete_f) (db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v, int _n);
137
-
138
-
139
-/*
140
- * Update some rows in the specified table
141
- * _h: structure representing database connection
142
- * _k: key names
143
- * _o: operators
144
- * _v: values of the keys that must match
145
- * _uk: updated columns
146
- * _uv: updated values of the columns
147
- * _n: number of key=value pairs
148
- * _un: number of columns to update
149
- */
150
-typedef int (*db_update_f) (db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v,
151
-			    db_key_t* _uk, db_val_t* _uv, int _n, int _un);
152
-
153
-/*
154
- * Insert a row and replace if one already 
155
- */
156
-typedef int (*db_replace_f) (db_con_t* handle, db_key_t* keys, db_val_t* vals, int n);
157
-
158
-
159
-typedef struct db_func {
160
-	unsigned int     cap;          /* Capability vector of the database transport */
161
-	db_use_table_f   use_table;    /* Specify table name */
162
-	db_init_f        init;         /* Initialize database connection */
163
-	db_close_f       close;        /* Close database connection */
164
-	db_query_f       query;        /* query a table */
165
-	db_raw_query_f   raw_query;    /* Raw query - SQL */
166
-	db_free_result_f free_result;  /* Free a query result */
167
-	db_insert_f      insert;       /* Insert into table */
168
-	db_delete_f      delete;       /* Delete from table */ 
169
-	db_update_f      update;       /* Update table */
170
-	db_replace_f     replace;      /* Replace row in a table */
171
-} db_func_t;
172
-
173
-
174
-
175
-/*
176
- * Bind database module functions
177
- * returns TRUE if everything went OK
178
- * FALSE otherwise
179
- */
180
-int bind_dbmod(char* mod, db_func_t* dbf);
181
-
182
-
183
-/*
184
- * Get the version of the given table. If there is
185
- * no row for the table then the function returns
186
- * version 0. -1 is returned on error.
187
- */
188
-int table_version(db_func_t* dbf, db_con_t* con, const str* table);
47
+extern struct db_root db;
189 48
 
49
+#ifdef __cplusplus
50
+}
51
+#endif /* __cplusplus */
190 52
 
191
-#endif /* DB_H */
53
+#endif /* _DB_H */
Browse code

allocated flags for table attr_types and domain_settings

Karel Kozlik authored on 10/05/2006 14:12:44
Showing 1 changed files
... ...
@@ -55,6 +55,10 @@
55 55
 #define DB_DELETED    (1 << 7)
56 56
 #define DB_CALLER_DELETED (1 << 8) /* Accounting table */
57 57
 #define DB_CALLEE_DELETED (1 << 9) /* Accounting table */
58
+#define DB_MULTIVALUE     (1 << 10) /* Attr_types table */
59
+#define DB_FILL_ON_REG    (1 << 11) /* Attr_types table */
60
+#define DB_REQUIRED       (1 << 12) /* Attr_types table */
61
+#define DB_DIR            (1 << 13) /* Domain_settings table */
58 62
 
59 63
 
60 64
 /*
Browse code

- acc and missed_call table flags

Jan Janak authored on 06/12/2005 15:57:53
Showing 1 changed files
... ...
@@ -53,6 +53,9 @@
53 53
 #define DB_FOR_SERWEB (1 << 5)  /* Credentials instance can be used by serweb */
54 54
 #define DB_PENDING    (1 << 6)
55 55
 #define DB_DELETED    (1 << 7)
56
+#define DB_CALLER_DELETED (1 << 8) /* Accounting table */
57
+#define DB_CALLEE_DELETED (1 << 9) /* Accounting table */
58
+
56 59
 
57 60
 /*
58 61
  * Specify table name that will be used for
Browse code

- pending and deleted flags added

Jan Janak authored on 24/11/2005 15:09:45
Showing 1 changed files
... ...
@@ -51,7 +51,8 @@
51 51
 #define DB_IS_TO      (1 << 3)  /* The URI can be used in To */
52 52
 #define DB_IS_FROM    (1 << 4)  /* The URI can be used in From */
53 53
 #define DB_FOR_SERWEB (1 << 5)  /* Credentials instance can be used by serweb */
54
-
54
+#define DB_PENDING    (1 << 6)
55
+#define DB_DELETED    (1 << 7)
55 56
 
56 57
 /*
57 58
  * Specify table name that will be used for
Browse code

- common flags in database

Jan Janak authored on 19/11/2005 16:55:14
Showing 1 changed files
... ...
@@ -42,6 +42,16 @@
42 42
 #include "db_res.h"
43 43
 #include "db_cap.h"
44 44
 
45
+/*
46
+ * Various database flags shared by modules 
47
+ */
48
+#define DB_LOAD_SER   (1 << 0)  /* The row should be loaded by SER */
49
+#define DB_DISABLED   (1 << 1)  /* The row is disabled */
50
+#define DB_CANON      (1 << 2)  /* Canonical entry (domain or uri) */
51
+#define DB_IS_TO      (1 << 3)  /* The URI can be used in To */
52
+#define DB_IS_FROM    (1 << 4)  /* The URI can be used in From */
53
+#define DB_FOR_SERWEB (1 << 5)  /* Credentials instance can be used by serweb */
54
+
45 55
 
46 56
 /*
47 57
  * Specify table name that will be used for
Browse code

- DB_REPLACE capability added

Jan Janak authored on 28/02/2005 18:52:32
Showing 1 changed files
... ...
@@ -132,6 +132,10 @@ typedef int (*db_delete_f) (db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _
132 132
 typedef int (*db_update_f) (db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v,
133 133
 			    db_key_t* _uk, db_val_t* _uv, int _n, int _un);
134 134
 
135
+/*
136
+ * Insert a row and replace if one already 
137
+ */
138
+typedef int (*db_replace_f) (db_con_t* handle, db_key_t* keys, db_val_t* vals, int n);
135 139
 
136 140
 
137 141
 typedef struct db_func {
... ...
@@ -145,6 +149,7 @@ typedef struct db_func {
145 149
 	db_insert_f      insert;       /* Insert into table */
146 150
 	db_delete_f      delete;       /* Delete from table */ 
147 151
 	db_update_f      update;       /* Update table */
152
+	db_replace_f     replace;      /* Replace row in a table */
148 153
 } db_func_t;
149 154
 
150 155
 
Browse code

- Database capability check in AVP - Typo fixed

Jan Janak authored on 14/09/2004 12:49:29
Showing 1 changed files
... ...
@@ -40,6 +40,7 @@
40 40
 #include "db_con.h"
41 41
 #include "db_row.h"
42 42
 #include "db_res.h"
43
+#include "db_cap.h"
43 44
 
44 45
 
45 46
 /*
Browse code

Database capability vector. It allows database modules to export just a subset of database interface and modules can query the capability of a particular database module.

Jan Janak authored on 14/09/2004 10:38:02
Showing 1 changed files
... ...
@@ -134,6 +134,7 @@ typedef int (*db_update_f) (db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _
134 134
 
135 135
 
136 136
 typedef struct db_func {
137
+	unsigned int     cap;          /* Capability vector of the database transport */
137 138
 	db_use_table_f   use_table;    /* Specify table name */
138 139
 	db_init_f        init;         /* Initialize database connection */
139 140
 	db_close_f       close;        /* Close database connection */
Browse code

- Spelling checked - READMEs updated

Jan Janak authored on 24/08/2004 08:45:09
Showing 1 changed files
... ...
@@ -1,7 +1,7 @@
1 1
 /*
2 2
  * $Id$
3 3
  *
4
- * Copyright (C) 2001-2003 Fhg Fokus
4
+ * Copyright (C) 2001-2003 FhG Fokus
5 5
  *
6 6
  * This file is part of ser, a free SIP server.
7 7
  *
... ...
@@ -135,7 +135,7 @@ typedef int (*db_update_f) (db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _
135 135
 
136 136
 typedef struct db_func {
137 137
 	db_use_table_f   use_table;    /* Specify table name */
138
-	db_init_f        init;         /* Initialize dabase connection */
138
+	db_init_f        init;         /* Initialize database connection */
139 139
 	db_close_f       close;        /* Close database connection */
140 140
 	db_query_f       query;        /* query a table */
141 141
 	db_raw_query_f   raw_query;    /* Raw query - SQL */
Browse code

free_query changed to free_result

Jan Janak authored on 04/08/2004 14:26:24
Showing 1 changed files
... ...
@@ -93,7 +93,7 @@ typedef int (*db_raw_query_f) (db_con_t* _h, char* _s, db_res_t** _r);
93 93
  * _h: structure representing database connection
94 94
  * _r: db_res structure
95 95
  */
96
-typedef int (*db_free_query_f) (db_con_t* _h, db_res_t* _r);
96
+typedef int (*db_free_result_f) (db_con_t* _h, db_res_t* _r);
97 97
 
98 98
 
99 99
 /*
... ...
@@ -134,15 +134,15 @@ typedef int (*db_update_f) (db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _
134 134
 
135 135
 
136 136
 typedef struct db_func {
137
-	db_use_table_f  use_table;   /* Specify table name */
138
-	db_init_f       init;        /* Initialize dabase connection */
139
-	db_close_f      close;       /* Close database connection */
140
-	db_query_f      query;       /* query a table */
141
-	db_raw_query_f  raw_query;   /* Raw query - SQL */
142
-	db_free_query_f free_query;  /* Free a query result */
143
-	db_insert_f     insert;      /* Insert into table */
144
-	db_delete_f     delete;      /* Delete from table */ 
145
-	db_update_f     update;      /* Update table */
137
+	db_use_table_f   use_table;    /* Specify table name */
138
+	db_init_f        init;         /* Initialize dabase connection */
139
+	db_close_f       close;        /* Close database connection */
140
+	db_query_f       query;        /* query a table */
141
+	db_raw_query_f   raw_query;    /* Raw query - SQL */
142
+	db_free_result_f free_result;  /* Free a query result */
143
+	db_insert_f      insert;       /* Insert into table */
144
+	db_delete_f      delete;       /* Delete from table */ 
145
+	db_update_f      update;       /* Update table */
146 146
 } db_func_t;
147 147
 
148 148
 
Browse code

- changed db api: now several db modules can be used simultaneously; all the modules were updated to use the new api - small cleaups, like using static db related variables in modules (were it was possible) - changed version no.

Andrei Pelinescu-Onciul authored on 08/06/2004 10:55:29
Showing 1 changed files
... ...
@@ -24,6 +24,11 @@
24 24
  * along with this program; if not, write to the Free Software 
25 25
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26 26
  */
27
+/*
28
+ * History:
29
+ * --------
30
+ *  2004-06-06  removed db_* macros and global dbf (andrei)
31
+ */
27 32
 
28 33
 
29 34
 #ifndef DB_H
... ...
@@ -141,27 +146,13 @@ typedef struct db_func {
141 146
 } db_func_t;
142 147
 
143 148
 
149
+
144 150
 /*
145 151
  * Bind database module functions
146 152
  * returns TRUE if everything went OK
147 153
  * FALSE otherwise
148 154
  */
149
-
150
-extern db_func_t dbf;
151
-
152
-
153
-#define db_use_table  (dbf.use_table)
154
-#define db_init       (dbf.init)
155
-#define db_close      (dbf.close)
156
-#define db_query      (dbf.query)
157
-#define db_raw_query  (dbf.raw_query)
158
-#define db_free_query (dbf.free_query)
159
-#define db_insert     (dbf.insert)
160
-#define db_delete     (dbf.delete)
161
-#define db_update     (dbf.update)
162
-
163
-
164
-int bind_dbmod(char* mod);
155
+int bind_dbmod(char* mod, db_func_t* dbf);
165 156
 
166 157
 
167 158
 /*
... ...
@@ -169,7 +160,7 @@ int bind_dbmod(char* mod);
169 160
  * no row for the table then the function returns
170 161
  * version 0. -1 is returned on error.
171 162
  */
172
-int table_version(db_con_t* con, const str* table);
163
+int table_version(db_func_t* dbf, db_con_t* con, const str* table);
173 164
 
174 165
 
175 166
 #endif /* DB_H */
Browse code

table_version returns version 0 if there is no row for the given table is found in table "version".

Jan Janak authored on 22/01/2004 22:28:36
Showing 1 changed files
... ...
@@ -165,7 +165,9 @@ int bind_dbmod(char* mod);
165 165
 
166 166
 
167 167
 /*
168
- * Get version of a table
168
+ * Get the version of the given table. If there is
169
+ * no row for the table then the function returns
170
+ * version 0. -1 is returned on error.
169 171
  */
170 172
 int table_version(db_con_t* con, const str* table);
171 173
 
Browse code

- table_version function -- the function returns version of given database table

Jan Janak authored on 28/11/2003 23:47:50
Showing 1 changed files
... ...
@@ -162,6 +162,12 @@ extern db_func_t dbf;
162 162
 
163 163
 
164 164
 int bind_dbmod(char* mod);
165
- 
165
+
166
+
167
+/*
168
+ * Get version of a table
169
+ */
170
+int table_version(db_con_t* con, const str* table);
171
+
166 172
 
167 173
 #endif /* DB_H */
Browse code

- Removed obsolete function declarations

Jan Janak authored on 24/10/2003 20:33:45
Showing 1 changed files
... ...
@@ -128,7 +128,7 @@ typedef int (*db_update_f) (db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _
128 128
 
129 129
 
130 130
 
131
-typedef struct db_func{
131
+typedef struct db_func {
132 132
 	db_use_table_f  use_table;   /* Specify table name */
133 133
 	db_init_f       init;        /* Initialize dabase connection */
134 134
 	db_close_f      close;       /* Close database connection */
... ...
@@ -161,7 +161,7 @@ extern db_func_t dbf;
161 161
 #define db_update     (dbf.update)
162 162
 
163 163
 
164
-int bind_dbmod(void);
164
+int bind_dbmod(char* mod);
165 165
  
166 166
 
167 167
 #endif /* DB_H */
Browse code

db_query, db_delete and db_update now accept additional parameter - operator. New function added - db_raw_query which accepts a raw SQL query and executes it.

Jan Janak authored on 28/11/2002 16:53:03
Showing 1 changed files
... ...
@@ -30,6 +30,7 @@
30 30
 #define DB_H
31 31
 
32 32
 #include "db_key.h"
33
+#include "db_op.h"
33 34
 #include "db_val.h"
34 35
 #include "db_con.h"
35 36
 #include "db_row.h"
... ...
@@ -61,6 +62,7 @@ typedef void (*db_close_f) (db_con_t* _h);
61 62
  * Query table for specified rows
62 63
  * _h: structure representing database connection
63 64
  * _k: key names
65
+ * _op: conditions
64 66
  * _v: values of the keys that must match
65 67
  * _c: column names to return
66 68
  * _n: nmber of key=values pairs to compare
... ...
@@ -70,11 +72,17 @@ typedef void (*db_close_f) (db_con_t* _h);
70 72
  *     NULL if there is no result
71 73
  */
72 74
 typedef int (*db_query_f) (db_con_t* _h, db_key_t* _k, 
73
-			   db_val_t* _v, db_key_t* _c, 
74
-			   int _n, int _nc,
75
+			   db_op_t* _op, db_val_t* _v, 
76
+			   db_key_t* _c, int _n, int _nc,
75 77
 			   db_key_t _o, db_res_t** _r);
76 78
 
77 79
 
80
+/*
81
+ * Raw SQL query, database specific !
82
+ */
83
+typedef int (*db_raw_query_f) (db_con_t* _h, char* _s, db_res_t** _r);
84
+
85
+
78 86
 /*
79 87
  * Free a result allocated by db_query
80 88
  * _h: structure representing database connection
... ...
@@ -97,23 +105,25 @@ typedef int (*db_insert_f) (db_con_t* _h, db_key_t* _k, db_val_t* _v, int _n);
97 105
  * Delete a row from the specified table
98 106
  * _h: structure representing database connection
99 107
  * _k: key names
108
+ * _o: operators
100 109
  * _v: values of the keys that must match
101 110
  * _n: number of key=value pairs
102 111
  */
103
-typedef int (*db_delete_f) (db_con_t* _h, db_key_t* _k, db_val_t* _v, int _n);
112
+typedef int (*db_delete_f) (db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v, int _n);
104 113
 
105 114
 
106 115
 /*
107 116
  * Update some rows in the specified table
108 117
  * _h: structure representing database connection
109 118
  * _k: key names
119
+ * _o: operators
110 120
  * _v: values of the keys that must match
111 121
  * _uk: updated columns
112 122
  * _uv: updated values of the columns
113 123
  * _n: number of key=value pairs
114 124
  * _un: number of columns to update
115 125
  */
116
-typedef int (*db_update_f) (db_con_t* _h, db_key_t* _k, db_val_t* _v,
126
+typedef int (*db_update_f) (db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v,
117 127
 			    db_key_t* _uk, db_val_t* _uv, int _n, int _un);
118 128
 
119 129
 
... ...
@@ -123,6 +133,7 @@ typedef struct db_func{
123 133
 	db_init_f       init;        /* Initialize dabase connection */
124 134
 	db_close_f      close;       /* Close database connection */
125 135
 	db_query_f      query;       /* query a table */
136
+	db_raw_query_f  raw_query;   /* Raw query - SQL */
126 137
 	db_free_query_f free_query;  /* Free a query result */
127 138
 	db_insert_f     insert;      /* Insert into table */
128 139
 	db_delete_f     delete;      /* Delete from table */ 
... ...
@@ -143,6 +154,7 @@ extern db_func_t dbf;
143 154
 #define db_init       (dbf.init)
144 155
 #define db_close      (dbf.close)
145 156
 #define db_query      (dbf.query)
157
+#define db_raw_query  (dbf.raw_query)
146 158
 #define db_free_query (dbf.free_query)
147 159
 #define db_insert     (dbf.insert)
148 160
 #define db_delete     (dbf.delete)
Browse code

GPLization banner introduced to *.[hc] files

Jiri Kuthan authored on 19/09/2002 12:23:52
Showing 1 changed files
... ...
@@ -1,7 +1,31 @@
1 1
 /*
2 2
  * $Id$
3
+ *
4
+ * Copyright (C) 2001-2003 Fhg Fokus
5
+ *
6
+ * This file is part of ser, a free SIP server.
7
+ *
8
+ * ser is free software; you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation; either version 2 of the License, or
11
+ * (at your option) any later version
12
+ *
13
+ * For a license to use the ser software under conditions
14
+ * other than those described here, or to purchase support for this
15
+ * software, please contact iptel.org by e-mail at the following addresses:
16
+ *    info@iptel.org
17
+ *
18
+ * ser is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License 
24
+ * along with this program; if not, write to the Free Software 
25
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
3 26
  */
4 27
 
28
+
5 29
 #ifndef DB_H
6 30
 #define DB_H
7 31
 
Browse code

db_con internals changed a little bit

Jan Janak authored on 12/08/2002 11:23:17
Showing 1 changed files
... ...
@@ -128,4 +128,4 @@ extern db_func_t dbf;
128 128
 int bind_dbmod(void);
129 129
  
130 130
 
131
-#endif
131
+#endif /* DB_H */
Browse code

Header files split

Jan Janak authored on 24/07/2002 14:45:10
Showing 1 changed files
... ...
@@ -2,138 +2,14 @@
2 2
  * $Id$
3 3
  */
4 4
 
5
-#ifndef __DB_H__
6
-#define __DB_H__
5
+#ifndef DB_H
6
+#define DB_H
7 7
 
8
-#include <time.h>
9
-
10
-/*
11
- * Generic database interface
12
- */
13
-
14
-
15
-/* =================== db_key =============== */
16
-
17
-/*
18
- * Type of a database key (column)
19
- */
20
-typedef const char* db_key_t;
21
-
22
-
23
-/* =================== db_val =============== */
24
-
25
-/*
26
- * Accepted column types
27
- */
28
-typedef enum {
29
-	DB_INT,
30
-        DB_DOUBLE,
31
-	DB_STRING,
32
-	DB_DATETIME
33
-} db_type_t;
34
-
35
-
36
-/*
37
- * Column value structure
38
- */
39
-typedef struct {
40
-	db_type_t type;                  /* Type of the value */
41
-	int nul;                         /* Means that the column in database has no value */
42
-	union {
43
-		int          int_val;    /* integer value */
44
-		double       double_val; /* double value */
45
-		time_t       time_val;   /* unix time value */
46
-		const char*  string_val; /* NULL terminated string */
47
-	} val;                           /* union of all possible types */
48
-} db_val_t;
49
-
50
-
51
-/*
52
- * Useful macros for accessing attributes of db_val structure
53
- */
54
-
55
-/* Get value type */
56
-#define VAL_TYPE(dv)   ((dv)->type)
57
-
58
-/* Get null flag (means that value in dabase is null) */
59
-#define VAL_NULL(dv)   ((dv)->nul)
60
-
61
-/* Get integer value */
62
-#define VAL_INT(dv)    ((dv)->val.int_val)
63
-
64
-/* Get double value */
65
-#define VAL_DOUBLE(dv) ((dv)->val.double_val)
66
-
67
-/* Get time_t value */
68
-#define VAL_TIME(dv)   ((dv)->val.time_val)
69
-
70
-/* Get char* value */
71
-#define VAL_STRING(dv) ((dv)->val.string_val)
72
-
73
-
74
-/* ==================== db_con ======================= */
75
-
76
-/*
77
- * This structure represents a database connection
78
- * and pointer to this structure is used as a connection
79
- * handle
80
- */
81
-typedef struct {
82
-	char* table;     /* Default table to use */
83
-	void* con;       /* Mysql Connection */
84
-	void* res;       /* Result of previous operation */
85
-	void* row;       /* Actual row in the result */
86
-	int   connected; /* TRUE if connection is established */
87
-} db_con_t;
88
-
89
-
90
-/* ===================== db_row ====================== */
91
-
92
-/*
93
- * Structure holding result of query_table function (ie. table row)
94
- */
95
-typedef struct db_row {
96
-	db_val_t* values;  /* Columns in the row */
97
-	int n;             /* Number of columns in the row */
98
-} db_row_t;
99
-
100
-/* Useful macros for manipulating db_row structure attributes */
101
-
102
-/* Get row members */
103
-#define ROW_VALUES(rw) ((rw)->values)
104
-
105
-/* Get number of member in the row */
106
-#define ROW_N(rw)      ((rw)->n)
107
-
108
-
109
-/* ===================== db_res ====================== */
110
-
111
-typedef struct db_res {
112
-	struct {
113
-		db_key_t* names;   /* Column names */
114
-		db_type_t* types;  /* Column types */
115
-		int n;             /* Number of columns */
116
-	} col;
117
-	struct db_row* rows;       /* Rows */
118
-	int n;                     /* Number of rows */
119
-} db_res_t;
120
-
121
-/* Useful macros for manipulating db_res attributes */
122
-
123
-/* Column names */
124
-#define RES_NAMES(re) ((re)->col.names)
125
-
126
-/* Column types */
127
-#define RES_TYPES(re) ((re)->col.types)
128
-
129
-/* Number of columns */
130
-#define RES_COL_N(re) ((re)->col.n)
131
-
132
-/* Rows */
133
-#define RES_ROWS(re)  ((re)->rows)
134
-
135
-/* Number of rows */
136
-#define RES_ROW_N(re) ((re)->n)
8
+#include "db_key.h"
9
+#include "db_val.h"
10
+#include "db_con.h"
11
+#include "db_row.h"
12
+#include "db_res.h"
137 13
 
138 14
 
139 15
 /*
... ...
@@ -235,8 +111,6 @@ typedef struct db_func{
235 111
  * returns TRUE if everything went OK
236 112
  * FALSE otherwise
237 113
  */
238
-int bind_dbmod(void);
239
-
240 114
 
241 115
 extern db_func_t dbf;
242 116
 
... ...
@@ -249,5 +123,9 @@ extern db_func_t dbf;
249 123
 #define db_insert     (dbf.insert)
250 124
 #define db_delete     (dbf.delete)
251 125
 #define db_update     (dbf.update)
126
+
127
+
128
+int bind_dbmod(void);
252 129
  
130
+
253 131
 #endif
Browse code

*** empty log message ***

Jan Janak authored on 09/07/2002 09:16:05
Showing 1 changed files
... ...
@@ -1,3 +1,7 @@
1
+/*
2
+ * $Id$