diff options
| author | dequis <dx@dxzone.com.ar> | 2015-05-07 16:53:58 -0300 | 
|---|---|---|
| committer | dequis <dx@dxzone.com.ar> | 2015-05-07 20:12:06 -0300 | 
| commit | 33528bd690d5e663fb4ae5f0d544ea9a38ed118c (patch) | |
| tree | 3bd17727552496cd39de42bc97495950d38dc226 /protocols | |
| parent | b71f599d0195a21941122b27891a90f463058833 (diff) | |
twitter: split length check function into twitter_message_len
Mostly to be able to test twitter_message_len externally against the
twitter-text conformance tests (the current version definitely fails -
it doesn't do utf8 normalization)
Diffstat (limited to 'protocols')
| -rw-r--r-- | protocols/twitter/twitter.c | 15 | 
1 files changed, 11 insertions, 4 deletions
diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c index 421a0552..4debc08a 100644 --- a/protocols/twitter/twitter.c +++ b/protocols/twitter/twitter.c @@ -482,17 +482,24 @@ int twitter_url_len_diff(gchar *msg, unsigned int target_len)  	return url_len_diff;  } -static gboolean twitter_length_check(struct im_connection *ic, gchar * msg) +int twitter_message_len(gchar *msg, int target_len)  { -	int max = set_getint(&ic->acc->set, "message_length"), len; -	int target_len = set_getint(&ic->acc->set, "target_url_length");  	int url_len_diff = 0;  	if (target_len > 0) {  		url_len_diff = twitter_url_len_diff(msg, target_len);  	} -	if (max == 0 || (len = g_utf8_strlen(msg, -1) + url_len_diff) <= max) { +	return g_utf8_strlen(msg, -1) + url_len_diff; +} + +static gboolean twitter_length_check(struct im_connection *ic, gchar * msg) +{ +	int max = set_getint(&ic->acc->set, "message_length"); +	int target_len = set_getint(&ic->acc->set, "target_url_length"); +	int len = twitter_message_len(msg, target_len); + +	if (max == 0 || len <= max) {  		return TRUE;  	}  | 
