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,865 +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
-static int _xode_strcmp(const char *a, const char *b)
25
-{
26
-    if(a == NULL || b == NULL) return -1;
27
-
28
-    return strcmp(a,b);
29
-}
30
-
31
-/* Internal routines */
32
-static xode _xode_new(xode_pool p, const char* name, unsigned int type)
33
-{
34
-    xode result = NULL;
35
-    if (type > XODE_TYPE_LAST)
36
-        return NULL;
37
-
38
-    if (type != XODE_TYPE_CDATA && name == NULL)
39
-        return NULL;
40
-
41
-    if (p == NULL)
42
-    {
43
-        p = xode_pool_heap(1*1024);
44
-    }
45
-
46
-    /* Allocate & zero memory */
47
-    result = (xode)xode_pool_malloc(p, sizeof(_xode));
48
-    memset(result, '\0', sizeof(_xode));
49
-
50
-    /* Initialize fields */
51
-    if (type != XODE_TYPE_CDATA)
52
-        result->name = xode_pool_strdup(p,name);
53
-    result->type = type;
54
-    result->p = p;
55
-    return result;
56
-}
57
-
58
-static xode _xode_appendsibling(xode lastsibling, const char* name, unsigned int type)
59
-{
60
-    xode result;
61
-
62
-    result = _xode_new(xode_get_pool(lastsibling), name, type);
63
-    if (result != NULL)
64
-    {
65
-        /* Setup sibling pointers */
66
-        result->prev = lastsibling;
67
-        lastsibling->next = result;
68
-    }
69
-    return result;
70
-}
71
-
72
-static xode _xode_insert(xode parent, const char* name, unsigned int type)
73
-{
74
-    xode result;
75
-
76
-    if(parent == NULL || name == NULL) return NULL;
77
-
78
-    /* If parent->firstchild is NULL, simply create a new node for the first child */
79
-    if (parent->firstchild == NULL)
80
-    {
81
-        result = _xode_new(parent->p, name, type);
82
-        parent->firstchild = result;
83
-    }
84
-    /* Otherwise, append this to the lastchild */
85
-    else
86
-    {
87
-        result= _xode_appendsibling(parent->lastchild, name, type);
88
-    }
89
-    result->parent = parent;
90
-    parent->lastchild = result;
91
-    return result;
92
-
93
-}
94
-
95
-static xode _xode_search(xode firstsibling, const char* name, unsigned int type)
96
-{
97
-    xode current;
98
-
99
-    /* Walk the sibling list, looking for a XODE_TYPE_TAG xode with
100
-    the specified name */
101
-    current = firstsibling;
102
-    while (current != NULL)
103
-    {
104
-        if (name != NULL && (current->type == type) && (_xode_strcmp(current->name, name) == 0))
105
-            return current;
106
-        else
107
-            current = current->next;
108
-    }
109
-    return NULL;
110
-}
111
-
112
-static char* _xode_merge(xode_pool p, char* dest, unsigned int destsize, const char* src, unsigned int srcsize)
113
-{
114
-    char* result;
115
-    result = (char*)xode_pool_malloc(p, destsize + srcsize + 1);
116
-    memcpy(result, dest, destsize);
117
-    memcpy(result+destsize, src, srcsize);
118
-    result[destsize + srcsize] = '\0';
119
-
120
-    /* WARNING: major ugly hack: since we're throwing the old data away, let's jump in the xode_pool and subtract it from the size, this is for xmlstream's big-node checking */
121
-    p->size -= destsize;
122
-
123
-    return result;
124
-}
125
-
126
-static void _xode_hidesibling(xode child)
127
-{
128
-    if(child == NULL)
129
-        return;
130
-
131
-    if(child->prev != NULL)
132
-        child->prev->next = child->next;
133
-    if(child->next != NULL)
134
-        child->next->prev = child->prev;
135
-}
136
-
137
-static void _xode_tag2str(xode_spool s, xode node, int flag)
138
-{
139
-    xode tmp;
140
-
141
-    if(flag==0 || flag==1)
142
-    {
143
-	    xode_spooler(s,"<",xode_get_name(node),s);
144
-	    tmp = xode_get_firstattrib(node);
145
-	    while(tmp) {
146
-	        xode_spooler(s," ",xode_get_name(tmp),"='",xode_strescape(xode_get_pool(node),xode_get_data(tmp)),"'",s);
147
-	        tmp = xode_get_nextsibling(tmp);
148
-	    }
149
-	    if(flag==0)
150
-	        xode_spool_add(s,"/>");
151
-	    else
152
-	        xode_spool_add(s,">");
153
-    }
154
-    else
155
-    {
156
-	    xode_spooler(s,"</",xode_get_name(node),">",s);
157
-    }
158
-}
159
-
160
-static xode_spool _xode_tospool(xode node)
161
-{
162
-    xode_spool s;
163
-    int level=0,dir=0;
164
-    xode tmp;
165
-
166
-    if(!node || xode_get_type(node) != XODE_TYPE_TAG)
167
-	return NULL;
168
-
169
-    s = xode_spool_newfrompool(xode_get_pool(node));
170
-    if(!s) return(NULL);
171
-
172
-    while(1)
173
-    {
174
-        if(dir==0)
175
-        {
176
-    	    if(xode_get_type(node) == XODE_TYPE_TAG)
177
-            {
178
-		        if(xode_has_children(node))
179
-                {
180
-		            _xode_tag2str(s,node,1);
181
-        		    node = xode_get_firstchild(node);
182
-		            level++;
183
-		            continue;
184
-        		}
185
-                else
186
-                {
187
-		            _xode_tag2str(s,node,0);
188
-		        }
189
-	        }
190
-            else
191
-            {
192
-		        xode_spool_add(s,xode_strescape(xode_get_pool(node),xode_get_data(node)));
193
-	        }
194
-	    }
195
-
196
-    	tmp = xode_get_nextsibling(node);
197
-	    if(!tmp)
198
-        {
199
-	        node = xode_get_parent(node);
200
-	        level--;
201
-	        if(level>=0) _xode_tag2str(s,node,2);
202
-	        if(level<1) break;
203
-	        dir = 1;
204
-	    }
205
-        else
206
-        {
207
-	        node = tmp;
208
-	        dir = 0;
209
-	    }
210
-    }
211
-
212
-    return s;
213
-}
214
-
215
-
216
-/* External routines */
217
-
218
-
219
-/*
220
- *  xode_new_tag -- create a tag node
221
- *  Automatically creates a memory xode_pool for the node.
222
- *
223
- *  parameters
224
- *      name -- name of the tag
225
- *
226
- *  returns
227
- *      a pointer to the tag node
228
- *      or NULL if it was unsuccessful
229
- */
230
-xode xode_new(const char* name)
231
-{
232
-    return _xode_new(NULL, name, XODE_TYPE_TAG);
233
-}
234
-
235
-/*
236
- * alias for 'xode_new'
237
- */
238
-xode xode_new_tag(const char* name)
239
-{
240
-    return _xode_new(NULL, name, XODE_TYPE_TAG);
241
-}
242
-
243
-/*
244
- *  xode_new_tag_pool -- create a tag node within given pool
245
- *
246
- *  parameters
247
- *      p -- previously created memory pool
248
- *      name -- name of the tag
249
- *
250
- *  returns
251
- *      a pointer to the tag node
252
- *      or NULL if it was unsuccessful
253
- */
254
-xode xode_new_frompool(xode_pool p, const char* name)
255
-{
256
-    return _xode_new(p, name, XODE_TYPE_TAG);
257
-}
258
-
259
-
260
-/*
261
- *  xode_insert_tag -- append a child tag to a tag
262
- *
263
- *  parameters
264
- *      parent -- pointer to the parent tag
265
- *      name -- name of the child tag
266
- *
267
- *  returns
268
- *      a pointer to the child tag node
269
- *      or NULL if it was unsuccessful
270
- */
271
-xode xode_insert_tag(xode parent, const char* name)
272
-{
273
-    return _xode_insert(parent, name, XODE_TYPE_TAG);
274
-}
275
-
276
-
277
-/*
278
- *  xode_insert_cdata -- append character data to a tag
279
- *  If last child of the parent is CDATA, merges CDATA nodes. Otherwise
280
- *  creates a CDATA node, and appends it to the parent's child list.
281
- *
282
- *  parameters
283
- *      parent -- parent tag
284
- *      CDATA -- character data
285
- *      size -- size of CDATA
286
- *              or -1 for null-terminated CDATA strings
287
- *
288
- *  returns
289
- *      a pointer to the child CDATA node
290
- *      or NULL if it was unsuccessful
291
- */
292
-xode xode_insert_cdata(xode parent, const char* CDATA, unsigned int size)
293
-{
294
-    xode result;
295
-
296
-    if(CDATA == NULL || parent == NULL)
297
-        return NULL;
298
-
299
-    if(size == -1)
300
-        size = strlen(CDATA);
301
-
302
-    if ((parent->lastchild != NULL) && (parent->lastchild->type == XODE_TYPE_CDATA))
303
-    {
304
-        result = parent->lastchild;
305
-        result->data = _xode_merge(result->p, result->data, result->data_sz, CDATA, size);
306
-        result->data_sz = result->data_sz + size;
307
-    }
308
-    else
309
-    {
310
-        result = _xode_insert(parent, "", XODE_TYPE_CDATA);
311
-        if (result != NULL)
312
-        {
313
-            result->data = (char*)xode_pool_malloc(result->p, size + 1);
314
-            memcpy(result->data, CDATA, size);
315
-            result->data[size] = '\0';
316
-            result->data_sz = size;
317
-        }
318
-    }
319
-
320
-    return result;
321
-}
322
-
323
-
324
-/*
325
- *  xode_gettag -- find given tag in an xode tree
326
- *
327
- *  parameters
328
- *      parent -- pointer to the parent tag
329
- *      name -- "name" for the child tag of that name
330
- *              "name/name" for a sub child (recurses)
331
- *              "?attrib" to match the first tag with that attrib defined
332
- *              "?attrib=value" to match the first tag with that attrib and value
333
- *              or any combination: "name/name/?attrib", etc
334
- *
335
- *  results
336
- *      a pointer to the tag matching search criteria
337
- *      or NULL if search was unsuccessful
338
- */
339
-xode xode_get_tag(xode parent, const char* name)
340
-{
341
-    char *str, *slash, *qmark, *equals;
342
-    xode step, ret;
343
-
344
-    if(parent == NULL || parent->firstchild == NULL || name == NULL || name == '\0') return NULL;
345
-
346
-    if(strstr(name, "/") == NULL && strstr(name,"?") == NULL)
347
-        return _xode_search(parent->firstchild, name, XODE_TYPE_TAG);
348
-
349
-    /* jer's note: why can't I modify the name directly, why do I have to strdup it?  damn c grrr! */
350
-    str = strdup(name);
351
-    slash = strstr(str, "/");
352
-    qmark = strstr(str, "?");
353
-    equals = strstr(str, "=");
354
-
355
-    if(qmark != NULL && (slash == NULL || qmark < slash))
356
-    { /* of type ?attrib */
357
-
358
-        *qmark = '\0';
359
-        qmark++;
360
-        if(equals != NULL)
361
-        {
362
-            *equals = '\0';
363
-            equals++;
364
-        }
365
-
366
-        for(step = parent->firstchild; step != NULL; step = xode_get_nextsibling(step))
367
-        {
368
-            if(xode_get_type(step) != XODE_TYPE_TAG)
369
-                continue;
370
-
371
-            if(*str != '\0')
372
-                if(_xode_strcmp(xode_get_name(step),str) != 0)
373
-                    continue;
374
-
375
-            if(xode_get_attrib(step,qmark) == NULL)
376
-                continue;
377
-
378
-            if(equals != NULL && _xode_strcmp(xode_get_attrib(step,qmark),equals) != 0)
379
-                continue;
380
-
381
-            break;
382
-        }
383
-
384
-        free(str);
385
-        return step;
386
-    }
387
-
388
-
389
-    *slash = '\0';
390
-    ++slash;
391
-
392
-    for(step = parent->firstchild; step != NULL; step = xode_get_nextsibling(step))
393
-    {
394
-        if(xode_get_type(step) != XODE_TYPE_TAG) continue;
395
-
396
-        if(_xode_strcmp(xode_get_name(step),str) != 0)
397
-            continue;
398
-
399
-        ret = xode_get_tag(step, slash);
400
-        if(ret != NULL)
401
-        {
402
-            free(str);
403
-            return ret;
404
-        }
405
-    }
406
-
407
-    free(str);
408
-    return NULL;
409
-}
410
-
411
-
412
-/* return the cdata from any tag */
413
-char *xode_get_tagdata(xode parent, const char *name)
414
-{
415
-    xode tag;
416
-
417
-    tag = xode_get_tag(parent, name);
418
-    if(tag == NULL) return NULL;
419
-
420
-    return xode_get_data(tag);
421
-}
422
-
423
-
424
-void xode_put_attrib(xode owner, const char* name, const char* value)
425
-{
426
-    xode attrib;
427
-
428
-    if(owner == NULL || name == NULL || value == NULL) return;
429
-
430
-    /* If there are no existing attributes, allocate a new one to start
431
-    the list */
432
-    if (owner->firstattrib == NULL)
433
-    {
434
-        attrib = _xode_new(owner->p, name, XODE_TYPE_ATTRIB);
435
-        owner->firstattrib = attrib;
436
-        owner->lastattrib  = attrib;
437
-    }
438
-    else
439
-    {
440
-        attrib = _xode_search(owner->firstattrib, name, XODE_TYPE_ATTRIB);
441
-        if(attrib == NULL)
442
-        {
443
-            attrib = _xode_appendsibling(owner->lastattrib, name, XODE_TYPE_ATTRIB);
444
-            owner->lastattrib = attrib;
445
-        }
446
-    }
447
-    /* Update the value of the attribute */
448
-    attrib->data_sz = strlen(value);
449
-    attrib->data    = xode_pool_strdup(owner->p, value);
450
-
451
-}
452
-
453
-char* xode_get_attrib(xode owner, const char* name)
454
-{
455
-    xode attrib;
456
-
457
-    if (owner != NULL && owner->firstattrib != NULL)
458
-    {
459
-        attrib = _xode_search(owner->firstattrib, name, XODE_TYPE_ATTRIB);
460
-        if (attrib != NULL)
461
-            return (char*)attrib->data;
462
-    }
463
-    return NULL;
464
-}
465
-
466
-void xode_put_vattrib(xode owner, const char* name, void *value)
467
-{
468
-    xode attrib;
469
-
470
-    if (owner != NULL)
471
-    {
472
-        attrib = _xode_search(owner->firstattrib, name, XODE_TYPE_ATTRIB);
473
-        if (attrib == NULL)
474
-        {
475
-            xode_put_attrib(owner, name, "");
476
-            attrib = _xode_search(owner->firstattrib, name, XODE_TYPE_ATTRIB);
477
-        }
478
-        if (attrib != NULL)
479
-            attrib->firstchild = (xode)value;
480
-    }
481
-}
482
-
483
-void* xode_get_vattrib(xode owner, const char* name)
484
-{
485
-    xode attrib;
486
-
487
-    if (owner != NULL && owner->firstattrib != NULL)
488
-    {
489
-        attrib = _xode_search(owner->firstattrib, name, XODE_TYPE_ATTRIB);
490
-        if (attrib != NULL)
491
-            return (void*)attrib->firstchild;
492
-    }
493
-    return NULL;
494
-}
495
-
496
-xode xode_get_firstattrib(xode parent)
497
-{
498
-    if (parent != NULL)
499
-        return parent->firstattrib;
500
-    return NULL;
501
-}
502
-
503
-xode xode_get_firstchild(xode parent)
504
-{
505
-    if (parent != NULL)
506
-        return parent->firstchild;
507
-    return NULL;
508
-}
509
-
510
-xode xode_get_lastchild(xode parent)
511
-{
512
-    if (parent != NULL)
513
-        return parent->lastchild;
514
-    return NULL;
515
-}
516
-
517
-xode xode_get_nextsibling(xode sibling)
518
-{
519
-    if (sibling != NULL)
520
-        return sibling->next;
521
-    return NULL;
522
-}
523
-
524
-xode xode_get_prevsibling(xode sibling)
525
-{
526
-    if (sibling != NULL)
527
-        return sibling->prev;
528
-    return NULL;
529
-}
530
-
531
-xode xode_get_parent(xode node)
532
-{
533
-    if (node != NULL)
534
-        return node->parent;
535
-    return NULL;
536
-}
537
-
538
-char* xode_get_name(xode node)
539
-{
540
-    if (node != NULL)
541
-        return node->name;
542
-    return NULL;
543
-}
544
-
545
-char* xode_get_data(xode node)
546
-{
547
-    xode cur;
548
-
549
-    if(node == NULL) return NULL;
550
-
551
-    if(xode_get_type(node) == XODE_TYPE_TAG) /* loop till we find a CDATA */
552
-    {
553
-        for(cur = xode_get_firstchild(node); cur != NULL; cur = xode_get_nextsibling(cur))
554
-            if(xode_get_type(cur) == XODE_TYPE_CDATA)
555
-                return cur->data;
556
-    }else{
557
-        return node->data;
558
-    }
559
-    return NULL;
560
-}
561
-
562
-int xode_get_datasz(xode node)
563
-{
564
-	
565
-    if( node == NULL )
566
-    {
567
-        return (int)(long)NULL;	    
568
-    }	    
569
-    else if(xode_get_type(node) == XODE_TYPE_TAG) /* loop till we find a CDATA */
570
-    {
571
-    	xode cur;	
572
-        for(cur = xode_get_firstchild(node); cur != NULL; cur = xode_get_nextsibling(cur))
573
-            if(xode_get_type(cur) == XODE_TYPE_CDATA)
574
-                return cur->data_sz;
575
-    }else{
576
-        return node->data_sz;
577
-    }
578
-    return (int)(long)NULL;
579
-}
580
-
581
-int xode_get_type(xode node)
582
-{
583
-    if (node != NULL)
584
-    {
585
-        return node->type;
586
-    }
587
-    return (int)(long)NULL;
588
-}
589
-
590
-int xode_has_children(xode node)
591
-{
592
-    if ((node != NULL) && (node->firstchild != NULL))
593
-        return 1;
594
-    return 0;
595
-}
596
-
597
-int xode_has_attribs(xode node)
598
-{
599
-    if ((node != NULL) && (node->firstattrib != NULL))
600
-        return 1;
601
-    return 0;
602
-}
603
-
604
-xode_pool xode_get_pool(xode node)
605
-{
606
-    if (node != NULL)
607
-        return node->p;
608
-    return (xode_pool)NULL;
609
-}
610
-
611
-void xode_hide(xode child)
612
-{
613
-    xode parent;
614
-
615
-    if(child == NULL || child->parent == NULL)
616
-        return;
617
-
618
-    parent = child->parent;
619
-
620
-    /* first fix up at the child level */
621
-    _xode_hidesibling(child);
622
-
623
-    /* next fix up at the parent level */
624
-    if(parent->firstchild == child)
625
-        parent->firstchild = child->next;
626
-    if(parent->lastchild == child)
627
-        parent->lastchild = child->prev;
628
-}
629
-
630
-void xode_hide_attrib(xode parent, const char *name)
631
-{
632
-    xode attrib;
633
-
634
-    if(parent == NULL || parent->firstattrib == NULL || name == NULL)
635
-        return;
636
-
637
-    attrib = _xode_search(parent->firstattrib, name, XODE_TYPE_ATTRIB);
638
-    if(attrib == NULL)
639
-        return;
640
-
641
-    /* first fix up at the child level */
642
-    _xode_hidesibling(attrib);
643
-
644
-    /* next fix up at the parent level */
645
-    if(parent->firstattrib == attrib)
646
-        parent->firstattrib = attrib->next;
647
-    if(parent->lastattrib == attrib)
648
-        parent->lastattrib = attrib->prev;
649
-}
650
-
651
-
652
-
653
-/*
654
- *  xode2str -- convert given xode tree into a string
655
- *
656
- *  parameters
657
- *      node -- pointer to the xode structure
658
- *
659
- *  results
660
- *      a pointer to the created string
661
- *      or NULL if it was unsuccessful
662
- */
663
-char *xode_to_str(xode node)
664
-{
665
-     return xode_spool_tostr(_xode_tospool(node));
666
-}
667
-
668
-
669
-/* loop through both a and b comparing everything, attribs, cdata, children, etc */
670
-int xode_cmp(xode a, xode b)
671
-{
672
-    int ret = 0;
673
-
674
-    while(1)
675
-    {
676
-        if(a == NULL && b == NULL)
677
-            return 0;
678
-
679
-        if(a == NULL || b == NULL)
680
-            return -1;
681
-
682
-        if(xode_get_type(a) != xode_get_type(b))
683
-            return -1;
684
-
685
-        switch(xode_get_type(a))
686
-        {
687
-        case XODE_TYPE_ATTRIB:
688
-            ret = _xode_strcmp(xode_get_name(a), xode_get_name(b));
689
-            if(ret != 0)
690
-                return -1;
691
-            ret = _xode_strcmp(xode_get_data(a), xode_get_data(b));
692
-            if(ret != 0)
693
-                return -1;
694
-            break;
695
-        case XODE_TYPE_TAG:
696
-            ret = _xode_strcmp(xode_get_name(a), xode_get_name(b));
697
-            if(ret != 0)
698
-                return -1;
699
-            ret = xode_cmp(xode_get_firstattrib(a), xode_get_firstattrib(b));
700
-            if(ret != 0)
701
-                return -1;
702
-            ret = xode_cmp(xode_get_firstchild(a), xode_get_firstchild(b));
703
-            if(ret != 0)
704
-                return -1;
705
-            break;
706
-        case XODE_TYPE_CDATA:
707
-            ret = _xode_strcmp(xode_get_data(a), xode_get_data(b));
708
-            if(ret != 0)
709
-                return -1;
710
-        }
711
-        a = xode_get_nextsibling(a);
712
-        b = xode_get_nextsibling(b);
713
-    }
714
-}
715
-
716
-
717
-xode xode_insert_tagnode(xode parent, xode node)
718
-{
719
-    xode child;
720
-
721
-    child = xode_insert_tag(parent, xode_get_name(node));
722
-    if (xode_has_attribs(node))
723
-        xode_insert_node(child, xode_get_firstattrib(node));
724
-    if (xode_has_children(node))
725
-        xode_insert_node(child, xode_get_firstchild(node));
726
-
727
-    return child;
728
-}
729
-
730
-/* places copy of node and node's siblings in parent */
731
-void xode_insert_node(xode parent, xode node)
732
-{
733
-    if(node == NULL || parent == NULL)
734
-        return;
735
-
736
-    while(node != NULL)
737
-    {
738
-        switch(xode_get_type(node))
739
-        {
740
-        case XODE_TYPE_ATTRIB:
741
-            xode_put_attrib(parent, xode_get_name(node), xode_get_data(node));
742
-            break;
743
-        case XODE_TYPE_TAG:
744
-            xode_insert_tagnode(parent, node);
745
-            break;
746
-        case XODE_TYPE_CDATA:
747
-            xode_insert_cdata(parent, xode_get_data(node), xode_get_datasz(node));
748
-        }
749
-        node = xode_get_nextsibling(node);
750
-    }
751
-}
752
-
753
-
754
-/* produce full duplicate of x with a new xode_pool, x must be a tag! */
755
-xode xode_dup(xode x)
756
-{
757
-    xode x2;
758
-
759
-    if(x == NULL)
760
-        return NULL;
761
-
762
-    x2 = xode_new(xode_get_name(x));
763
-
764
-    if (xode_has_attribs(x))
765
-        xode_insert_node(x2, xode_get_firstattrib(x));
766
-    if (xode_has_children(x))
767
-        xode_insert_node(x2, xode_get_firstchild(x));
768
-
769
-    return x2;
770
-}
771
-
772
-xode xode_dup_frompool(xode_pool p, xode x)
773
-{
774
-    xode x2;
775
-
776
-    if(x == NULL)
777
-        return NULL;
778
-
779
-    x2 = xode_new_frompool(p, xode_get_name(x));
780
-
781
-    if (xode_has_attribs(x))
782
-        xode_insert_node(x2, xode_get_firstattrib(x));
783
-    if (xode_has_children(x))
784
-        xode_insert_node(x2, xode_get_firstchild(x));
785
-
786
-    return x2;
787
-}
788
-
789
-xode xode_wrap(xode x,const char *wrapper)
790
-{
791
-    xode wrap;
792
-    if(x==NULL||wrapper==NULL) return NULL;
793
-    wrap=xode_new_frompool(xode_get_pool(x),wrapper);
794
-    if(wrap==NULL) return NULL;
795
-    wrap->firstchild=x;
796
-    wrap->lastchild=x;
797
-    x->parent=wrap;
798
-    return wrap;
799
-}
800
-
801
-void xode_free(xode node)
802
-{
803
-    if(node == NULL)
804
-        return;
805
-
806
-    xode_pool_free(node->p);
807
-}
808
-
809
-
810
-void
811
-_xode_to_prettystr( xode_spool s, xode x, int deep )
812
-{
813
-	int i;
814
-	xode y;
815
-
816
-	if(xode_get_type(x) != XODE_TYPE_TAG) return;
817
-	
818
-	for(i=0; i<deep; i++) xode_spool_add(s, "\t");	
819
-
820
-	xode_spooler( s , "<" , xode_get_name(x) ,  s );
821
-
822
-	y = xode_get_firstattrib(x);
823
-	while( y )
824
-	{
825
-		xode_spooler( s , " " , xode_get_name(y) , "='", xode_get_data(y) , "'" , s );
826
-
827
-		y = xode_get_nextsibling( y );
828
-	}
829
-	xode_spool_add(s,">");
830
-	xode_spool_add(s,"\n");
831
-		
832
-	if( xode_get_data(x))
833
-	{
834
-		for(i=0; i<=deep; i++) xode_spool_add(s, "\t");	
835
-		xode_spool_add( s , xode_get_data(x)); 
836
-	}
837
-			
838
-	y = xode_get_firstchild(x);
839
-	while( y )
840
-	{
841
-		_xode_to_prettystr(s , y, deep+1);
842
-		y = xode_get_nextsibling(y);
843
-		xode_spool_add(s,"\n");
844
-	}
845
-		
846
-	for(i=0; i<deep; i++) xode_spool_add(s, "\t");	
847
-	xode_spooler( s , "</" , xode_get_name(x) , ">" , s );
848
-
849
-	return;
850
-}
851
-
852
-char * 
853
-xode_to_prettystr( xode x )
854
-{
855
-	xode_spool s;
856
-
857
-	if( !x) return NULL;
858
-	
859
-	s = xode_spool_newfrompool( xode_get_pool(x));
860
-
861
-	_xode_to_prettystr( s , x, 0 );
862
-
863
-	return xode_spool_tostr(s);
864
-}
865
-
Browse code

fixed more 64bits warnings

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

Bogdan-Andrei Iancu authored on 12/12/2007 19:20:35
Showing 1 changed files
... ...
@@ -564,7 +564,7 @@ int xode_get_datasz(xode node)
564 564
 	
565 565
     if( node == NULL )
566 566
     {
567
-        return (int)NULL;	    
567
+        return (int)(long)NULL;	    
568 568
     }	    
569 569
     else if(xode_get_type(node) == XODE_TYPE_TAG) /* loop till we find a CDATA */
570 570
     {
... ...
@@ -575,7 +575,7 @@ int xode_get_datasz(xode node)
575 575
     }else{
576 576
         return node->data_sz;
577 577
     }
578
-    return (int)NULL;
578
+    return (int)(long)NULL;
579 579
 }
580 580
 
581 581
 int xode_get_type(xode node)
... ...
@@ -584,7 +584,7 @@ int xode_get_type(xode node)
584 584
     {
585 585
         return node->type;
586 586
     }
587
-    return (int)NULL;
587
+    return (int)(long)NULL;
588 588
 }
589 589
 
590 590
 int xode_has_children(xode node)
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,865 @@
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