Changeset 9c77fbf
- Timestamp:
- 2012-09-22T12:47:55Z (12 years ago)
- Branches:
- master
- Children:
- 6bef211
- Parents:
- c6fc24a (diff), 11ec078 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/http_client.c
rc6fc24a r9c77fbf 73 73 printf( "About to send HTTP request:\n%s\n", req->request ); 74 74 75 return ( req );75 return req; 76 76 } 77 77 … … 198 198 int evil_server = 0; 199 199 char buffer[2048]; 200 char *end1, *end2; 200 char *end1, *end2, *s; 201 size_t content_length; 201 202 int st; 202 203 … … 481 482 /* Assume that a closed connection means we're finished, this indeed 482 483 breaks with keep-alive connections and faulty connections. */ 483 req->finished = 1;484 /* req->finished = 1; */ 484 485 485 486 cleanup: … … 488 489 else 489 490 closesocket( req->fd ); 491 492 if( ( s = get_rfc822_header( req->reply_headers, "Content-Length", 0 ) ) && 493 sscanf( s, "%zd", &content_length ) == 1 ) 494 { 495 if( content_length < req->body_size ) 496 { 497 req->status_code = -1; 498 g_free( req->status_string ); 499 req->status_string = g_strdup( "Response truncated" ); 500 } 501 } 502 g_free( s ); 490 503 491 504 if( getenv( "BITLBEE_DEBUG" ) && req ) -
lib/http_client.h
rc6fc24a r9c77fbf 59 59 char *reply_body; 60 60 int body_size; /* The number of bytes in reply_body. */ 61 int finished; /*Set to non-0 if the request was completed61 /* int finished; Set to non-0 if the request was completed 62 62 successfully. */ 63 63 int redir_ttl; /* You can set it to 0 if you don't want -
lib/misc.c
rc6fc24a r9c77fbf 730 730 } 731 731 732 char *get_rfc822_header( c har *text,char *header, int len )732 char *get_rfc822_header( const char *text, const char *header, int len ) 733 733 { 734 734 int hlen = strlen( header ), i; 735 c har *ret;735 const char *ret; 736 736 737 737 if( text == NULL ) -
lib/misc.h
rc6fc24a r9c77fbf 68 68 G_MODULE_EXPORT int md5_verify_password( char *password, char *hash ); 69 69 G_MODULE_EXPORT char **split_command_parts( char *command ); 70 G_MODULE_EXPORT char *get_rfc822_header( c har *text,char *header, int len );70 G_MODULE_EXPORT char *get_rfc822_header( const char *text, const char *header, int len ); 71 71 72 72 #endif -
lib/xmltree.c
rc6fc24a r9c77fbf 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
rc6fc24a r9c77fbf 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
rc6fc24a r9c77fbf 740 740 char *psm_text = NULL; 741 741 742 ubx = xt_from_string( msg );742 ubx = xt_from_string( msg, msglen ); 743 743 if( ubx && strcmp( ubx->name, "Data" ) == 0 && 744 744 ( psm = xt_find_node( ubx->children, "PSM" ) ) ) … … 752 752 struct xt_node *adl, *d, *c; 753 753 754 if( !( adl = xt_from_string( msg ) ) )754 if( !( adl = xt_from_string( msg, msglen ) ) ) 755 755 return 1; 756 756 -
protocols/msn/soap.c
rc6fc24a r9c77fbf 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
rc6fc24a r9c77fbf 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. … … 739 735 740 736 if (td->flags & TWITTER_DOING_TIMELINE) { 741 return; 737 if (++td->http_fails >= 5) { 738 imcb_error(ic, "Fetch timeout (%d)", td->flags); 739 imc_logout(ic, TRUE); 740 } 742 741 } 743 742 … … 886 885 struct im_connection *ic = req->data; 887 886 struct twitter_data *td; 888 struct xt_ parser *parser;887 struct xt_node *parsed; 889 888 struct twitter_xml_list *txl; 890 889 … … 913 912 914 913 // Parse the data. 915 parser = xt_new(NULL, txl); 916 xt_feed(parser, req->reply_body, req->body_size); 914 parsed = xt_from_string(req->reply_body, req->body_size); 917 915 // 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);916 twitter_xt_get_status_list(ic, parsed, txl); 917 xt_free_node(parsed); 920 918 921 919 td->home_timeline_obj = txl; … … 934 932 struct im_connection *ic = req->data; 935 933 struct twitter_data *td; 936 struct xt_ parser *parser;934 struct xt_node *parsed; 937 935 struct twitter_xml_list *txl; 938 936 … … 961 959 962 960 // Parse the data. 963 parser = xt_new(NULL, txl); 964 xt_feed(parser, req->reply_body, req->body_size); 961 parsed = xt_from_string(req->reply_body, req->body_size); 965 962 // 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);963 twitter_xt_get_status_list(ic, parsed, txl); 964 xt_free_node(parsed); 968 965 969 966 td->mentions_obj = txl; … … 999 996 1000 997 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")) && 998 struct xt_node *parsed, *node; 999 1000 parsed = xt_from_string(req->reply_body, req->body_size); 1001 1002 if ((node = xt_find_node(parsed, "status")) && 1008 1003 (node = xt_find_node(node->children, "id")) && node->text) 1009 1004 td->last_status_id = g_ascii_strtoull(node->text, NULL, 10); 1010 1005 1011 xt_free (xp);1006 xt_free_node(parsed); 1012 1007 } 1013 1008 }
Note: See TracChangeset
for help on using the changeset viewer.