Jabber WindowGram Client (JWGC)

Introduction Screenshots Installation Downloads
Documentation Browse Source Resources Project Site

Stable Version
-none-

Latest Version
beta5



Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

xode.c File Reference

#include "libxode.h"

Go to the source code of this file.

Functions

xode xode_new (const char *name)
xode xode_new_frompool (xode_pool p, const char *name)
xode xode_insert_tag (xode parent, const char *name)
xode xode_insert_cdata (xode parent, const char *CDATA, unsigned int size)
xode xode_get_tag (xode parent, const char *name)
char * xode_get_tagdata (xode parent, const char *name)
void xode_put_attrib (xode owner, const char *name, const char *value)
char * xode_get_attrib (xode owner, const char *name)
void xode_put_vattrib (xode owner, const char *name, void *value)
void * xode_get_vattrib (xode owner, const char *name)
xode xode_get_firstattrib (xode parent)
xode xode_get_firstchild (xode parent)
xode xode_get_lastchild (xode parent)
xode xode_get_nextsibling (xode sibling)
xode xode_get_prevsibling (xode sibling)
xode xode_get_parent (xode node)
char * xode_get_name (xode node)
char * xode_get_data (xode node)
int xode_get_datasz (xode node)
int xode_get_type (xode node)
int xode_has_children (xode node)
int xode_has_attribs (xode node)
xode_pool xode_get_pool (xode node)
void xode_hide (xode child)
void xode_hide_attrib (xode parent, const char *name)
char * xode_to_str (xode node)
int xode_cmp (xode a, xode b)
xode xode_insert_tagnode (xode parent, xode node)
void xode_insert_node (xode parent, xode node)
xode xode_dup (xode x)
xode xode_dup_frompool (xode_pool p, xode x)
xode xode_wrap (xode x, const char *wrapper)
void xode_free (xode node)
void _xode_to_prettystr (xode_spool s, xode x, int deep)
char * xode_to_prettystr (xode x)


Function Documentation

void _xode_to_prettystr xode_spool  s,
xode  x,
int  deep
 

Definition at line 802 of file xode.c.

References xode, xode_get_data(), xode_get_firstattrib(), xode_get_firstchild(), xode_get_name(), xode_get_nextsibling(), xode_get_type(), xode_spool, xode_spool_add(), and xode_spooler().

Referenced by xode_to_prettystr().

00803 {
00804         int i;
00805         xode y;
00806 
00807         if(xode_get_type(x) != XODE_TYPE_TAG) return;
00808         
00809         for(i=0; i<deep; i++) xode_spool_add(s, "\t");  
00810 
00811         xode_spooler( s , "<" , xode_get_name(x) ,  s );
00812 
00813         y = xode_get_firstattrib(x);
00814         while( y )
00815         {
00816                 xode_spooler( s , " " , xode_get_name(y) , "='", xode_get_data(y) , "'" , s );
00817 
00818                 y = xode_get_nextsibling( y );
00819         }
00820         xode_spool_add(s,">");
00821         xode_spool_add(s,"\n");
00822                 
00823         if( xode_get_data(x))
00824         {
00825                 for(i=0; i<=deep; i++) xode_spool_add(s, "\t"); 
00826                 xode_spool_add( s , xode_get_data(x)); 
00827         }
00828                         
00829         y = xode_get_firstchild(x);
00830         while( y )
00831         {
00832                 _xode_to_prettystr(s , y, deep+1);
00833                 y = xode_get_nextsibling(y);
00834                 xode_spool_add(s,"\n");
00835         }
00836                 
00837         for(i=0; i<deep; i++) xode_spool_add(s, "\t");  
00838         xode_spooler( s , "</" , xode_get_name(x) , ">" , s );
00839 
00840         return;
00841 }

int xode_cmp xode  a,
xode  b
 

Definition at line 661 of file xode.c.

References NULL, xode, xode_get_data(), xode_get_firstattrib(), xode_get_firstchild(), xode_get_name(), xode_get_nextsibling(), xode_get_type(), XODE_TYPE_ATTRIB, XODE_TYPE_CDATA, and XODE_TYPE_TAG.

00662 {
00663     int ret = 0;
00664 
00665     while(1)
00666     {
00667         if(a == NULL && b == NULL)
00668             return 0;
00669 
00670         if(a == NULL || b == NULL)
00671             return -1;
00672 
00673         if(xode_get_type(a) != xode_get_type(b))
00674             return -1;
00675 
00676         switch(xode_get_type(a))
00677         {
00678         case XODE_TYPE_ATTRIB:
00679             ret = _xode_strcmp(xode_get_name(a), xode_get_name(b));
00680             if(ret != 0)
00681                 return -1;
00682             ret = _xode_strcmp(xode_get_data(a), xode_get_data(b));
00683             if(ret != 0)
00684                 return -1;
00685             break;
00686         case XODE_TYPE_TAG:
00687             ret = _xode_strcmp(xode_get_name(a), xode_get_name(b));
00688             if(ret != 0)
00689                 return -1;
00690             ret = xode_cmp(xode_get_firstattrib(a), xode_get_firstattrib(b));
00691             if(ret != 0)
00692                 return -1;
00693             ret = xode_cmp(xode_get_firstchild(a), xode_get_firstchild(b));
00694             if(ret != 0)
00695                 return -1;
00696             break;
00697         case XODE_TYPE_CDATA:
00698             ret = _xode_strcmp(xode_get_data(a), xode_get_data(b));
00699             if(ret != 0)
00700                 return -1;
00701         }
00702         a = xode_get_nextsibling(a);
00703         b = xode_get_nextsibling(b);
00704     }
00705 }

xode xode_dup xode  x  ) 
 

Definition at line 746 of file xode.c.

References xode, xode_get_firstattrib(), xode_get_firstchild(), xode_get_name(), xode_has_attribs(), xode_has_children(), xode_insert_node(), and xode_new().

Referenced by list_agents(), list_contacts(), and list_contacts_bygroup().

00747 {
00748     xode x2;
00749 
00750     if(x == NULL)
00751         return NULL;
00752 
00753     x2 = xode_new(xode_get_name(x));
00754 
00755     if (xode_has_attribs(x))
00756         xode_insert_node(x2, xode_get_firstattrib(x));
00757     if (xode_has_children(x))
00758         xode_insert_node(x2, xode_get_firstchild(x));
00759 
00760     return x2;
00761 }

xode xode_dup_frompool xode_pool  p,
xode  x
 

Definition at line 763 of file xode.c.

References xode, xode_get_firstattrib(), xode_get_firstchild(), xode_get_name(), xode_has_attribs(), xode_has_children(), xode_insert_node(), xode_new_frompool(), and xode_pool.

00764 {
00765     xode x2;
00766 
00767     if(x == NULL)
00768         return NULL;
00769 
00770     x2 = xode_new_frompool(p, xode_get_name(x));
00771 
00772     if (xode_has_attribs(x))
00773         xode_insert_node(x2, xode_get_firstattrib(x));
00774     if (xode_has_children(x))
00775         xode_insert_node(x2, xode_get_firstchild(x));
00776 
00777     return x2;
00778 }

void xode_free xode  node  ) 
 

Definition at line 792 of file xode.c.

References xode_struct::p, xode, and xode_pool_free().

Referenced by check_live_jwgc(), fake_startup_packet(), jab_auth(), jab_on_state_handler(), jab_reg(), jab_start(), jctl_on_event_handler(), jwg_on_event_handler(), jwg_serverror(), jwg_servsuccess(), jwgc_change_presence_event_handler(), list_contacts(), list_contacts_bygroup(), main(), process_presence(), show_status(), xode_file(), xode_from_file(), xode_from_str(), and xode_str().

00793 {
00794     if(node == NULL)
00795         return;
00796 
00797     xode_pool_free(node->p);
00798 }

char* xode_get_attrib xode  owner,
const char *  name
 

Definition at line 444 of file xode.c.

References xode_struct::data, xode_struct::firstattrib, NULL, xode, and XODE_TYPE_ATTRIB.

Referenced by contact_status_change(), decode_notice(), display_field(), display_field_boolean(), display_field_fixed(), display_field_hidden(), display_field_list_single(), display_field_text_private(), display_field_text_single(), display_form(), display_form_results(), edit_field_boolean(), edit_field_list_single(), edit_field_text_single(), edit_form_entry(), find_contact_group(), find_jid_from_nickname(), find_list_id(), find_list_label(), find_match(), find_nickname_from_jid(), get_filled_form(), insert_into_agent_list(), insert_into_contact_list(), jab_on_packet_handler(), jabpacket_reset(), jabpacket_subtype(), jabutil_delay(), jabutil_priority(), jabutil_tofrom(), jctl_on_event_handler(), JFormHandler(), jid_nodescan(), jlocate_grouped_on_event_handler(), jlocate_standard_on_event_handler(), jstat_on_event_handler(), jwg_on_event_handler(), list_contacts(), list_contacts_bygroup(), process_choice(), process_iq_error(), process_iq_result(), process_iq_set(), process_presence(), remove_from_contact_list(), set_filled_form(), show_list_labels(), test_match(), update_contact_status(), update_group(), update_nickname(), and xode_get_tag().

00445 {
00446     xode attrib;
00447 
00448     if (owner != NULL && owner->firstattrib != NULL)
00449     {
00450         attrib = _xode_search(owner->firstattrib, name, XODE_TYPE_ATTRIB);
00451         if (attrib != NULL)
00452             return (char*)attrib->data;
00453     }
00454     return NULL;
00455 }

char* xode_get_data xode  node  ) 
 

Definition at line 536 of file xode.c.

References xode_struct::data, xode, xode_get_firstchild(), xode_get_nextsibling(), and xode_get_type().

Referenced by _xode_to_prettystr(), contact_status_change(), decode_notice(), display_nonform_field(), jab_on_packet_handler(), jabutil_priority(), jctl_on_event_handler(), jwg_on_event_handler(), jwrite_on_event_handler(), jwrite_ping_on_event_handler(), process_iq_result(), process_presence(), xode_cmp(), xode_get_tagdata(), and xode_insert_node().

00537 {
00538     xode cur;
00539 
00540     if(node == NULL) return NULL;
00541 
00542     if(xode_get_type(node) == XODE_TYPE_TAG) /* loop till we find a CDATA */
00543     {
00544         for(cur = xode_get_firstchild(node); cur != NULL; cur = xode_get_nextsibling(cur))
00545             if(xode_get_type(cur) == XODE_TYPE_CDATA)
00546                 return cur->data;
00547     }else{
00548         return node->data;
00549     }
00550     return NULL;
00551 }

int xode_get_datasz xode  node  ) 
 

Definition at line 553 of file xode.c.

References xode_struct::data_sz, xode, xode_get_firstchild(), xode_get_nextsibling(), and xode_get_type().

Referenced by xode_insert_node().

00554 {
00555         
00556     if( node == NULL )
00557     {
00558         return (int)NULL;           
00559     }       
00560     else if(xode_get_type(node) == XODE_TYPE_TAG) /* loop till we find a CDATA */
00561     {
00562         xode cur;       
00563         for(cur = xode_get_firstchild(node); cur != NULL; cur = xode_get_nextsibling(cur))
00564             if(xode_get_type(cur) == XODE_TYPE_CDATA)
00565                 return cur->data_sz;
00566     }else{
00567         return node->data_sz;
00568     }
00569     return (int)NULL;
00570 }

xode xode_get_firstattrib xode  parent  ) 
 

Definition at line 487 of file xode.c.

References xode_struct::firstattrib, and xode.

Referenced by _xode_to_prettystr(), xode_cmp(), xode_dup(), xode_dup_frompool(), and xode_insert_tagnode().

00488 {
00489     if (parent != NULL)
00490         return parent->firstattrib;
00491     return NULL;
00492 }

xode xode_get_firstchild xode  parent  ) 
 

Definition at line 494 of file xode.c.

References xode_struct::firstchild, and xode.

Referenced by _xode_to_prettystr(), display_form(), display_form_results(), get_filled_form(), jabutil_iqresult(), jid_nodescan(), jlocate_grouped_on_event_handler(), jlocate_standard_on_event_handler(), jstat_on_event_handler(), jwg_on_event_handler(), list_contacts(), list_contacts_bygroup(), process_form_choice(), process_nonform_choice(), set_filled_form(), update_contact_status(), xode_cmp(), xode_dup(), xode_dup_frompool(), xode_get_data(), xode_get_datasz(), and xode_insert_tagnode().

00495 {
00496     if (parent != NULL)
00497         return parent->firstchild;
00498     return NULL;
00499 }

xode xode_get_lastchild xode  parent  ) 
 

Definition at line 501 of file xode.c.

References xode_struct::lastchild, and xode.

00502 {
00503     if (parent != NULL)
00504         return parent->lastchild;
00505     return NULL;
00506 }

char* xode_get_name xode  node  ) 
 

Definition at line 529 of file xode.c.

References xode_struct::name, and xode.

Referenced by _xode_to_prettystr(), display_form(), display_nonform_field(), edit_nonform_entry(), jabpacket_reset(), jctl_on_event_handler(), jstat_on_event_handler(), jwgpacket_reset(), jwrite_on_event_handler(), jwrite_ping_on_event_handler(), process_form_choice(), process_nonform_choice(), xode_cmp(), xode_dup(), xode_dup_frompool(), xode_get_tag(), xode_insert_node(), and xode_insert_tagnode().

00530 {
00531     if (node != NULL)
00532         return node->name;
00533     return NULL;
00534 }

xode xode_get_nextsibling xode  sibling  ) 
 

Definition at line 508 of file xode.c.

References xode_struct::next, and xode.

Referenced by _xode_to_prettystr(), display_form(), display_form_results(), find_contact_group(), find_list_id(), find_list_label(), get_filled_form(), jabutil_iqresult(), jid_nodescan(), jlocate_grouped_on_event_handler(), jlocate_standard_on_event_handler(), jstat_on_event_handler(), jwg_on_event_handler(), list_contacts(), list_contacts_bygroup(), process_form_choice(), process_iq_result(), process_nonform_choice(), set_filled_form(), show_list_labels(), update_contact_status(), xode_cmp(), xode_get_data(), xode_get_datasz(), xode_get_tag(), and xode_insert_node().

00509 {
00510     if (sibling != NULL)
00511         return sibling->next;
00512     return NULL;
00513 }

xode xode_get_parent xode  node  ) 
 

Definition at line 522 of file xode.c.

References xode_struct::parent, and xode.

Referenced by expat_endElement().

00523 {
00524     if (node != NULL)
00525         return node->parent;
00526     return NULL;
00527 }

xode_pool xode_get_pool xode  node  ) 
 

Definition at line 595 of file xode.c.

References xode_struct::p, xode, and xode_pool.

Referenced by jabpacket_new(), jabpacket_reset(), jwgpacket_new(), jwgpacket_reset(), xode2file(), xode_stream_eat(), xode_to_prettystr(), and xode_wrap().

00596 {
00597     if (node != NULL)
00598         return node->p;
00599     return (xode_pool)NULL;
00600 }

xode xode_get_prevsibling xode  sibling  ) 
 

Definition at line 515 of file xode.c.

References xode_struct::prev, and xode.

00516 {
00517     if (sibling != NULL)
00518         return sibling->prev;
00519     return NULL;
00520 }

xode xode_get_tag xode  parent,
const char *  name
 

Definition at line 330 of file xode.c.

References xode_struct::firstchild, NULL, xode, xode_get_attrib(), xode_get_name(), xode_get_nextsibling(), xode_get_type(), and XODE_TYPE_TAG.

Referenced by contact_status_change(), decode_notice(), display_form(), display_form_results(), find_contact_group(), find_list_id(), find_list_label(), insert_resource_into_contact(), jab_auth(), jab_on_packet_handler(), jab_reg(), jabpacket_reset(), jabutil_priority(), jctl_on_event_handler(), JDisplayForm(), JFormHandler(), jlocate_grouped_on_event_handler(), jlocate_standard_on_event_handler(), jstat_on_event_handler(), jwg_on_event_handler(), list_contacts(), list_contacts_bygroup(), process_choice(), process_iq_error(), process_iq_result(), process_iq_set(), process_presence(), set_filled_nonform(), show_list_labels(), update_contact_status(), and xode_get_tagdata().

00331 {
00332     char *str, *slash, *qmark, *equals;
00333     xode step, ret;
00334 
00335     if(parent == NULL || parent->firstchild == NULL || name == NULL || name == '\0') return NULL;
00336 
00337     if(strstr(name, "/") == NULL && strstr(name,"?") == NULL)
00338         return _xode_search(parent->firstchild, name, XODE_TYPE_TAG);
00339 
00340     /* jer's note: why can't I modify the name directly, why do I have to strdup it?  damn c grrr! */
00341     str = strdup(name);
00342     slash = strstr(str, "/");
00343     qmark = strstr(str, "?");
00344     equals = strstr(str, "=");
00345 
00346     if(qmark != NULL && (slash == NULL || qmark < slash))
00347     { /* of type ?attrib */
00348 
00349         *qmark = '\0';
00350         qmark++;
00351         if(equals != NULL)
00352         {
00353             *equals = '\0';
00354             equals++;
00355         }
00356 
00357         for(step = parent->firstchild; step != NULL; step = xode_get_nextsibling(step))
00358         {
00359             if(xode_get_type(step) != XODE_TYPE_TAG)
00360                 continue;
00361 
00362             if(*str != '\0')
00363                 if(_xode_strcmp(xode_get_name(step),str) != 0)
00364                     continue;
00365 
00366             if(xode_get_attrib(step,qmark) == NULL)
00367                 continue;
00368 
00369             if(equals != NULL && _xode_strcmp(xode_get_attrib(step,qmark),equals) != 0)
00370                 continue;
00371 
00372             break;
00373         }
00374 
00375         free(str);
00376         return step;
00377     }
00378 
00379 
00380     *slash = '\0';
00381     ++slash;
00382 
00383     for(step = parent->firstchild; step != NULL; step = xode_get_nextsibling(step))
00384     {
00385         if(xode_get_type(step) != XODE_TYPE_TAG) continue;
00386 
00387         if(_xode_strcmp(xode_get_name(step),str) != 0)
00388             continue;
00389 
00390         ret = xode_get_tag(step, slash);
00391         if(ret != NULL)
00392         {
00393             free(str);
00394             return ret;
00395         }
00396     }
00397 
00398     free(str);
00399     return NULL;
00400 }

char* xode_get_tagdata xode  parent,
const char *  name
 

Definition at line 404 of file xode.c.

References xode, xode_get_data(), and xode_get_tag().

Referenced by display_field_boolean(), display_field_fixed(), display_field_hidden(), display_field_list_single(), display_field_text_private(), display_field_text_single(), display_form(), display_form_results(), edit_field_boolean(), edit_field_list_single(), edit_field_text_single(), find_list_id(), find_list_label(), get_filled_form(), get_filled_nonform(), jstat_on_event_handler(), jwg_on_event_handler(), process_iq_error(), process_iq_result(), process_presence(), and show_list_labels().

00405 {
00406     xode tag;
00407 
00408     tag = xode_get_tag(parent, name);
00409     if(tag == NULL) return NULL;
00410 
00411     return xode_get_data(tag);
00412 }

int xode_get_type xode  node  ) 
 

Definition at line 572 of file xode.c.

References xode_struct::type, and xode.

Referenced by _xode_to_prettystr(), jid_nodescan(), xode_cmp(), xode_get_data(), xode_get_datasz(), xode_get_tag(), and xode_insert_node().

00573 {
00574     if (node != NULL)
00575     {
00576         return node->type;
00577     }
00578     return (int)NULL;
00579 }

void* xode_get_vattrib xode  owner,
const char *  name
 

Definition at line 474 of file xode.c.

References xode_struct::firstattrib, xode_struct::firstchild, NULL, xode, and XODE_TYPE_ATTRIB.

00475 {
00476     xode attrib;
00477 
00478     if (owner != NULL && owner->firstattrib != NULL)
00479     {
00480         attrib = _xode_search(owner->firstattrib, name, XODE_TYPE_ATTRIB);
00481         if (attrib != NULL)
00482             return (void*)attrib->firstchild;
00483     }
00484     return NULL;
00485 }

int xode_has_attribs xode  node  ) 
 

Definition at line 588 of file xode.c.

References xode_struct::firstattrib, and xode.

Referenced by xode_dup(), xode_dup_frompool(), and xode_insert_tagnode().

00589 {
00590     if ((node != NULL) && (node->firstattrib != NULL))
00591         return 1;
00592     return 0;
00593 }

int xode_has_children xode  node  ) 
 

Definition at line 581 of file xode.c.

References xode_struct::firstchild, and xode.

Referenced by list_contacts(), list_contacts_bygroup(), xode_dup(), xode_dup_frompool(), and xode_insert_tagnode().

00582 {
00583     if ((node != NULL) && (node->firstchild != NULL))
00584         return 1;
00585     return 0;
00586 }

void xode_hide xode  child  ) 
 

Definition at line 602 of file xode.c.

References xode_struct::firstchild, xode_struct::lastchild, xode_struct::next, NULL, xode_struct::parent, xode_struct::prev, and xode.

Referenced by jabutil_iqresult(), list_contacts(), list_contacts_bygroup(), set_filled_form(), and set_filled_nonform().

00603 {
00604     xode parent;
00605 
00606     if(child == NULL || child->parent == NULL)
00607         return;
00608 
00609     parent = child->parent;
00610 
00611     /* first fix up at the child level */
00612     _xode_hidesibling(child);
00613 
00614     /* next fix up at the parent level */
00615     if(parent->firstchild == child)
00616         parent->firstchild = child->next;
00617     if(parent->lastchild == child)
00618         parent->lastchild = child->prev;
00619 }

void xode_hide_attrib xode  parent,
const char *  name
 

Definition at line 621 of file xode.c.

References xode_struct::firstattrib, xode_struct::lastattrib, xode_struct::next, NULL, xode_struct::prev, xode, and XODE_TYPE_ATTRIB.

Referenced by list_contacts_bygroup(), and update_contact_status().

00622 {
00623     xode attrib;
00624 
00625     if(parent == NULL || parent->firstattrib == NULL || name == NULL)
00626         return;
00627 
00628     attrib = _xode_search(parent->firstattrib, name, XODE_TYPE_ATTRIB);
00629     if(attrib == NULL)
00630         return;
00631 
00632     /* first fix up at the child level */
00633     _xode_hidesibling(attrib);
00634 
00635     /* next fix up at the parent level */
00636     if(parent->firstattrib == attrib)
00637         parent->firstattrib = attrib->next;
00638     if(parent->lastattrib == attrib)
00639         parent->lastattrib = attrib->prev;
00640 }

xode xode_insert_cdata xode  parent,
const char *  CDATA,
unsigned int  size
 

Definition at line 283 of file xode.c.

References xode_struct::data, xode_struct::data_sz, xode_struct::lastchild, NULL, xode_struct::p, xode_struct::type, xode, xode_pool_malloc(), and XODE_TYPE_CDATA.

Referenced by display_form_results(), expat_charData(), jab_auth(), jab_on_state_handler(), jab_reg(), jabutil_delay(), jabutil_error(), jabutil_msgnew(), jabutil_presnew(), jwg_on_event_handler(), jwg_serverror(), jwg_servsuccess(), jwgc_change_presence_event_handler(), main(), set_filled_form(), set_filled_nonform(), show_status(), xode_insert_node(), and xode_stream_eat().

00284 {
00285     xode result;
00286 
00287     if(CDATA == NULL || parent == NULL)
00288         return NULL;
00289 
00290     if(size == -1)
00291         size = strlen(CDATA);
00292 
00293     if ((parent->lastchild != NULL) && (parent->lastchild->type == XODE_TYPE_CDATA))
00294     {
00295         result = parent->lastchild;
00296         result->data = _xode_merge(result->p, result->data, result->data_sz, CDATA, size);
00297         result->data_sz = result->data_sz + size;
00298     }
00299     else
00300     {
00301         result = _xode_insert(parent, "", XODE_TYPE_CDATA);
00302         if (result != NULL)
00303         {
00304             result->data = (char*)xode_pool_malloc(result->p, size + 1);
00305             memcpy(result->data, CDATA, size);
00306             result->data[size] = '\0';
00307             result->data_sz = size;
00308         }
00309     }
00310 
00311     return result;
00312 }

void xode_insert_node xode  parent,
xode  node
 

Definition at line 722 of file xode.c.

References NULL, xode, xode_get_data(), xode_get_datasz(), xode_get_name(), xode_get_nextsibling(), xode_get_type(), xode_insert_cdata(), xode_insert_tagnode(), xode_put_attrib(), XODE_TYPE_ATTRIB, XODE_TYPE_CDATA, and XODE_TYPE_TAG.

Referenced by jctl_on_event_handler(), jwg_on_event_handler(), list_agents(), list_contacts(), list_contacts_bygroup(), xode_dup(), xode_dup_frompool(), and xode_insert_tagnode().

00723 {
00724     if(node == NULL || parent == NULL)
00725         return;
00726 
00727     while(node != NULL)
00728     {
00729         switch(xode_get_type(node))
00730         {
00731         case XODE_TYPE_ATTRIB:
00732             xode_put_attrib(parent, xode_get_name(node), xode_get_data(node));
00733             break;
00734         case XODE_TYPE_TAG:
00735             xode_insert_tagnode(parent, node);
00736             break;
00737         case XODE_TYPE_CDATA:
00738             xode_insert_cdata(parent, xode_get_data(node), xode_get_datasz(node));
00739         }
00740         node = xode_get_nextsibling(node);
00741     }
00742 }

xode xode_insert_tag xode  parent,
const char *  name
 

Definition at line 262 of file xode.c.

References xode, and XODE_TYPE_TAG.

Referenced by display_form_results(), expat_startElement(), insert_into_agent_list(), insert_into_contact_list(), insert_resource_into_contact(), jab_auth(), jab_on_state_handler(), jab_reg(), jabutil_delay(), jabutil_error(), jabutil_iqnew(), jabutil_msgnew(), jabutil_pingnew(), jabutil_presnew(), JFormHandler(), jwg_on_event_handler(), jwgc_change_presence_event_handler(), list_agents(), list_contacts_bygroup(), main(), set_filled_form(), set_filled_nonform(), show_status(), and xode_insert_tagnode().

00263 {
00264     return _xode_insert(parent, name, XODE_TYPE_TAG);
00265 }

xode xode_insert_tagnode xode  parent,
xode  node
 

Definition at line 708 of file xode.c.

References xode, xode_get_firstattrib(), xode_get_firstchild(), xode_get_name(), xode_has_attribs(), xode_has_children(), xode_insert_node(), and xode_insert_tag().

Referenced by xode_insert_node().

00709 {
00710     xode child;
00711 
00712     child = xode_insert_tag(parent, xode_get_name(node));
00713     if (xode_has_attribs(node))
00714         xode_insert_node(child, xode_get_firstattrib(node));
00715     if (xode_has_children(node))
00716         xode_insert_node(child, xode_get_firstchild(node));
00717 
00718     return child;
00719 }

xode xode_new const char *  name  ) 
 

Definition at line 228 of file xode.c.

References NULL, xode, and XODE_TYPE_TAG.

Referenced by check_live_jwgc(), display_form_results(), expat_startElement(), insert_into_agent_list(), insert_into_contact_list(), jabutil_header(), jabutil_iqnew(), jabutil_msgnew(), jabutil_pingnew(), jabutil_presnew(), jctl_on_event_handler(), JFormHandler(), jwg_on_event_handler(), jwg_serverror(), jwg_servsuccess(), list_contacts(), list_contacts_bygroup(), main(), show_status(), xode_dup(), and xode_stream_eat().

00229 {
00230     return _xode_new(NULL, name, XODE_TYPE_TAG);
00231 }

xode xode_new_frompool xode_pool  p,
const char *  name
 

Definition at line 245 of file xode.c.

References xode, xode_pool, and XODE_TYPE_TAG.

Referenced by jid_xres(), xode_dup_frompool(), and xode_wrap().

00246 {
00247     return _xode_new(p, name, XODE_TYPE_TAG);
00248 }

void xode_put_attrib xode  owner,
const char *  name,
const char *  value
 

Definition at line 415 of file xode.c.

References xode_struct::data, xode_struct::data_sz, xode_struct::firstattrib, xode_struct::lastattrib, NULL, xode_struct::p, xode, xode_pool_strdup(), and XODE_TYPE_ATTRIB.

Referenced by insert_into_agent_list(), insert_into_contact_list(), insert_resource_into_contact(), jab_auth(), jab_reg(), jabutil_delay(), jabutil_error(), jabutil_header(), jabutil_iqnew(), jabutil_iqresult(), jabutil_msgnew(), jabutil_pingnew(), jabutil_presnew(), jabutil_tofrom(), jctl_on_event_handler(), JFormHandler(), jid_xres(), jwg_on_event_handler(), list_contacts_bygroup(), main(), set_filled_form(), update_contact_status(), update_group(), update_nickname(), xode_insert_node(), xode_put_expat_attribs(), and xode_put_vattrib().

00416 {
00417     xode attrib;
00418 
00419     if(owner == NULL || name == NULL || value == NULL) return;
00420 
00421     /* If there are no existing attributs, allocate a new one to start
00422     the list */
00423     if (owner->firstattrib == NULL)
00424     {
00425         attrib = _xode_new(owner->p, name, XODE_TYPE_ATTRIB);
00426         owner->firstattrib = attrib;
00427         owner->lastattrib  = attrib;
00428     }
00429     else
00430     {
00431         attrib = _xode_search(owner->firstattrib, name, XODE_TYPE_ATTRIB);
00432         if(attrib == NULL)
00433         {
00434             attrib = _xode_appendsibling(owner->lastattrib, name, XODE_TYPE_ATTRIB);
00435             owner->lastattrib = attrib;
00436         }
00437     }
00438     /* Update the value of the attribute */
00439     attrib->data_sz = strlen(value);
00440     attrib->data    = xode_pool_strdup(owner->p, value);
00441 
00442 }

void xode_put_vattrib xode  owner,
const char *  name,
void *  value
 

Definition at line 457 of file xode.c.

References xode_struct::firstattrib, xode_struct::firstchild, xode, xode_put_attrib(), and XODE_TYPE_ATTRIB.

00458 {
00459     xode attrib;
00460 
00461     if (owner != NULL)
00462     {
00463         attrib = _xode_search(owner->firstattrib, name, XODE_TYPE_ATTRIB);
00464         if (attrib == NULL)
00465         {
00466             xode_put_attrib(owner, name, "");
00467             attrib = _xode_search(owner->firstattrib, name, XODE_TYPE_ATTRIB);
00468         }
00469         if (attrib != NULL)
00470             attrib->firstchild = (xode)value;
00471     }
00472 }

char* xode_to_prettystr xode  x  ) 
 

Definition at line 844 of file xode.c.

References _xode_to_prettystr(), xode, xode_get_pool(), xode_spool, xode_spool_newfrompool(), and xode_spool_tostr().

Referenced by decode_notice(), display_nonform_results(), jctl_on_event_handler(), list_contacts(), and list_contacts_bygroup().

00845 {
00846         xode_spool s;
00847 
00848         if( !x) return NULL;
00849         
00850         s = xode_spool_newfrompool( xode_get_pool(x));
00851 
00852         _xode_to_prettystr( s , x, 0 );
00853 
00854         return xode_spool_tostr(s);
00855 }

char* xode_to_str xode  node  ) 
 

Definition at line 654 of file xode.c.

References xode, and xode_spool_tostr().

Referenced by jab_on_packet_handler(), jab_send(), jab_start(), jwg_send(), jwg_servsend(), xode2file(), and xode_to_file().

00655 {
00656      return xode_spool_tostr(_xode_tospool(node));
00657 }

xode xode_wrap xode  x,
const char *  wrapper
 

Definition at line 780 of file xode.c.

References xode_struct::firstchild, xode_struct::lastchild, NULL, xode_struct::parent, xode, xode_get_pool(), and xode_new_frompool().

00781 {
00782     xode wrap;
00783     if(x==NULL||wrapper==NULL) return NULL;
00784     wrap=xode_new_frompool(xode_get_pool(x),wrapper);
00785     if(wrap==NULL) return NULL;
00786     wrap->firstchild=x;
00787     wrap->lastchild=x;
00788     x->parent=wrap;
00789     return wrap;
00790 }



Last updated at Tue Dec 18 21:07:42 PST 2007. This site and project hosted by...SourceForge.net Logo

Source Perspective by Fisheye