1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,163 +0,0 @@ |
1 |
-/* |
|
2 |
- * $Id$ |
|
3 |
- * |
|
4 |
- * UNIXODBC module |
|
5 |
- * |
|
6 |
- * Copyright (C) 2005-2006 Marco Lorrai |
|
7 |
- * Copyright (C) 2008 1&1 Internet AG |
|
8 |
- * |
|
9 |
- * This file is part of Kamailio, a free SIP server. |
|
10 |
- * |
|
11 |
- * Kamailio is free software; you can redistribute it and/or modify |
|
12 |
- * it under the terms of the GNU General Public License as published by |
|
13 |
- * the Free Software Foundation; either version 2 of the License, or |
|
14 |
- * (at your option) any later version |
|
15 |
- * |
|
16 |
- * Kamailio is distributed in the hope that it will be useful, |
|
17 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19 |
- * GNU General Public License for more details. |
|
20 |
- * |
|
21 |
- * You should have received a copy of the GNU General Public License |
|
22 |
- * along with this program; if not, write to the Free Software |
|
23 |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
24 |
- * |
|
25 |
- * |
|
26 |
- * History: |
|
27 |
- * -------- |
|
28 |
- * 2005-12-01 initial commit (chgen) |
|
29 |
- * 2006-04-04 simplified link list (sgupta) |
|
30 |
- * 2006-05-05 removed static allocation of 1k per column data (sgupta) |
|
31 |
- */ |
|
32 |
- |
|
33 |
-#include "../../dprint.h" |
|
34 |
-#include "../../mem/mem.h" |
|
35 |
-#include "list.h" |
|
36 |
- |
|
37 |
- |
|
38 |
-/*! |
|
39 |
- * \brief Create a list |
|
40 |
- * \param start start of the list |
|
41 |
- * \param link inserted element |
|
42 |
- * \param n number of values |
|
43 |
- * \param value inserted value |
|
44 |
- * \return 0 on success, -1 on failure |
|
45 |
- */ |
|
46 |
-int db_unixodbc_list_insert(list** start, list** link, int n, strn* value) |
|
47 |
-{ |
|
48 |
- int i = 0; |
|
49 |
- |
|
50 |
- if(!(*start)) { |
|
51 |
- *link = (list*)pkg_malloc(sizeof(list)); |
|
52 |
- if(!(*link)) { |
|
53 |
- LM_ERR("no more pkg memory (1)\n"); |
|
54 |
- return -1; |
|
55 |
- } |
|
56 |
- (*link)->rownum = n; |
|
57 |
- (*link)->next = NULL; |
|
58 |
- |
|
59 |
- (*link)->lengths = (unsigned long*)pkg_malloc(sizeof(unsigned long)*n); |
|
60 |
- if(!(*link)->lengths) { |
|
61 |
- LM_ERR("no more pkg memory (2)\n"); |
|
62 |
- pkg_free(*link); |
|
63 |
- *link = NULL; |
|
64 |
- return -1; |
|
65 |
- } |
|
66 |
- for(i=0; i<n; i++) |
|
67 |
- (*link)->lengths[i] = strlen(value[i].s) + 1; |
|
68 |
- |
|
69 |
- (*link)->data = (char**)pkg_malloc(sizeof(char*)*n); |
|
70 |
- if(!(*link)->data) { |
|
71 |
- LM_ERR("no more pkg memory (3)\n"); |
|
72 |
- pkg_free( (*link)->lengths ); |
|
73 |
- pkg_free(*link); |
|
74 |
- *link = NULL; |
|
75 |
- return -1; |
|
76 |
- } |
|
77 |
- |
|
78 |
- for(i=0; i<n; i++) { |
|
79 |
- (*link)->data[i] = pkg_malloc(sizeof(char) * (*link)->lengths[i]); |
|
80 |
- if(!(*link)->data[i]) { |
|
81 |
- LM_ERR("no more pkg memory (4)\n"); |
|
82 |
- pkg_free( (*link)->lengths ); |
|
83 |
- pkg_free( (*link)->data ); |
|
84 |
- pkg_free(*link); |
|
85 |
- *link = NULL; |
|
86 |
- return -1; |
|
87 |
- } |
|
88 |
- strncpy((*link)->data[i], value[i].s, (*link)->lengths[i]); |
|
89 |
- } |
|
90 |
- |
|
91 |
- *start = *link; |
|
92 |
- return 0; |
|
93 |
- } |
|
94 |
- else |
|
95 |
- { |
|
96 |
- list* nlink; |
|
97 |
- nlink=(list*)pkg_malloc(sizeof(list)); |
|
98 |
- if(!nlink) { |
|
99 |
- LM_ERR("no more pkg memory (5)\n"); |
|
100 |
- return -1; |
|
101 |
- } |
|
102 |
- nlink->rownum = n; |
|
103 |
- |
|
104 |
- nlink->lengths = (unsigned long*)pkg_malloc(sizeof(unsigned long)*n); |
|
105 |
- if(!nlink->lengths) { |
|
106 |
- LM_ERR("no more pkg memory (6)\n"); |
|
107 |
- pkg_free(nlink); |
|
108 |
- nlink = NULL; |
|
109 |
- return -1; |
|
110 |
- } |
|
111 |
- for(i=0; i<n; i++) |
|
112 |
- nlink->lengths[i] = strlen(value[i].s) + 1; |
|
113 |
- |
|
114 |
- nlink->data = (char**)pkg_malloc(sizeof(char*)*n); |
|
115 |
- if(!nlink->data) { |
|
116 |
- LM_ERR("no more pkg memory (7)\n"); |
|
117 |
- pkg_free( nlink->lengths ); |
|
118 |
- pkg_free(nlink); |
|
119 |
- nlink = NULL; |
|
120 |
- return -1; |
|
121 |
- } |
|
122 |
- |
|
123 |
- for(i=0; i<n; i++) { |
|
124 |
- nlink->data[i] = pkg_malloc(sizeof(char) * nlink->lengths[i]); |
|
125 |
- if(!nlink->data[i]) { |
|
126 |
- LM_ERR("no more pkg memory (8)\n"); |
|
127 |
- pkg_free( nlink->lengths ); |
|
128 |
- pkg_free( nlink->data ); |
|
129 |
- pkg_free(nlink); |
|
130 |
- nlink = NULL; |
|
131 |
- return -1; |
|
132 |
- } |
|
133 |
- strncpy(nlink->data[i], value[i].s, nlink->lengths[i]); |
|
134 |
- } |
|
135 |
- |
|
136 |
- nlink->next = NULL; |
|
137 |
- (*link)->next = nlink; |
|
138 |
- *link = (*link)->next; |
|
139 |
- |
|
140 |
- return 0; |
|
141 |
- } |
|
142 |
-} |
|
143 |
- |
|
144 |
- |
|
145 |
-/*! |
|
146 |
- * \brief Destroy a list |
|
147 |
- * \param link list element(s) |
|
148 |
- */ |
|
149 |
-void db_unixodbc_list_destroy(list *start) |
|
150 |
-{ |
|
151 |
- int i = 0; |
|
152 |
- |
|
153 |
- while(start) { |
|
154 |
- list* temp = start; |
|
155 |
- start = start->next; |
|
156 |
- for(i = 0; i < temp->rownum; i++) |
|
157 |
- pkg_free( temp->data[i] ); |
|
158 |
- pkg_free(temp->data); |
|
159 |
- pkg_free(temp->lengths); |
|
160 |
- pkg_free(temp); |
|
161 |
- } |
|
162 |
-} |
|
163 |
- |
git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@5422 689a6050-402a-0410-94f2-e92a70836424
... | ... |
@@ -34,6 +34,15 @@ |
34 | 34 |
#include "../../mem/mem.h" |
35 | 35 |
#include "list.h" |
36 | 36 |
|
37 |
+ |
|
38 |
+/*! |
|
39 |
+ * \brief Create a list |
|
40 |
+ * \param start start of the list |
|
41 |
+ * \param link inserted element |
|
42 |
+ * \param n number of values |
|
43 |
+ * \param value inserted value |
|
44 |
+ * \return 0 on success, -1 on failure |
|
45 |
+ */ |
|
37 | 46 |
int db_unixodbc_list_insert(list** start, list** link, int n, strn* value) |
38 | 47 |
{ |
39 | 48 |
int i = 0; |
... | ... |
@@ -133,6 +142,10 @@ int db_unixodbc_list_insert(list** start, list** link, int n, strn* value) |
133 | 142 |
} |
134 | 143 |
|
135 | 144 |
|
145 |
+/*! |
|
146 |
+ * \brief Destroy a list |
|
147 |
+ * \param link list element(s) |
|
148 |
+ */ |
|
136 | 149 |
void db_unixodbc_list_destroy(list *start) |
137 | 150 |
{ |
138 | 151 |
int i = 0; |
git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@4518 689a6050-402a-0410-94f2-e92a70836424
... | ... |
@@ -6,14 +6,14 @@ |
6 | 6 |
* Copyright (C) 2005-2006 Marco Lorrai |
7 | 7 |
* Copyright (C) 2008 1&1 Internet AG |
8 | 8 |
* |
9 |
- * This file is part of openser, a free SIP server. |
|
9 |
+ * This file is part of Kamailio, a free SIP server. |
|
10 | 10 |
* |
11 |
- * openser is free software; you can redistribute it and/or modify |
|
11 |
+ * Kamailio is free software; you can redistribute it and/or modify |
|
12 | 12 |
* it under the terms of the GNU General Public License as published by |
13 | 13 |
* the Free Software Foundation; either version 2 of the License, or |
14 | 14 |
* (at your option) any later version |
15 | 15 |
* |
16 |
- * openser is distributed in the hope that it will be useful, |
|
16 |
+ * Kamailio is distributed in the hope that it will be useful, |
|
17 | 17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | 18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 | 19 |
* GNU General Public License for more details. |
git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@3638 689a6050-402a-0410-94f2-e92a70836424
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,150 @@ |
1 |
+/* |
|
2 |
+ * $Id$ |
|
3 |
+ * |
|
4 |
+ * UNIXODBC module |
|
5 |
+ * |
|
6 |
+ * Copyright (C) 2005-2006 Marco Lorrai |
|
7 |
+ * Copyright (C) 2008 1&1 Internet AG |
|
8 |
+ * |
|
9 |
+ * This file is part of openser, a free SIP server. |
|
10 |
+ * |
|
11 |
+ * openser is free software; you can redistribute it and/or modify |
|
12 |
+ * it under the terms of the GNU General Public License as published by |
|
13 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
14 |
+ * (at your option) any later version |
|
15 |
+ * |
|
16 |
+ * openser is distributed in the hope that it will be useful, |
|
17 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19 |
+ * GNU General Public License for more details. |
|
20 |
+ * |
|
21 |
+ * You should have received a copy of the GNU General Public License |
|
22 |
+ * along with this program; if not, write to the Free Software |
|
23 |
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
24 |
+ * |
|
25 |
+ * |
|
26 |
+ * History: |
|
27 |
+ * -------- |
|
28 |
+ * 2005-12-01 initial commit (chgen) |
|
29 |
+ * 2006-04-04 simplified link list (sgupta) |
|
30 |
+ * 2006-05-05 removed static allocation of 1k per column data (sgupta) |
|
31 |
+ */ |
|
32 |
+ |
|
33 |
+#include "../../dprint.h" |
|
34 |
+#include "../../mem/mem.h" |
|
35 |
+#include "list.h" |
|
36 |
+ |
|
37 |
+int db_unixodbc_list_insert(list** start, list** link, int n, strn* value) |
|
38 |
+{ |
|
39 |
+ int i = 0; |
|
40 |
+ |
|
41 |
+ if(!(*start)) { |
|
42 |
+ *link = (list*)pkg_malloc(sizeof(list)); |
|
43 |
+ if(!(*link)) { |
|
44 |
+ LM_ERR("no more pkg memory (1)\n"); |
|
45 |
+ return -1; |
|
46 |
+ } |
|
47 |
+ (*link)->rownum = n; |
|
48 |
+ (*link)->next = NULL; |
|
49 |
+ |
|
50 |
+ (*link)->lengths = (unsigned long*)pkg_malloc(sizeof(unsigned long)*n); |
|
51 |
+ if(!(*link)->lengths) { |
|
52 |
+ LM_ERR("no more pkg memory (2)\n"); |
|
53 |
+ pkg_free(*link); |
|
54 |
+ *link = NULL; |
|
55 |
+ return -1; |
|
56 |
+ } |
|
57 |
+ for(i=0; i<n; i++) |
|
58 |
+ (*link)->lengths[i] = strlen(value[i].s) + 1; |
|
59 |
+ |
|
60 |
+ (*link)->data = (char**)pkg_malloc(sizeof(char*)*n); |
|
61 |
+ if(!(*link)->data) { |
|
62 |
+ LM_ERR("no more pkg memory (3)\n"); |
|
63 |
+ pkg_free( (*link)->lengths ); |
|
64 |
+ pkg_free(*link); |
|
65 |
+ *link = NULL; |
|
66 |
+ return -1; |
|
67 |
+ } |
|
68 |
+ |
|
69 |
+ for(i=0; i<n; i++) { |
|
70 |
+ (*link)->data[i] = pkg_malloc(sizeof(char) * (*link)->lengths[i]); |
|
71 |
+ if(!(*link)->data[i]) { |
|
72 |
+ LM_ERR("no more pkg memory (4)\n"); |
|
73 |
+ pkg_free( (*link)->lengths ); |
|
74 |
+ pkg_free( (*link)->data ); |
|
75 |
+ pkg_free(*link); |
|
76 |
+ *link = NULL; |
|
77 |
+ return -1; |
|
78 |
+ } |
|
79 |
+ strncpy((*link)->data[i], value[i].s, (*link)->lengths[i]); |
|
80 |
+ } |
|
81 |
+ |
|
82 |
+ *start = *link; |
|
83 |
+ return 0; |
|
84 |
+ } |
|
85 |
+ else |
|
86 |
+ { |
|
87 |
+ list* nlink; |
|
88 |
+ nlink=(list*)pkg_malloc(sizeof(list)); |
|
89 |
+ if(!nlink) { |
|
90 |
+ LM_ERR("no more pkg memory (5)\n"); |
|
91 |
+ return -1; |
|
92 |
+ } |
|
93 |
+ nlink->rownum = n; |
|
94 |
+ |
|
95 |
+ nlink->lengths = (unsigned long*)pkg_malloc(sizeof(unsigned long)*n); |
|
96 |
+ if(!nlink->lengths) { |
|
97 |
+ LM_ERR("no more pkg memory (6)\n"); |
|
98 |
+ pkg_free(nlink); |
|
99 |
+ nlink = NULL; |
|
100 |
+ return -1; |
|
101 |
+ } |
|
102 |
+ for(i=0; i<n; i++) |
|
103 |
+ nlink->lengths[i] = strlen(value[i].s) + 1; |
|
104 |
+ |
|
105 |
+ nlink->data = (char**)pkg_malloc(sizeof(char*)*n); |
|
106 |
+ if(!nlink->data) { |
|
107 |
+ LM_ERR("no more pkg memory (7)\n"); |
|
108 |
+ pkg_free( nlink->lengths ); |
|
109 |
+ pkg_free(nlink); |
|
110 |
+ nlink = NULL; |
|
111 |
+ return -1; |
|
112 |
+ } |
|
113 |
+ |
|
114 |
+ for(i=0; i<n; i++) { |
|
115 |
+ nlink->data[i] = pkg_malloc(sizeof(char) * nlink->lengths[i]); |
|
116 |
+ if(!nlink->data[i]) { |
|
117 |
+ LM_ERR("no more pkg memory (8)\n"); |
|
118 |
+ pkg_free( nlink->lengths ); |
|
119 |
+ pkg_free( nlink->data ); |
|
120 |
+ pkg_free(nlink); |
|
121 |
+ nlink = NULL; |
|
122 |
+ return -1; |
|
123 |
+ } |
|
124 |
+ strncpy(nlink->data[i], value[i].s, nlink->lengths[i]); |
|
125 |
+ } |
|
126 |
+ |
|
127 |
+ nlink->next = NULL; |
|
128 |
+ (*link)->next = nlink; |
|
129 |
+ *link = (*link)->next; |
|
130 |
+ |
|
131 |
+ return 0; |
|
132 |
+ } |
|
133 |
+} |
|
134 |
+ |
|
135 |
+ |
|
136 |
+void db_unixodbc_list_destroy(list *start) |
|
137 |
+{ |
|
138 |
+ int i = 0; |
|
139 |
+ |
|
140 |
+ while(start) { |
|
141 |
+ list* temp = start; |
|
142 |
+ start = start->next; |
|
143 |
+ for(i = 0; i < temp->rownum; i++) |
|
144 |
+ pkg_free( temp->data[i] ); |
|
145 |
+ pkg_free(temp->data); |
|
146 |
+ pkg_free(temp->lengths); |
|
147 |
+ pkg_free(temp); |
|
148 |
+ } |
|
149 |
+} |
|
150 |
+ |