|
|
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <stdio.h>
#include <errno.h>
#include <syslog.h>
#include <strings.h>
#include <unistd.h>
#include <sys/time.h>
#include "libjwgc_debug.h"
#include "expat.h"
#include <varargs.h>
Go to the source code of this file.
|
|
|
|
|
Definition at line 53 of file libxode.h. Referenced by j_shahash(), j_shahash_r(), jab_getid(), jabutil_error(), jabutil_presnew(), jabutil_timestamp(), main(), xode_file_borked(), xode_from_file(), and xode_to_file(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 248 of file libxode.h. Referenced by xode_stream_eat(). |
|
|
|
|
|
Definition at line 156 of file libxode.h. Referenced by xode_cmp(), xode_get_attrib(), xode_get_vattrib(), xode_hide_attrib(), xode_insert_node(), xode_put_attrib(), and xode_put_vattrib(). |
|
Definition at line 157 of file libxode.h. Referenced by xode_cmp(), xode_insert_cdata(), and xode_insert_node(). |
|
|
|
Definition at line 155 of file libxode.h. Referenced by xode_cmp(), xode_get_tag(), xode_insert_node(), xode_insert_tag(), xode_new(), and xode_new_frompool(). |
|
|
|
|
|
Referenced by _xode_pool_new(). |
|
Referenced by xode_stream_new(). |
|
|
|
|
|
|
Referenced by xode_stream_eat(), and xode_stream_new(). |
|
|
|
Definition at line 912 of file snprintf.c. 00913 { 00914 int cc; 00915 va_list ap; 00916 00917 va_start(ap, format); 00918 strx_printv(&cc, buf, (len - 1), format, ap); 00919 va_end(ap); 00920 return (cc); 00921 }
|
|
Definition at line 924 of file snprintf.c. 00925 { 00926 int cc; 00927 00928 strx_printv(&cc, buf, (len - 1), format, ap); 00929 return (cc); 00930 }
|
|
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 }
|
|
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 }
|
|
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 }
|
|
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 }
|
|
Definition at line 109 of file xode_from.c. References dprintf(), dXML, errno, getenv(), NULL, snprintf, XML_ErrorString(), XML_GetErrorCode(), XML_Parse(), XML_Parser, XML_ParserCreate(), XML_ParserFree(), XML_SetCharacterDataHandler(), XML_SetElementHandler(), XML_SetUserData(), xode, and xode_free(). 00110 { 00111 XML_Parser p; 00112 xode *x, node; /* pointer to an xmlnode */ 00113 char buf[BUFSIZ]; 00114 int done, fd, len; 00115 char _file[1000]; 00116 00117 if(NULL == file) 00118 return NULL; 00119 00120 /* perform tilde expansion */ 00121 if(*file == '~') 00122 { 00123 char *env = getenv("HOME"); 00124 if(env != NULL) 00125 snprintf((char*)_file, 1000, "%s%s", env, file + 1); 00126 else 00127 snprintf((char*)_file, 1000, "%s", file); 00128 } 00129 else 00130 { 00131 snprintf((char*)_file, 1000, "%s", file); 00132 } 00133 00134 fd = open((char*)_file,O_RDONLY); 00135 if(fd < 0) { 00136 dprintf(dXML, "unable to open file [%d]: %s\n", errno, _file); 00137 return NULL; 00138 } 00139 00140 x = malloc(sizeof(void *)); 00141 00142 *x = NULL; /* pointer to NULL */ 00143 p = XML_ParserCreate(NULL); 00144 XML_SetUserData(p, x); 00145 XML_SetElementHandler(p, _xode_expat_startElement, _xode_expat_endElement); 00146 XML_SetCharacterDataHandler(p, _xode_expat_charData); 00147 do{ 00148 len = read(fd, buf, BUFSIZ); 00149 done = len < BUFSIZ; 00150 if(!XML_Parse(p, buf, len, done)) 00151 { 00152 dprintf(dXML, "xmlnode_file_parseerror: %s",(char *)XML_ErrorString(XML_GetErrorCode(p))); 00153 xode_free(*x); 00154 *x = NULL; 00155 done = 1; 00156 } 00157 }while(!done); 00158 00159 node = *x; 00160 XML_ParserFree(p); 00161 free(x); 00162 close(fd); 00163 return node; /* return the xmlnode x points to */ 00164 }
|
|
Definition at line 79 of file xode_from.c. References dprintf(), dXML, NULL, XML_ErrorString(), XML_GetErrorCode(), XML_Parse(), XML_Parser, XML_ParserCreate(), XML_ParserFree(), XML_SetCharacterDataHandler(), XML_SetElementHandler(), XML_SetUserData(), xode, and xode_free(). 00080 { 00081 XML_Parser p; 00082 xode *x, node; /* pointer to an xmlnode */ 00083 00084 if(NULL == str) 00085 return NULL; 00086 00087 if(len == -1) 00088 len = strlen(str); 00089 00090 x = malloc(sizeof(void *)); 00091 00092 *x = NULL; /* pointer to NULL */ 00093 p = XML_ParserCreate(NULL); 00094 XML_SetUserData(p, x); 00095 XML_SetElementHandler(p, _xode_expat_startElement, _xode_expat_endElement); 00096 XML_SetCharacterDataHandler(p, _xode_expat_charData); 00097 if(!XML_Parse(p, str, len, 1)) 00098 { 00099 dprintf(dXML, "xmlnode_str_error: %s",(char *)XML_ErrorString(XML_GetErrorCode(p))); 00100 xode_free(*x); 00101 *x = NULL; 00102 } 00103 node = *x; 00104 free(x); 00105 XML_ParserFree(p); 00106 return node; /* return the xmlnode x points to */ 00107 }
|
|
|
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 }
|
|
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 }
|
|
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 }
|
|
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 }
|
|
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 }
|
|
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 }
|
|
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 }
|
|
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 }
|
|
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().
|
|
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 }
|
|
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 }
|
|
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 }
|
|
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 }
|
|
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 }
|
|
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 }
|
|
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 }
|
|
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 }
|
|
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 }
|
|
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 }
|
|
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 }
|
|
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 }
|
|
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 }
|
|
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 }
|
|
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 }
|
|
Definition at line 232 of file pool.c. References _xode_pool_free(), xode_pool_struct::cleanup, xode_pool_free::next, and xode_pool. Referenced by xode_stream_new(). 00233 { 00234 struct xode_pool_free *clean; 00235 00236 clean = _xode_pool_free(p, f, arg); 00237 clean->next = p->cleanup; 00238 p->cleanup = clean; 00239 }
|
|
Definition at line 213 of file pool.c. References _xode_pool__free, xode_pool_free::arg, xode_pool_struct::cleanup, xode_pool_free::f, xode_pool_free::next, and xode_pool. Referenced by jab_delete(), jid_nodescan(), jwg_delete(), xode_free(), and xode_spool_free(). 00214 { 00215 struct xode_pool_free *cur, *stub; 00216 00217 if(p == NULL) return; 00218 00219 cur = p->cleanup; 00220 while(cur != NULL) 00221 { 00222 (*cur->f)(cur->arg); 00223 stub = cur->next; 00224 _xode_pool__free(cur); 00225 cur = stub; 00226 } 00227 00228 _xode_pool__free(p); 00229 }
|
|
Definition at line 246 of file pool.c. References _xode_pool_newheap(), and xode_pool. Referenced by xode_spool_new(). 00247 { 00248 return _xode_pool_newheap(bytes); 00249 }
|
|
Definition at line 137 of file pool.c. References _xode_pool__free, _xode_pool__malloc, _xode_pool_cleanup_append(), _xode_pool_free(), _xode_pool_heap(), xode_pool_heap::block, xode_pool_struct::heap, NULL, xode_pool_heap::size, xode_pool_struct::size, xode_pool_heap::used, and xode_pool. Referenced by jab_auth(), jabpacket_new(), jwgpacket_new(), spool_print(), xode_insert_cdata(), xode_pool_malloco(), xode_pool_mallocx(), xode_pool_strdup(), xode_spool_add(), xode_spool_newfrompool(), xode_spool_tostr(), xode_strescape(), and xode_strunescape(). 00138 { 00139 void *block; 00140 00141 if(p == NULL) 00142 { 00143 fprintf(stderr,"Memory Leak! xode_pmalloc received NULL pool, unable to track allocation, exiting]\n"); 00144 abort(); 00145 } 00146 00147 /* if there is no heap for this pool or it's a big request, just raw, I like how we clean this :) */ 00148 if(p->heap == NULL || size > (p->heap->size / 2)) 00149 { 00150 while((block = _xode_pool__malloc(size)) == NULL) sleep(1); 00151 p->size += size; 00152 _xode_pool_cleanup_append(p, _xode_pool_free(p, _xode_pool__free, block)); 00153 return block; 00154 } 00155 00156 /* we have to preserve boundaries, long story :) */ 00157 if(size >= 4) 00158 while(p->heap->used&7) p->heap->used++; 00159 00160 /* if we don't fit in the old heap, replace it */ 00161 if(size > (p->heap->size - p->heap->used)) 00162 p->heap = _xode_pool_heap(p, p->heap->size); 00163 00164 /* the current heap has room */ 00165 block = (char *)p->heap->block + p->heap->used; 00166 p->heap->used += size; 00167 return block; 00168 }
|
|
Definition at line 179 of file pool.c. References xode_pool, and xode_pool_malloc(). Referenced by jid_new(), jid_user(), and xode_stream_new(). 00180 { 00181 void *block = xode_pool_malloc(p, size); 00182 memset(block, 0, size); 00183 return block; 00184 }
|
|
Definition at line 170 of file pool.c. References xode_pool, and xode_pool_malloc(). Referenced by jab_new(), jwg_new(), and jwg_server(). 00171 { 00172 void* result = xode_pool_malloc(p, size); 00173 if (result != NULL) 00174 memset(result, c, size); 00175 return result; 00176 }
|
|
Definition at line 241 of file pool.c. References _xode_pool_new(), and xode_pool. Referenced by jab_new(), jid_nodescan(), jwg_new(), and jwg_server(). 00242 { 00243 return _xode_pool_new(); 00244 }
|
|
Definition at line 206 of file pool.c. References xode_pool_struct::size, and xode_pool. Referenced by xode_stream_eat(). 00207 { 00208 if(p == NULL) return 0; 00209 00210 return p->size; 00211 }
|
|
Definition at line 187 of file pool.c. References xode_pool, and xode_pool_malloc(). Referenced by jab_new(), jid_new(), jid_set(), jid_xres(), xode_pool_strdupx(), xode_put_attrib(), and xode_spool_add(). 00188 { 00189 char *ret; 00190 00191 if(src == NULL) 00192 return NULL; 00193 00194 ret = xode_pool_malloc(p,strlen(src) + 1); 00195 strcpy(ret,src); 00196 00197 return ret; 00198 }
|
|
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 }
|
|
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 }
|
|
Definition at line 60 of file str.c. References xode_spool_node::c, xode_spool_struct::first, xode_spool_struct::last, xode_spool_struct::len, xode_spool_node::next, xode_spool_struct::p, xode_pool_malloc(), xode_pool_strdup(), and xode_spool. Referenced by _xode_to_prettystr(), jid_full(), spools(), xode_spool_str(), and xode_spooler(). 00061 { 00062 struct xode_spool_node *sn; 00063 int len; 00064 00065 if(str == NULL) 00066 return; 00067 00068 len = strlen(str); 00069 if(len == 0) 00070 return; 00071 00072 sn = xode_pool_malloc(s->p, sizeof(struct xode_spool_node)); 00073 sn->c = xode_pool_strdup(s->p, str); 00074 sn->next = NULL; 00075 00076 s->len += len; 00077 if(s->last != NULL) 00078 s->last->next = sn; 00079 s->last = sn; 00080 if(s->first == NULL) 00081 s->first = sn; 00082 }
|
|
Definition at line 38 of file str.c. References xode_pool_free(), xode_spool, and xode_spool_getpool(). 00039 { 00040 xode_pool_free(xode_spool_getpool(s)); 00041 }
|
|
Definition at line 30 of file str.c. References xode_spool_struct::len, and xode_spool. 00031 { 00032 if(s == NULL) 00033 return 0; 00034 00035 return s->len; 00036 }
|
|
Definition at line 22 of file str.c. References xode_spool_struct::p, xode_pool, and xode_spool. Referenced by xode_spool_free(). 00023 { 00024 if(s == NULL) 00025 return NULL; 00026 00027 return s->p; 00028 }
|
|
Definition at line 55 of file str.c. References xode_pool_heap(), xode_spool, and xode_spool_newfrompool(). 00056 { 00057 return xode_spool_newfrompool(xode_pool_heap(512)); 00058 }
|
|
Definition at line 43 of file str.c. References xode_spool_struct::first, xode_spool_struct::last, xode_spool_struct::len, xode_spool_struct::p, xode_pool, xode_pool_malloc(), and xode_spool. Referenced by jid_full(), spools(), xode_spool_new(), xode_spool_str(), and xode_to_prettystr(). 00044 { 00045 xode_spool s; 00046 00047 s = xode_pool_malloc(p, sizeof(struct xode_spool_struct)); 00048 s->p = p; 00049 s->len = 0; 00050 s->last = NULL; 00051 s->first = NULL; 00052 return s; 00053 }
|
|
Definition at line 130 of file str.c. References xode_pool, xode_spool, xode_spool_add(), xode_spool_newfrompool(), and xode_spool_tostr(). 00131 { 00132 va_list ap; 00133 xode_spool s; 00134 char *arg = NULL; 00135 00136 if(p == NULL) 00137 return NULL; 00138 00139 s = xode_spool_newfrompool(p); 00140 00141 va_start(ap, p); 00142 00143 /* loop till we hit our end flag, the first arg */ 00144 while(1) 00145 { 00146 arg = va_arg(ap,char *); 00147 if((int)arg == (int)p) 00148 break; 00149 else 00150 xode_spool_add(s, arg); 00151 } 00152 00153 va_end(ap); 00154 00155 return xode_spool_tostr(s); 00156 }
|
|
Definition at line 107 of file str.c. References xode_spool_node::c, xode_spool_struct::first, xode_spool_struct::len, xode_spool_node::next, NULL, xode_spool_struct::p, xode_pool_malloc(), and xode_spool. Referenced by jid_full(), xode_spool_str(), xode_to_prettystr(), and xode_to_str(). 00108 { 00109 char *ret,*tmp; 00110 struct xode_spool_node *next; 00111 00112 if(s == NULL || s->len == 0 || s->first == NULL) 00113 return NULL; 00114 00115 ret = xode_pool_malloc(s->p, s->len + 1); 00116 *ret = '\0'; 00117 00118 next = s->first; 00119 tmp = ret; 00120 while(next != NULL) 00121 { 00122 tmp = strcat(tmp,next->c); 00123 next = next->next; 00124 } 00125 00126 return ret; 00127 }
|
|
Definition at line 84 of file str.c. References xode_spool, and xode_spool_add(). Referenced by _xode_to_prettystr(), and jid_full(). 00085 { 00086 va_list ap; 00087 char *arg = NULL; 00088 00089 if(s == NULL) 00090 return; 00091 00092 va_start(ap, s); 00093 00094 /* loop till we hit our end flag, the first arg */ 00095 while(1) 00096 { 00097 arg = va_arg(ap,char *); 00098 if((int)arg == (int)s || arg == NULL) 00099 break; 00100 else 00101 xode_spool_add(s, arg); 00102 } 00103 00104 va_end(ap); 00105 }
|
|
Definition at line 144 of file xstream.c. References xode_stream_struct::arg, xode_stream_struct::cdata_len, xode_stream_struct::f, xode_stream_struct::node, xode_stream_struct::parser, xode_stream_struct::status, XML_ErrorString(), XML_GetErrorCode(), XML_Parse(), xode, xode_get_pool(), xode_insert_cdata(), xode_new(), xode_pool_size(), xode_stream, and XODE_STREAM_MAXNODE. 00145 { 00146 char *err; 00147 xode xerr; 00148 static char maxerr[] = "maximum node size reached"; 00149 static char deeperr[] = "maximum node depth reached"; 00150 00151 if(xs == NULL) 00152 { 00153 fprintf(stderr,"Fatal Programming Error: xode_streameat() was improperly called with NULL.\n"); 00154 return XODE_STREAM_ERROR; 00155 } 00156 00157 if(len == 0 || buff == NULL) 00158 return xs->status; 00159 00160 if(len == -1) /* easy for hand-fed eat calls */ 00161 len = strlen(buff); 00162 00163 if(!XML_Parse(xs->parser, buff, len, 0)) 00164 { 00165 err = (char *)XML_ErrorString(XML_GetErrorCode(xs->parser)); 00166 xs->status = XODE_STREAM_ERROR; 00167 }else if(xode_pool_size(xode_get_pool(xs->node)) > XODE_STREAM_MAXNODE || xs->cdata_len > XODE_STREAM_MAXNODE){ 00168 err = maxerr; 00169 xs->status = XODE_STREAM_ERROR; 00170 }else if(xs->status == XODE_STREAM_ERROR){ /* set within expat handlers */ 00171 err = deeperr; 00172 } 00173 00174 /* fire parsing error event, make a node containing the error string */ 00175 if(xs->status == XODE_STREAM_ERROR) 00176 { 00177 xerr = xode_new("error"); 00178 xode_insert_cdata(xerr,err,-1); 00179 (xs->f)(XODE_STREAM_ERROR, xerr, xs->arg); 00180 } 00181 00182 return xs->status; 00183 }
|
|
Definition at line 118 of file xstream.c. References _xode_stream, xode_stream_struct::arg, xode_stream_struct::f, NULL, xode_stream_struct::p, xode_stream_struct::parser, XML_ParserCreate(), XML_SetCharacterDataHandler(), XML_SetElementHandler(), XML_SetUserData(), xode_pool, xode_pool_cleanup(), xode_pool_malloco(), and xode_stream. 00119 { 00120 xode_stream newx; 00121 00122 if(p == NULL || f == NULL) 00123 { 00124 fprintf(stderr,"Fatal Programming Error: xode_streamnew() was improperly called with NULL.\n"); 00125 return NULL; 00126 } 00127 00128 newx = xode_pool_malloco(p, sizeof(_xode_stream)); 00129 newx->p = p; 00130 newx->f = f; 00131 newx->arg = arg; 00132 00133 /* create expat parser and ensure cleanup */ 00134 newx->parser = XML_ParserCreate(NULL); 00135 XML_SetUserData(newx->parser, (void *)newx); 00136 XML_SetElementHandler(newx->parser, (void *)_xode_stream_startElement, (void *)_xode_stream_endElement); 00137 XML_SetCharacterDataHandler(newx->parser, (void *)_xode_stream_charData); 00138 xode_pool_cleanup(p, _xode_stream_cleanup, (void *)newx); 00139 00140 return newx; 00141 }
|
|
Definition at line 203 of file str.c. References NULL, xode_pool, and xode_pool_malloc(). 00204 { 00205 int i,j,oldlen,newlen; 00206 char *temp; 00207 00208 if (p == NULL || buf == NULL) return(NULL); 00209 00210 oldlen = newlen = strlen(buf); 00211 for(i=0;i<oldlen;i++) 00212 { 00213 switch(buf[i]) 00214 { 00215 case '&': 00216 newlen+=5; 00217 break; 00218 case '\'': 00219 newlen+=6; 00220 break; 00221 case '\"': 00222 newlen+=6; 00223 break; 00224 case '<': 00225 newlen+=4; 00226 break; 00227 case '>': 00228 newlen+=4; 00229 break; 00230 } 00231 } 00232 00233 if(oldlen == newlen) return buf; 00234 00235 temp = xode_pool_malloc(p,newlen+1); 00236 00237 if (temp==NULL) return(NULL); 00238 00239 for(i=j=0;i<oldlen;i++) 00240 { 00241 switch(buf[i]) 00242 { 00243 case '&': 00244 memcpy(&temp[j],"&",5); 00245 j += 5; 00246 break; 00247 case '\'': 00248 memcpy(&temp[j],"'",6); 00249 j += 6; 00250 break; 00251 case '\"': 00252 memcpy(&temp[j],""",6); 00253 j += 6; 00254 break; 00255 case '<': 00256 memcpy(&temp[j],"<",4); 00257 j += 4; 00258 break; 00259 case '>': 00260 memcpy(&temp[j],">",4); 00261 j += 4; 00262 break; 00263 default: 00264 temp[j++] = buf[i]; 00265 } 00266 } 00267 temp[j] = '\0'; 00268 return temp; 00269 }
|
|
Definition at line 159 of file str.c. References NULL, xode_pool, and xode_pool_malloc(). 00160 { 00161 int i,j=0; 00162 char *temp; 00163 00164 if (p == NULL || buf == NULL) return(NULL); 00165 00166 if (strchr(buf,'&') == NULL) return(buf); 00167 00168 temp = xode_pool_malloc(p,strlen(buf)+1); 00169 00170 if (temp == NULL) return(NULL); 00171 00172 for(i=0;i<strlen(buf);i++) 00173 { 00174 if (buf[i]=='&') 00175 { 00176 if (strncmp(&buf[i],"&",5)==0) 00177 { 00178 temp[j] = '&'; 00179 i += 4; 00180 } else if (strncmp(&buf[i],""",6)==0) { 00181 temp[j] = '\"'; 00182 i += 5; 00183 } else if (strncmp(&buf[i],"'",6)==0) { 00184 temp[j] = '\''; 00185 i += 5; 00186 } else if (strncmp(&buf[i],"<",4)==0) { 00187 temp[j] = '<'; 00188 i += 3; 00189 } else if (strncmp(&buf[i],">",4)==0) { 00190 temp[j] = '>'; 00191 i += 3; 00192 } 00193 } else { 00194 temp[j]=buf[i]; 00195 } 00196 j++; 00197 } 00198 temp[j]='\0'; 00199 return(temp); 00200 }
|
|
Definition at line 166 of file xode_from.c. References getenv(), NULL, snprintf, xode, and xode_to_str(). 00167 { 00168 char *doc; 00169 int fd, i; 00170 char _file[1000]; 00171 00172 if(file == NULL || node == NULL) 00173 return -1; 00174 00175 /* perform tilde expansion */ 00176 if(*file == '~') 00177 { 00178 char *env = getenv("HOME"); 00179 if(env != NULL) 00180 snprintf((char*)_file, 1000, "%s%s", env, file + 1); 00181 else 00182 snprintf((char*)_file, 1000, "%s", file); 00183 } 00184 else 00185 { 00186 snprintf((char*)_file, 1000, "%s", file); 00187 } 00188 00189 fd = open((char*)&_file, O_CREAT | O_WRONLY | O_TRUNC, 0600); 00190 if(fd < 0) 00191 return -1; 00192 00193 doc = xode_to_str(node); 00194 i = write(fd,doc,strlen(doc)); 00195 if(i < 0) 00196 return -1; 00197 00198 close(fd); 00199 return 1; 00200 }
|
|
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 }
|
|
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 }
|
|
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... |