Browse code

modules_k/*: moved k modules in directory modules/

Daniel-Constantin Mierla authored on 20/01/2013 11:57:52
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,276 +0,0 @@
1
-/*
2
- * $Id$
3
- *
4
- *  This program is free software; you can redistribute it and/or modify
5
- *  it under the terms of the GNU General Public License as published by
6
- *  the Free Software Foundation; either version 2 of the License, or
7
- *  (at your option) any later version.
8
- *
9
- *  This program is distributed in the hope that it will be useful,
10
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
- *  GNU General Public License for more details.
13
- *
14
- *  You should have received a copy of the GNU General Public License
15
- *  along with this program; if not, write to the Free Software
16
- *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
- *
18
- *  Jabber
19
- *  Copyright (C) 1998-1999 The Jabber Team http://jabber.org/
20
- */
21
-
22
-/*! \file
23
- * \ingroup xmpp
24
- */
25
-
26
-
27
-#include "xode.h"
28
-
29
-xode_pool xode_spool_getpool(const xode_spool s)
30
-{
31
-    if(s == NULL)
32
-        return NULL;
33
-
34
-    return s->p;
35
-}
36
-
37
-int xode_spool_getlen(const xode_spool s)
38
-{
39
-    if(s == NULL)
40
-        return 0;
41
-
42
-    return s->len;    
43
-}
44
-
45
-void xode_spool_free(xode_spool s)
46
-{
47
-    xode_pool_free(xode_spool_getpool(s));
48
-}
49
-
50
-xode_spool xode_spool_newfrompool(xode_pool p)
51
-{
52
-    xode_spool s;
53
-
54
-    s = xode_pool_malloc(p, sizeof(struct xode_spool_struct));
55
-    s->p = p;
56
-    s->len = 0;
57
-    s->last = NULL;
58
-    s->first = NULL;
59
-    return s;
60
-}
61
-
62
-xode_spool xode_spool_new(void)
63
-{
64
-    return xode_spool_newfrompool(xode_pool_heap(512));
65
-}
66
-
67
-void xode_spool_add(xode_spool s, char *str)
68
-{
69
-    struct xode_spool_node *sn;
70
-    int len;
71
-
72
-    if(str == NULL)
73
-        return;
74
-
75
-    len = strlen(str);
76
-    if(len == 0)
77
-        return;
78
-
79
-    sn = xode_pool_malloc(s->p, sizeof(struct xode_spool_node));
80
-    sn->c = xode_pool_strdup(s->p, str);
81
-    sn->next = NULL;
82
-
83
-    s->len += len;
84
-    if(s->last != NULL)
85
-        s->last->next = sn;
86
-    s->last = sn;
87
-    if(s->first == NULL)
88
-        s->first = sn;
89
-}
90
-
91
-void xode_spooler(xode_spool s, ...)
92
-{
93
-    va_list ap;
94
-    char *arg = NULL;
95
-
96
-    if(s == NULL)
97
-        return;
98
-
99
-    va_start(ap, s);
100
-
101
-    /* loop till we hit our end flag, the first arg */
102
-    while(1)
103
-    {
104
-        arg = va_arg(ap,char *);
105
-        if((void*)arg == (void*)s || arg == NULL)
106
-            break;
107
-        else
108
-            xode_spool_add(s, arg);
109
-    }
110
-
111
-    va_end(ap);
112
-}
113
-
114
-char *xode_spool_tostr(xode_spool s)
115
-{
116
-    char *ret,*tmp;
117
-    struct xode_spool_node *next;
118
-
119
-    if(s == NULL || s->len == 0 || s->first == NULL)
120
-        return NULL;
121
-
122
-    ret = xode_pool_malloc(s->p, s->len + 1);
123
-    *ret = '\0';
124
-
125
-    next = s->first;
126
-    tmp = ret;
127
-    while(next != NULL)
128
-    {
129
-        tmp = strcat(tmp,next->c);
130
-        next = next->next;
131
-    }
132
-
133
-    return ret;
134
-}
135
-
136
-/* convenience :) */
137
-char *xode_spool_str(xode_pool p, ...)
138
-{
139
-    va_list ap;
140
-    xode_spool s;
141
-    char *arg = NULL;
142
-
143
-    if(p == NULL)
144
-        return NULL;
145
-
146
-    s = xode_spool_newfrompool(p);
147
-
148
-    va_start(ap, p);
149
-
150
-    /* loop till we hit our end flag, the first arg */
151
-    while(1)
152
-    {
153
-        arg = va_arg(ap,char *);
154
-        if((void*)arg == (void*)p)
155
-            break;
156
-        else
157
-            xode_spool_add(s, arg);
158
-    }
159
-
160
-    va_end(ap);
161
-
162
-    return xode_spool_tostr(s);
163
-}
164
-
165
-
166
-char *xode_strunescape(xode_pool p, char *buf)
167
-{
168
-    int i,j=0;
169
-    char *temp;
170
-
171
-    if (p == NULL || buf == NULL) return(NULL);
172
-
173
-    if (strchr(buf,'&') == NULL) return(buf);
174
-
175
-    temp = xode_pool_malloc(p,strlen(buf)+1);
176
-
177
-    if (temp == NULL) return(NULL);
178
-
179
-    for(i=0;i<strlen(buf);i++)
180
-    {
181
-        if (buf[i]=='&')
182
-        {
183
-            if (strncmp(&buf[i],"&amp;",5)==0)
184
-            {
185
-                temp[j] = '&';
186
-                i += 4;
187
-            } else if (strncmp(&buf[i],"&quot;",6)==0) {
188
-                temp[j] = '\"';
189
-                i += 5;
190
-            } else if (strncmp(&buf[i],"&apos;",6)==0) {
191
-                temp[j] = '\'';
192
-                i += 5;
193
-            } else if (strncmp(&buf[i],"&lt;",4)==0) {
194
-                temp[j] = '<';
195
-                i += 3;
196
-            } else if (strncmp(&buf[i],"&gt;",4)==0) {
197
-                temp[j] = '>';
198
-                i += 3;
199
-            }
200
-        } else {
201
-            temp[j]=buf[i];
202
-        }
203
-        j++;
204
-    }
205
-    temp[j]='\0';
206
-    return(temp);
207
-}
208
-
209
-
210
-char *xode_strescape(xode_pool p, char *buf)
211
-{
212
-    int i,j,oldlen,newlen;
213
-    char *temp;
214
-
215
-    if (p == NULL || buf == NULL) return(NULL);
216
-
217
-    oldlen = newlen = strlen(buf);
218
-    for(i=0;i<oldlen;i++)
219
-    {
220
-        switch(buf[i])
221
-        {
222
-        case '&':
223
-            newlen+=5;
224
-            break;
225
-        case '\'':
226
-            newlen+=6;
227
-            break;
228
-        case '\"':
229
-            newlen+=6;
230
-            break;
231
-        case '<':
232
-            newlen+=4;
233
-            break;
234
-        case '>':
235
-            newlen+=4;
236
-            break;
237
-        }
238
-    }
239
-
240
-    if(oldlen == newlen) return buf;
241
-
242
-    temp = xode_pool_malloc(p,newlen+1);
243
-
244
-    if (temp==NULL) return(NULL);
245
-
246
-    for(i=j=0;i<oldlen;i++)
247
-    {
248
-        switch(buf[i])
249
-        {
250
-        case '&':
251
-            memcpy(&temp[j],"&amp;",5);
252
-            j += 5;
253
-            break;
254
-        case '\'':
255
-            memcpy(&temp[j],"&apos;",6);
256
-            j += 6;
257
-            break;
258
-        case '\"':
259
-            memcpy(&temp[j],"&quot;",6);
260
-            j += 6;
261
-            break;
262
-        case '<':
263
-            memcpy(&temp[j],"&lt;",4);
264
-            j += 4;
265
-            break;
266
-        case '>':
267
-            memcpy(&temp[j],"&gt;",4);
268
-            j += 4;
269
-            break;
270
-        default:
271
-            temp[j++] = buf[i];
272
-        }
273
-    }
274
-    temp[j] = '\0';
275
-    return temp;
276
-}
Browse code

- small fix for previous commit, add missing ingroup - patch provided from Olle E. Johansson, closes #2024490

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@4494 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt authored on 22/07/2008 13:43:48
Showing 1 changed files
... ...
@@ -19,6 +19,11 @@
19 19
  *  Copyright (C) 1998-1999 The Jabber Team http://jabber.org/
20 20
  */
21 21
 
22
+/*! \file
23
+ * \ingroup xmpp
24
+ */
25
+
26
+
22 27
 #include "xode.h"
23 28
 
24 29
 xode_pool xode_spool_getpool(const xode_spool s)
Browse code

- SIP-to-XMPP gateway implementation following the latest XMPP standards from IETF (RFC3920/RFC3921) - this first version works for instant messaging (to follow: presence. voice) - allow communication with any XMPP server, including Google Talk - ability to work as standalone XMPP server or as component to other XMPP server - no need to map SIP users to XMPP users, everything is transalted on the fly - the address resolution follows the scheme from old jabber module

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@1120 689a6050-402a-0410-94f2-e92a70836424

Daniel-Constantin Mierla authored on 25/09/2006 15:07:40
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,271 @@
1
+/*
2
+ * $Id$
3
+ *
4
+ *  This program is free software; you can redistribute it and/or modify
5
+ *  it under the terms of the GNU General Public License as published by
6
+ *  the Free Software Foundation; either version 2 of the License, or
7
+ *  (at your option) any later version.
8
+ *
9
+ *  This program is distributed in the hope that it will be useful,
10
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
+ *  GNU General Public License for more details.
13
+ *
14
+ *  You should have received a copy of the GNU General Public License
15
+ *  along with this program; if not, write to the Free Software
16
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
+ *
18
+ *  Jabber
19
+ *  Copyright (C) 1998-1999 The Jabber Team http://jabber.org/
20
+ */
21
+
22
+#include "xode.h"
23
+
24
+xode_pool xode_spool_getpool(const xode_spool s)
25
+{
26
+    if(s == NULL)
27
+        return NULL;
28
+
29
+    return s->p;
30
+}
31
+
32
+int xode_spool_getlen(const xode_spool s)
33
+{
34
+    if(s == NULL)
35
+        return 0;
36
+
37
+    return s->len;    
38
+}
39
+
40
+void xode_spool_free(xode_spool s)
41
+{
42
+    xode_pool_free(xode_spool_getpool(s));
43
+}
44
+
45
+xode_spool xode_spool_newfrompool(xode_pool p)
46
+{
47
+    xode_spool s;
48
+
49
+    s = xode_pool_malloc(p, sizeof(struct xode_spool_struct));
50
+    s->p = p;
51
+    s->len = 0;
52
+    s->last = NULL;
53
+    s->first = NULL;
54
+    return s;
55
+}
56
+
57
+xode_spool xode_spool_new(void)
58
+{
59
+    return xode_spool_newfrompool(xode_pool_heap(512));
60
+}
61
+
62
+void xode_spool_add(xode_spool s, char *str)
63
+{
64
+    struct xode_spool_node *sn;
65
+    int len;
66
+
67
+    if(str == NULL)
68
+        return;
69
+
70
+    len = strlen(str);
71
+    if(len == 0)
72
+        return;
73
+
74
+    sn = xode_pool_malloc(s->p, sizeof(struct xode_spool_node));
75
+    sn->c = xode_pool_strdup(s->p, str);
76
+    sn->next = NULL;
77
+
78
+    s->len += len;
79
+    if(s->last != NULL)
80
+        s->last->next = sn;
81
+    s->last = sn;
82
+    if(s->first == NULL)
83
+        s->first = sn;
84
+}
85
+
86
+void xode_spooler(xode_spool s, ...)
87
+{
88
+    va_list ap;
89
+    char *arg = NULL;
90
+
91
+    if(s == NULL)
92
+        return;
93
+
94
+    va_start(ap, s);
95
+
96
+    /* loop till we hit our end flag, the first arg */
97
+    while(1)
98
+    {
99
+        arg = va_arg(ap,char *);
100
+        if((void*)arg == (void*)s || arg == NULL)
101
+            break;
102
+        else
103
+            xode_spool_add(s, arg);
104
+    }
105
+
106
+    va_end(ap);
107
+}
108
+
109
+char *xode_spool_tostr(xode_spool s)
110
+{
111
+    char *ret,*tmp;
112
+    struct xode_spool_node *next;
113
+
114
+    if(s == NULL || s->len == 0 || s->first == NULL)
115
+        return NULL;
116
+
117
+    ret = xode_pool_malloc(s->p, s->len + 1);
118
+    *ret = '\0';
119
+
120
+    next = s->first;
121
+    tmp = ret;
122
+    while(next != NULL)
123
+    {
124
+        tmp = strcat(tmp,next->c);
125
+        next = next->next;
126
+    }
127
+
128
+    return ret;
129
+}
130
+
131
+/* convenience :) */
132
+char *xode_spool_str(xode_pool p, ...)
133
+{
134
+    va_list ap;
135
+    xode_spool s;
136
+    char *arg = NULL;
137
+
138
+    if(p == NULL)
139
+        return NULL;
140
+
141
+    s = xode_spool_newfrompool(p);
142
+
143
+    va_start(ap, p);
144
+
145
+    /* loop till we hit our end flag, the first arg */
146
+    while(1)
147
+    {
148
+        arg = va_arg(ap,char *);
149
+        if((void*)arg == (void*)p)
150
+            break;
151
+        else
152
+            xode_spool_add(s, arg);
153
+    }
154
+
155
+    va_end(ap);
156
+
157
+    return xode_spool_tostr(s);
158
+}
159
+
160
+
161
+char *xode_strunescape(xode_pool p, char *buf)
162
+{
163
+    int i,j=0;
164
+    char *temp;
165
+
166
+    if (p == NULL || buf == NULL) return(NULL);
167
+
168
+    if (strchr(buf,'&') == NULL) return(buf);
169
+
170
+    temp = xode_pool_malloc(p,strlen(buf)+1);
171
+
172
+    if (temp == NULL) return(NULL);
173
+
174
+    for(i=0;i<strlen(buf);i++)
175
+    {
176
+        if (buf[i]=='&')
177
+        {
178
+            if (strncmp(&buf[i],"&amp;",5)==0)
179
+            {
180
+                temp[j] = '&';
181
+                i += 4;
182
+            } else if (strncmp(&buf[i],"&quot;",6)==0) {
183
+                temp[j] = '\"';
184
+                i += 5;
185
+            } else if (strncmp(&buf[i],"&apos;",6)==0) {
186
+                temp[j] = '\'';
187
+                i += 5;
188
+            } else if (strncmp(&buf[i],"&lt;",4)==0) {
189
+                temp[j] = '<';
190
+                i += 3;
191
+            } else if (strncmp(&buf[i],"&gt;",4)==0) {
192
+                temp[j] = '>';
193
+                i += 3;
194
+            }
195
+        } else {
196
+            temp[j]=buf[i];
197
+        }
198
+        j++;
199
+    }
200
+    temp[j]='\0';
201
+    return(temp);
202
+}
203
+
204
+
205
+char *xode_strescape(xode_pool p, char *buf)
206
+{
207
+    int i,j,oldlen,newlen;
208
+    char *temp;
209
+
210
+    if (p == NULL || buf == NULL) return(NULL);
211
+
212
+    oldlen = newlen = strlen(buf);
213
+    for(i=0;i<oldlen;i++)
214
+    {
215
+        switch(buf[i])
216
+        {
217
+        case '&':
218
+            newlen+=5;
219
+            break;
220
+        case '\'':
221
+            newlen+=6;
222
+            break;
223
+        case '\"':
224
+            newlen+=6;
225
+            break;
226
+        case '<':
227
+            newlen+=4;
228
+            break;
229
+        case '>':
230
+            newlen+=4;
231
+            break;
232
+        }
233
+    }
234
+
235
+    if(oldlen == newlen) return buf;
236
+
237
+    temp = xode_pool_malloc(p,newlen+1);
238
+
239
+    if (temp==NULL) return(NULL);
240
+
241
+    for(i=j=0;i<oldlen;i++)
242
+    {
243
+        switch(buf[i])
244
+        {
245
+        case '&':
246
+            memcpy(&temp[j],"&amp;",5);
247
+            j += 5;
248
+            break;
249
+        case '\'':
250
+            memcpy(&temp[j],"&apos;",6);
251
+            j += 6;
252
+            break;
253
+        case '\"':
254
+            memcpy(&temp[j],"&quot;",6);
255
+            j += 6;
256
+            break;
257
+        case '<':
258
+            memcpy(&temp[j],"&lt;",4);
259
+            j += 4;
260
+            break;
261
+        case '>':
262
+            memcpy(&temp[j],"&gt;",4);
263
+            j += 4;
264
+            break;
265
+        default:
266
+            temp[j++] = buf[i];
267
+        }
268
+    }
269
+    temp[j] = '\0';
270
+    return temp;
271
+}