Changeset d0752e8
- Timestamp:
- 2012-09-22T12:12:12Z (12 years ago)
- Branches:
- master
- Children:
- 11ec078
- Parents:
- 55ccc9a0
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/xmltree.c
r55ccc9a0 rd0752e8 263 263 } 264 264 265 struct xt_node *xt_from_string( const char *in )265 struct xt_node *xt_from_string( const char *in, int len ) 266 266 { 267 267 struct xt_parser *parser; 268 268 struct xt_node *ret; 269 269 270 if( len == 0 ) 271 len = strlen( in ); 272 270 273 parser = xt_new( NULL, NULL ); 271 xt_feed( parser, in, strlen( in ));274 xt_feed( parser, in, len ); 272 275 ret = parser->root; 273 276 parser->root = NULL; -
lib/xmltree.h
r55ccc9a0 rd0752e8 82 82 int xt_handle( struct xt_parser *xt, struct xt_node *node, int depth ); 83 83 void xt_cleanup( struct xt_parser *xt, struct xt_node *node, int depth ); 84 struct xt_node *xt_from_string( const char *in );84 struct xt_node *xt_from_string( const char *in, int text_len ); 85 85 char *xt_to_string( struct xt_node *node ); 86 86 void xt_print( struct xt_node *node ); -
protocols/msn/ns.c
r55ccc9a0 rd0752e8 683 683 char *psm_text = NULL; 684 684 685 ubx = xt_from_string( msg );685 ubx = xt_from_string( msg, msglen ); 686 686 if( ubx && strcmp( ubx->name, "Data" ) == 0 && 687 687 ( psm = xt_find_node( ubx->children, "PSM" ) ) ) … … 695 695 struct xt_node *adl, *d, *c; 696 696 697 if( !( adl = xt_from_string( msg ) ) )697 if( !( adl = xt_from_string( msg, msglen ) ) ) 698 698 return 1; 699 699 -
protocols/msn/soap.c
r55ccc9a0 rd0752e8 229 229 if( payload ) 230 230 { 231 struct xt_node *xt = xt_from_string( payload );231 struct xt_node *xt = xt_from_string( payload, 0 ); 232 232 if( xt ) 233 233 xt_print( xt ); -
protocols/twitter/twitter_lib.c
r55ccc9a0 rd0752e8 168 168 { 169 169 static char *ret = NULL; 170 struct xt_parser *xp = NULL; 171 struct xt_node *node, *err; 170 struct xt_node *root, *node, *err; 172 171 173 172 g_free(ret); … … 175 174 176 175 if (req->body_size > 0) { 177 xp = xt_new(NULL, NULL); 178 xt_feed(xp, req->reply_body, req->body_size); 176 root = xt_from_string(req->reply_body, req->body_size); 179 177 180 for (node = xp->root; node; node = node->next)178 for (node = root; node; node = node->next) 181 179 if ((err = xt_find_node(node->children, "error")) && err->text_len > 0) { 182 180 ret = g_strdup_printf("%s (%s)", req->status_string, err->text); … … 184 182 } 185 183 186 xt_free (xp);184 xt_free_node(root); 187 185 } 188 186 … … 256 254 { 257 255 struct im_connection *ic; 258 struct xt_ parser *parser;256 struct xt_node *parsed; 259 257 struct twitter_xml_list *txl; 260 258 struct twitter_data *td; … … 292 290 293 291 // Parse the data. 294 parser = xt_new(NULL, txl); 295 xt_feed(parser, req->reply_body, req->body_size); 296 twitter_xt_get_friends_id_list(parser->root, txl); 297 xt_free(parser); 292 parsed = xt_from_string(req->reply_body, req->body_size); 293 twitter_xt_get_friends_id_list(parsed, txl); 294 xt_free_node(parsed); 298 295 299 296 td->follow_ids = txl->list; … … 352 349 struct im_connection *ic = req->data; 353 350 struct twitter_data *td; 354 struct xt_ parser *parser;351 struct xt_node *parsed; 355 352 struct twitter_xml_list *txl; 356 353 GSList *l = NULL; … … 377 374 378 375 // Parse the data. 379 parser = xt_new(NULL, txl); 380 xt_feed(parser, req->reply_body, req->body_size); 376 parsed = xt_from_string(req->reply_body, req->body_size); 381 377 382 378 // Get the user list from the parsed xml feed. 383 twitter_xt_get_users(parse r->root, txl);384 xt_free (parser);379 twitter_xt_get_users(parsed, txl); 380 xt_free_node(parsed); 385 381 386 382 // Add the users as buddies. … … 886 882 struct im_connection *ic = req->data; 887 883 struct twitter_data *td; 888 struct xt_ parser *parser;884 struct xt_node *parsed; 889 885 struct twitter_xml_list *txl; 890 886 … … 913 909 914 910 // Parse the data. 915 parser = xt_new(NULL, txl); 916 xt_feed(parser, req->reply_body, req->body_size); 911 parsed = xt_from_string(req->reply_body, req->body_size); 917 912 // The root <statuses> node should hold the list of statuses <status> 918 twitter_xt_get_status_list(ic, parse r->root, txl);919 xt_free (parser);913 twitter_xt_get_status_list(ic, parsed, txl); 914 xt_free_node(parsed); 920 915 921 916 td->home_timeline_obj = txl; … … 934 929 struct im_connection *ic = req->data; 935 930 struct twitter_data *td; 936 struct xt_ parser *parser;931 struct xt_node *parsed; 937 932 struct twitter_xml_list *txl; 938 933 … … 961 956 962 957 // Parse the data. 963 parser = xt_new(NULL, txl); 964 xt_feed(parser, req->reply_body, req->body_size); 958 parsed = xt_from_string(req->reply_body, req->body_size); 965 959 // The root <statuses> node should hold the list of statuses <status> 966 twitter_xt_get_status_list(ic, parse r->root, txl);967 xt_free (parser);960 twitter_xt_get_status_list(ic, parsed, txl); 961 xt_free_node(parsed); 968 962 969 963 td->mentions_obj = txl; … … 999 993 1000 994 if (req->body_size > 0) { 1001 struct xt_parser *xp = NULL; 1002 struct xt_node *node; 1003 1004 xp = xt_new(NULL, NULL); 1005 xt_feed(xp, req->reply_body, req->body_size); 1006 1007 if ((node = xt_find_node(xp->root, "status")) && 995 struct xt_node *parsed, *node; 996 997 parsed = xt_from_string(req->reply_body, req->body_size); 998 999 if ((node = xt_find_node(parsed, "status")) && 1008 1000 (node = xt_find_node(node->children, "id")) && node->text) 1009 1001 td->last_status_id = g_ascii_strtoull(node->text, NULL, 10); 1010 1002 1011 xt_free (xp);1003 xt_free_node(parsed); 1012 1004 } 1013 1005 }
Note: See TracChangeset
for help on using the changeset viewer.