Browse code

core: relocated some folders from root and utils to misc

- utils keeps only the applications related to kamailio c code
- the other are now in misc/tools
- utils/misc/vim moved to misc/extra/
- obsolete and scripts folders moved to misc/

Daniel-Constantin Mierla authored on 07/12/2016 11:46:38
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,240 +0,0 @@
1
-/*
2
- * Presence Agent, domain list
3
- *
4
- * $Id$
5
- *
6
- * Copyright (C) 2001-2003 FhG Fokus
7
- *
8
- * This file is part of ser, a free SIP server.
9
- *
10
- * ser is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License as published by
12
- * the Free Software Foundation; either version 2 of the License, or
13
- * (at your option) any later version
14
- *
15
- * For a license to use the ser software under conditions
16
- * other than those described here, or to purchase support for this
17
- * software, please contact iptel.org by e-mail at the following addresses:
18
- *    info@iptel.org
19
- *
20
- * ser is distributed in the hope that it will be useful,
21
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
- * GNU General Public License for more details.
24
- *
25
- * You should have received a copy of the GNU General Public License 
26
- * along with this program; if not, write to the Free Software 
27
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
28
- */
29
-
30
-
31
-#include "dlist.h"
32
-#include "../../dprint.h"
33
-#include "../../mem/shm_mem.h"
34
-#include "../../sr_module.h"
35
-#include "../../ut.h"
36
-#include "paerrno.h"
37
-#include <string.h>
38
-#include "ptime.h"
39
-#include "presentity.h"
40
-
41
-/*
42
- * List of all registered domains
43
- */
44
-dlist_t* root = 0;
45
-
46
-
47
-/*
48
- * Find domain with the given name
49
- * Returns 0 if the domain was found
50
- * and 1 of not
51
- */
52
-static inline int find_dlist(str* _n, dlist_t** _d)
53
-{
54
-	dlist_t* ptr;
55
-
56
-	ptr = root;
57
-	while(ptr) {
58
-		if ((_n->len == ptr->name.len) &&
59
-		    !memcmp(_n->s, ptr->name.s, _n->len)) {
60
-			*_d = ptr;
61
-			return 0;
62
-		}
63
-		
64
-		ptr = ptr->next;
65
-	}
66
-	
67
-	return 1;
68
-}
69
-
70
-
71
-/*
72
- * Create a new domain structure
73
- * Returns 0 if everything went OK, otherwise value < 0
74
- * is returned
75
- *
76
- * The structure is NOT created in shared memory so the
77
- * function must be called before ser forks if it should
78
- * be available to all processes
79
- */
80
-static inline int new_dlist(str* _n, dlist_t** _d)
81
-{
82
-	cmd_function reg;
83
-	cmd_function unreg;
84
-
85
-	dlist_t* ptr;
86
-
87
-	     /* Domains are created before ser forks,
88
-	      * so we can create them using pkg_malloc
89
-	      */
90
-	ptr = (dlist_t*)mem_alloc(sizeof(dlist_t));
91
-	if (ptr == 0) {
92
-		paerrno = PA_NO_MEMORY;
93
-		LOG(L_ERR, "new_dlist(): No memory left\n");
94
-		return -1;
95
-	}
96
-	memset(ptr, 0, sizeof(dlist_t));
97
-
98
-	ptr->name.s = (char*)mem_alloc(_n->len);
99
-	if (ptr->name.s == 0) {
100
-		paerrno = PA_NO_MEMORY;
101
-		LOG(L_ERR, "new_dlist(): No memory left 2\n");
102
-		mem_free(ptr);
103
-		return -2;
104
-	}
105
-
106
-	memcpy(ptr->name.s, _n->s, _n->len);
107
-	ptr->name.len = _n->len;
108
-
109
-	if ((_n->len == 9) && (!strncasecmp(_n->s, "registrar", 9))) {
110
-		reg = find_export("ul_register_watcher", 1, 0);
111
-		if (reg == 0) {
112
-			LOG(L_ERR, "new_dlist(): ~ul_register_watcher not found\n");
113
-			return -3;
114
-		}
115
-		unreg = find_export("ul_unregister_watcher", 1, 0);
116
-		if (unreg == 0) {
117
-			LOG(L_ERR, "new_dlist(): ~ul_unregister_watcher not found\n");
118
-			return -4;
119
-		}
120
-	} else if ((_n->len == 6) && (!strncasecmp(_n->s, "jabber", 6))) {
121
-		reg = find_export("jab_register_watcher", 1, 0);
122
-		if (reg == 0) {
123
-			LOG(L_ERR, "new_dlist(): jab_register_watcher not found\n");
124
-			return -5;
125
-		}
126
-		unreg = find_export("jab_unregister_watcher", 1, 0);
127
-		if (unreg == 0) {
128
-			LOG(L_ERR, "new_dlist(): jab_unregister_watcher not found\n");
129
-			return -6;
130
-		}
131
-	} else {
132
-		LOG(L_ERR, "new_dlist(): Unknown module to bind: %.*s\n", _n->len, ZSW(_n->s));
133
-			return -7;
134
-	}
135
-
136
-	if (new_pdomain(&(ptr->name), 512, &(ptr->d), (register_watcher_t)reg, (unregister_watcher_t)unreg) < 0) {
137
-		LOG(L_ERR, "new_dlist(): Error while creating domain structure\n");
138
-		mem_free(ptr->name.s);
139
-		mem_free(ptr);
140
-		return -8;
141
-	}
142
-
143
-	*_d = ptr;
144
-	return 0;
145
-}
146
-
147
-int find_pdomain(const char* _n, pdomain_t** _d)
148
-{
149
-	dlist_t* d;
150
-	str s;
151
-
152
-	s.s = (char*)_n;
153
-	s.len = strlen(_n);
154
-
155
-	if (find_dlist(&s, &d) == 0) {
156
-	        *_d = d->d;
157
-		return 0;
158
-	}
159
-	
160
-	return 1;
161
-}
162
-
163
-/*
164
- * Function registers a new domain with presence agent
165
- * if the domain exists, pointer to existing structure
166
- * will be returned, otherwise a new domain will be
167
- * created
168
- */
169
-int register_pdomain(const char* _n, pdomain_t** _d)
170
-{
171
-	pdomain_t *pdomain;
172
-	dlist_t* d;
173
-	str s;
174
-
175
-	s.s = (char*)_n;
176
-	s.len = strlen(_n);
177
-
178
-	if (find_dlist(&s, &d) == 0) {
179
-	        *_d = d->d;
180
-		return 0;
181
-	}
182
-	
183
-	if (new_dlist(&s, &d) < 0) {
184
-		LOG(L_ERR, "register_pdomain(): Error while creating new domain\n");
185
-		return -1;
186
-	} 
187
-
188
-	pdomain = d->d;
189
-	lock_pdomain(pdomain);	/* do not enable timer to delete presentities in it */
190
-	d->next = root;
191
-	root = d;
192
-	
193
-	*_d = pdomain;
194
-
195
-	/* Preload domain with data from database if we are gonna
196
-	 * to use database
197
-	 */
198
-	pdomain_load_presentities(pdomain);
199
-	unlock_pdomain(pdomain);
200
-
201
-	return 0;
202
-}
203
-
204
-
205
-/*
206
- * Free all allocated memory
207
- */
208
-void free_all_pdomains(void)
209
-{
210
-	dlist_t* ptr;
211
-
212
-	while(root) {
213
-		ptr = root;
214
-		root = root->next;
215
-
216
-		free_pdomain(ptr->d);
217
-		mem_free(ptr->name.s);
218
-		mem_free(ptr);
219
-	}
220
-}
221
-
222
-/*
223
- * Run timer handler of all domains
224
- */
225
-int timer_all_pdomains(void)
226
-{
227
-	int res = 0;
228
-	dlist_t* ptr;
229
-
230
-	get_act_time(); /* Get and save actual time */
231
-
232
-	ptr = root;
233
-	while(ptr) {
234
-		res |= timer_pdomain(ptr->d);
235
-		ptr = ptr->next;
236
-	}
237
-	
238
-	return res;
239
-}
240
-
Browse code

all: updated FSF address in GPL text

Anthony Messina authored on 04/07/2014 09:36:37 • Daniel-Constantin Mierla committed on 04/07/2014 09:37:36
Showing 1 changed files
... ...
@@ -24,7 +24,7 @@
24 24
  *
25 25
  * You should have received a copy of the GNU General Public License 
26 26
  * along with this program; if not, write to the Free Software 
27
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
28 28
  */
29 29
 
30 30
 
Browse code

pa(s): obsoleted

Moved pa to obsolete/ because it does not compile (needs upgrade
to the current DB libs) and it does not have a maintainer.

Andrei Pelinescu-Onciul authored on 09/12/2009 09:53:51
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,240 @@
1
+/*
2
+ * Presence Agent, domain list
3
+ *
4
+ * $Id$
5
+ *
6
+ * Copyright (C) 2001-2003 FhG Fokus
7
+ *
8
+ * This file is part of ser, a free SIP server.
9
+ *
10
+ * ser is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version
14
+ *
15
+ * For a license to use the ser software under conditions
16
+ * other than those described here, or to purchase support for this
17
+ * software, please contact iptel.org by e-mail at the following addresses:
18
+ *    info@iptel.org
19
+ *
20
+ * ser is distributed in the hope that it will be useful,
21
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
+ * GNU General Public License for more details.
24
+ *
25
+ * You should have received a copy of the GNU General Public License 
26
+ * along with this program; if not, write to the Free Software 
27
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28
+ */
29
+
30
+
31
+#include "dlist.h"
32
+#include "../../dprint.h"
33
+#include "../../mem/shm_mem.h"
34
+#include "../../sr_module.h"
35
+#include "../../ut.h"
36
+#include "paerrno.h"
37
+#include <string.h>
38
+#include "ptime.h"
39
+#include "presentity.h"
40
+
41
+/*
42
+ * List of all registered domains
43
+ */
44
+dlist_t* root = 0;
45
+
46
+
47
+/*
48
+ * Find domain with the given name
49
+ * Returns 0 if the domain was found
50
+ * and 1 of not
51
+ */
52
+static inline int find_dlist(str* _n, dlist_t** _d)
53
+{
54
+	dlist_t* ptr;
55
+
56
+	ptr = root;
57
+	while(ptr) {
58
+		if ((_n->len == ptr->name.len) &&
59
+		    !memcmp(_n->s, ptr->name.s, _n->len)) {
60
+			*_d = ptr;
61
+			return 0;
62
+		}
63
+		
64
+		ptr = ptr->next;
65
+	}
66
+	
67
+	return 1;
68
+}
69
+
70
+
71
+/*
72
+ * Create a new domain structure
73
+ * Returns 0 if everything went OK, otherwise value < 0
74
+ * is returned
75
+ *
76
+ * The structure is NOT created in shared memory so the
77
+ * function must be called before ser forks if it should
78
+ * be available to all processes
79
+ */
80
+static inline int new_dlist(str* _n, dlist_t** _d)
81
+{
82
+	cmd_function reg;
83
+	cmd_function unreg;
84
+
85
+	dlist_t* ptr;
86
+
87
+	     /* Domains are created before ser forks,
88
+	      * so we can create them using pkg_malloc
89
+	      */
90
+	ptr = (dlist_t*)mem_alloc(sizeof(dlist_t));
91
+	if (ptr == 0) {
92
+		paerrno = PA_NO_MEMORY;
93
+		LOG(L_ERR, "new_dlist(): No memory left\n");
94
+		return -1;
95
+	}
96
+	memset(ptr, 0, sizeof(dlist_t));
97
+
98
+	ptr->name.s = (char*)mem_alloc(_n->len);
99
+	if (ptr->name.s == 0) {
100
+		paerrno = PA_NO_MEMORY;
101
+		LOG(L_ERR, "new_dlist(): No memory left 2\n");
102
+		mem_free(ptr);
103
+		return -2;
104
+	}
105
+
106
+	memcpy(ptr->name.s, _n->s, _n->len);
107
+	ptr->name.len = _n->len;
108
+
109
+	if ((_n->len == 9) && (!strncasecmp(_n->s, "registrar", 9))) {
110
+		reg = find_export("ul_register_watcher", 1, 0);
111
+		if (reg == 0) {
112
+			LOG(L_ERR, "new_dlist(): ~ul_register_watcher not found\n");
113
+			return -3;
114
+		}
115
+		unreg = find_export("ul_unregister_watcher", 1, 0);
116
+		if (unreg == 0) {
117
+			LOG(L_ERR, "new_dlist(): ~ul_unregister_watcher not found\n");
118
+			return -4;
119
+		}
120
+	} else if ((_n->len == 6) && (!strncasecmp(_n->s, "jabber", 6))) {
121
+		reg = find_export("jab_register_watcher", 1, 0);
122
+		if (reg == 0) {
123
+			LOG(L_ERR, "new_dlist(): jab_register_watcher not found\n");
124
+			return -5;
125
+		}
126
+		unreg = find_export("jab_unregister_watcher", 1, 0);
127
+		if (unreg == 0) {
128
+			LOG(L_ERR, "new_dlist(): jab_unregister_watcher not found\n");
129
+			return -6;
130
+		}
131
+	} else {
132
+		LOG(L_ERR, "new_dlist(): Unknown module to bind: %.*s\n", _n->len, ZSW(_n->s));
133
+			return -7;
134
+	}
135
+
136
+	if (new_pdomain(&(ptr->name), 512, &(ptr->d), (register_watcher_t)reg, (unregister_watcher_t)unreg) < 0) {
137
+		LOG(L_ERR, "new_dlist(): Error while creating domain structure\n");
138
+		mem_free(ptr->name.s);
139
+		mem_free(ptr);
140
+		return -8;
141
+	}
142
+
143
+	*_d = ptr;
144
+	return 0;
145
+}
146
+
147
+int find_pdomain(const char* _n, pdomain_t** _d)
148
+{
149
+	dlist_t* d;
150
+	str s;
151
+
152
+	s.s = (char*)_n;
153
+	s.len = strlen(_n);
154
+
155
+	if (find_dlist(&s, &d) == 0) {
156
+	        *_d = d->d;
157
+		return 0;
158
+	}
159
+	
160
+	return 1;
161
+}
162
+
163
+/*
164
+ * Function registers a new domain with presence agent
165
+ * if the domain exists, pointer to existing structure
166
+ * will be returned, otherwise a new domain will be
167
+ * created
168
+ */
169
+int register_pdomain(const char* _n, pdomain_t** _d)
170
+{
171
+	pdomain_t *pdomain;
172
+	dlist_t* d;
173
+	str s;
174
+
175
+	s.s = (char*)_n;
176
+	s.len = strlen(_n);
177
+
178
+	if (find_dlist(&s, &d) == 0) {
179
+	        *_d = d->d;
180
+		return 0;
181
+	}
182
+	
183
+	if (new_dlist(&s, &d) < 0) {
184
+		LOG(L_ERR, "register_pdomain(): Error while creating new domain\n");
185
+		return -1;
186
+	} 
187
+
188
+	pdomain = d->d;
189
+	lock_pdomain(pdomain);	/* do not enable timer to delete presentities in it */
190
+	d->next = root;
191
+	root = d;
192
+	
193
+	*_d = pdomain;
194
+
195
+	/* Preload domain with data from database if we are gonna
196
+	 * to use database
197
+	 */
198
+	pdomain_load_presentities(pdomain);
199
+	unlock_pdomain(pdomain);
200
+
201
+	return 0;
202
+}
203
+
204
+
205
+/*
206
+ * Free all allocated memory
207
+ */
208
+void free_all_pdomains(void)
209
+{
210
+	dlist_t* ptr;
211
+
212
+	while(root) {
213
+		ptr = root;
214
+		root = root->next;
215
+
216
+		free_pdomain(ptr->d);
217
+		mem_free(ptr->name.s);
218
+		mem_free(ptr);
219
+	}
220
+}
221
+
222
+/*
223
+ * Run timer handler of all domains
224
+ */
225
+int timer_all_pdomains(void)
226
+{
227
+	int res = 0;
228
+	dlist_t* ptr;
229
+
230
+	get_act_time(); /* Get and save actual time */
231
+
232
+	ptr = root;
233
+	while(ptr) {
234
+		res |= timer_pdomain(ptr->d);
235
+		ptr = ptr->next;
236
+	}
237
+	
238
+	return res;
239
+}
240
+