Changeset 7b40f17
- Timestamp:
- 2014-10-11T02:20:53Z (10 years ago)
- Branches:
- master
- Children:
- 46511b3
- Parents:
- 0e35ff6
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/xmltree.c
r0e35ff6 r7b40f17 524 524 } 525 525 526 struct xt_node *xt_find_node_by_attr( struct xt_node *xt, const char *tag, const char *key, const char *value ) { 527 struct xt_node *c; 528 char *s; 529 530 for( c = xt; ( c = xt_find_node( c, tag ) ); c = c->next ) 531 { 532 if( ( s = xt_find_attr( c, key ) ) && strcmp( s, value ) == 0 ) 533 { 534 return c; 535 } 536 } 537 return NULL; 538 } 539 540 526 541 /* Strip a few non-printable characters that aren't allowed in XML streams 527 542 (and upset some XMPP servers for example). */ -
lib/xmltree.h
r0e35ff6 r7b40f17 92 92 struct xt_node *xt_find_path( struct xt_node *node, const char *name ); 93 93 char *xt_find_attr( struct xt_node *node, const char *key ); 94 struct xt_node *xt_find_node_by_attr( struct xt_node *xt, const char *tag, const char *key, const char *value ); 94 95 95 96 struct xt_node *xt_new_node( char *name, const char *text, struct xt_node *children ); -
protocols/jabber/jabber.h
r0e35ff6 r7b40f17 229 229 #define XMLNS_RECEIPTS "urn:xmpp:receipts" /* XEP-0184 */ 230 230 #define XMLNS_VCARD "vcard-temp" /* XEP-0054 */ 231 #define XMLNS_DELAY "jabber:x:delay" /* XEP-0091 */ 231 #define XMLNS_DELAY_OLD "jabber:x:delay" /* XEP-0091 */ 232 #define XMLNS_DELAY "urn:xmpp:delay" /* XEP-0203 */ 232 233 #define XMLNS_XDATA "jabber:x:data" /* XEP-0004 */ 233 234 #define XMLNS_CHATSTATES "http://jabber.org/protocol/chatstates" /* XEP-0085 */ -
protocols/jabber/jabber_util.c
r0e35ff6 r7b40f17 726 726 char *s = NULL; 727 727 struct tm tp; 728 729 for( c = xt->children; ( c = xt_find_node( c, "x" ) ); c = c->next ) 730 { 731 if( ( s = xt_find_attr( c, "xmlns" ) ) && strcmp( s, XMLNS_DELAY ) == 0 ) 732 break; 733 } 734 735 if( !c || !( s = xt_find_attr( c, "stamp" ) ) ) 736 return 0; 728 gboolean is_old = TRUE; 729 const char *format; 730 731 /* XEP-0091 has <x> */ 732 c = xt_find_node_by_attr( xt->children, "x", "xmlns", XMLNS_DELAY_OLD ); 733 734 if( !c || !( s = xt_find_attr( c, "stamp" ) ) ) { 735 is_old = FALSE; 736 737 /* XEP-0203 has <delay> */ 738 c = xt_find_node_by_attr( xt->children, "delay", "xmlns", XMLNS_DELAY ); 739 if( !c || !( s = xt_find_attr( c, "stamp" ) ) ) { 740 return 0; 741 } 742 } 737 743 738 744 memset( &tp, 0, sizeof( tp ) ); 739 if( sscanf( s, "%4d%2d%2dT%2d:%2d:%2d", &tp.tm_year, &tp.tm_mon, &tp.tm_mday, 740 &tp.tm_hour, &tp.tm_min, &tp.tm_sec ) != 6 ) 745 746 /* The other main difference between XEPs is the timestamp format */ 747 format = (is_old) ? "%4d%2d%2dT%2d:%2d:%2d" : "%4d-%2d-%2dT%2d:%2d:%2dZ"; 748 749 if( sscanf( s, format, &tp.tm_year, &tp.tm_mon, &tp.tm_mday, 750 &tp.tm_hour, &tp.tm_min, &tp.tm_sec ) != 6 ) 741 751 return 0; 742 752
Note: See TracChangeset
for help on using the changeset viewer.