Browse code

jabber(k): module moved to obsolete/jabber_k

Daniel-Constantin Mierla authored on 04/10/2010 14:25:44
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,271 +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
-#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
-}
Browse code

Initial revision

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

Bogdan-Andrei Iancu authored on 13/06/2005 16:47:24
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
+}