Changeset ddc2de5 for protocols/twitter/twitter_lib.c
- Timestamp:
- 2012-11-10T23:52:21Z (11 years ago)
- Branches:
- master
- Children:
- dff0e0b
- Parents:
- 8bd866f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/twitter/twitter_lib.c
r8bd866f rddc2de5 727 727 } 728 728 729 static void twitter_http_get_home_timeline(struct http_request *req); 730 static void twitter_http_get_mentions(struct http_request *req); 729 static void twitter_get_home_timeline(struct im_connection *ic, gint64 next_cursor); 730 static void twitter_get_mentions(struct im_connection *ic, gint64 next_cursor); 731 732 static void twitter_http_stream(struct http_request *req) 733 { 734 int len; 735 int i; 736 char c; 737 json_value *j; 738 739 printf( "%d bytes in stream\n", req->body_size ); 740 741 /* m/^[\d\s]*/ /* why is there a second commend here? :-) */ 742 for (i = 0; i < req->body_size; i ++) { 743 if (!isspace(req->reply_body[i]) && !isdigit(req->reply_body[i])) 744 break; 745 } 746 747 /* Nothing but numbers and whitespace in there. Try again later. */ 748 if (i == req->body_size) 749 return; 750 751 /* Get length. */ 752 if (sscanf(req->reply_body, "%d", &len) != 1) 753 return; 754 755 if (req->body_size < i + len) { 756 printf("Not enough bytes in buffer yet\n"); 757 return; 758 } 759 760 http_flush_bytes(req, i); 761 c = req->reply_body[len]; 762 req->reply_body[len] = '\0'; 763 764 printf("JSON: %s\n", req->reply_body); 765 printf("parsed: %p\n", (j = json_parse(req->reply_body))); 766 json_value_free(j); 767 req->reply_body[len] = c; 768 769 http_flush_bytes(req, len); 770 } 731 771 732 772 /** … … 751 791 if (include_mentions) { 752 792 twitter_get_mentions(ic, next_cursor); 793 } 794 795 static int bla = 0; 796 797 if (bla) 798 return; 799 bla = 1; 800 801 char *args[4]; 802 args[0] = "with"; 803 args[1] = "followings"; 804 args[2] = "delimited"; 805 args[3] = "length"; 806 807 if ((td->stream = twitter_http(ic, "https://userstream.twitter.com/1.1/user.json", 808 twitter_http_stream, ic, 0, args, 4))) { 809 td->stream->flags |= HTTPC_STREAMING; 753 810 } 754 811 } … … 810 867 } 811 868 869 static void twitter_http_get_home_timeline(struct http_request *req); 870 static void twitter_http_get_mentions(struct http_request *req); 871 812 872 /** 813 873 * Get the timeline. 814 874 */ 815 void twitter_get_home_timeline(struct im_connection *ic, gint64 next_cursor)875 static void twitter_get_home_timeline(struct im_connection *ic, gint64 next_cursor) 816 876 { 817 877 struct twitter_data *td = ic->proto_data; … … 849 909 * Get mentions. 850 910 */ 851 void twitter_get_mentions(struct im_connection *ic, gint64 next_cursor)911 static void twitter_get_mentions(struct im_connection *ic, gint64 next_cursor) 852 912 { 853 913 struct twitter_data *td = ic->proto_data;
Note: See TracChangeset
for help on using the changeset viewer.