Changeset b75671d for protocols/twitter/twitter.c
- Timestamp:
- 2015-06-17T22:47:26Z (9 years ago)
- Children:
- b441614
- Parents:
- d832164 (diff), 2f99f23 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/twitter/twitter.c
rd832164 rb75671d 469 469 g_regex_match(regex, msg, 0, &match_info); 470 470 while (g_match_info_matches(match_info)) { 471 gchar *url = g_match_info_fetch(match_info, 2); 471 gchar *s, *url; 472 473 url = g_match_info_fetch(match_info, 2); 472 474 url_len_diff += target_len - g_utf8_strlen(url, -1); 475 473 476 /* Add another character for https://t.co/... URLs */ 474 if ( g_match_info_fetch(match_info, 3) != NULL) {477 if ((s = g_match_info_fetch(match_info, 3))) { 475 478 url_len_diff += 1; 479 g_free(s); 476 480 } 477 481 g_free(url); … … 483 487 } 484 488 485 static gboolean twitter_length_check(struct im_connection *ic, gchar * msg) 486 { 487 int max = set_getint(&ic->acc->set, "message_length"), len; 488 int target_len = set_getint(&ic->acc->set, "target_url_length"); 489 int twitter_message_len(gchar *msg, int target_len) 490 { 489 491 int url_len_diff = 0; 490 492 … … 493 495 } 494 496 495 if (max == 0 || (len = g_utf8_strlen(msg, -1) + url_len_diff) <= max) { 497 return g_utf8_strlen(msg, -1) + url_len_diff; 498 } 499 500 static gboolean twitter_length_check(struct im_connection *ic, gchar * msg) 501 { 502 int max = set_getint(&ic->acc->set, "message_length"); 503 int target_len = set_getint(&ic->acc->set, "target_url_length"); 504 int len = twitter_message_len(msg, target_len); 505 506 if (max == 0 || len <= max) { 496 507 return TRUE; 497 508 } … … 852 863 } 853 864 854 /* Parses a decimal or hex tweet ID, returns TRUE on success */855 static gboolean twitter_parse_id(char *string, int base, guint64 *id)856 {857 guint64 parsed;858 char *endptr;859 860 errno = 0;861 parsed = g_ascii_strtoull(string, &endptr, base);862 if (errno || endptr == string || *endptr != '\0') {863 return FALSE;864 }865 *id = parsed;866 return TRUE;867 }868 869 865 bee_user_t twitter_log_local_user; 870 866 … … 896 892 arg++; 897 893 } 898 if ( twitter_parse_id(arg, 16, &id) && id < TWITTER_LOG_LENGTH) {894 if (parse_int64(arg, 16, &id) && id < TWITTER_LOG_LENGTH) { 899 895 bu = td->log[id].bu; 900 896 id = td->log[id].id; 901 } else if ( twitter_parse_id(arg, 10, &id)) {897 } else if (parse_int64(arg, 10, &id)) { 902 898 /* Allow normal tweet IDs as well; not a very useful 903 899 feature but it's always been there. Just ignore … … 1016 1012 twitter_log(ic, "Tweet `%s' does not exist", cmd[1]); 1017 1013 } else { 1018 /* More common link is twitter.com/$UID/status/$ID (and that's 1019 * what this will 302 to) but can't generate that since for RTs, 1020 * bu here points at the retweeter while id contains the id of 1021 * the original message. */ 1022 twitter_log(ic, "https://twitter.com/statuses/%lld", id); 1014 twitter_status_show_url(ic, id); 1023 1015 } 1024 1016 goto eof;
Note: See TracChangeset
for help on using the changeset viewer.