From 990ab62207668c83168a4315e7b24a7c5a21b13b Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Fri, 19 Jun 2009 10:16:11 -0500 Subject: Update unit tests --- src/smsutil.c | 18 +++++++++++++++++- src/smsutil.h | 3 ++- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/smsutil.c b/src/smsutil.c index dd338053..02e6694a 100644 --- a/src/smsutil.c +++ b/src/smsutil.c @@ -2196,7 +2196,14 @@ static inline GSList *sms_list_append(GSList *l, const struct sms *in) return l; } -GSList *sms_text_prepare(const char *utf8, guint16 ref, gboolean use_16bit) +/* Prepares the text for transmission. Breaks up into fragments if + * necessary using ref as the concatenated message reference number. + * Returns a list of sms messages in order. If ref_offset is given, + * then the ref_offset contains the reference number offset or 0 + * if no concatenation took place. + */ +GSList *sms_text_prepare(const char *utf8, guint16 ref, + gboolean use_16bit, int *ref_offset) { struct sms template; int offset = 0; @@ -2236,6 +2243,9 @@ GSList *sms_text_prepare(const char *utf8, guint16 ref, gboolean use_16bit) template.submit.udhi = FALSE; if (gsm_encoded && (written <= sms_text_capacity_gsm(160, offset))) { + if (ref_offset) + *ref_offset = 0; + template.submit.udl = written + (offset * 8 + 6) / 7; pack_7bit_own_buf(gsm_encoded, written, offset, FALSE, NULL, 0, template.submit.ud + offset); @@ -2245,6 +2255,9 @@ GSList *sms_text_prepare(const char *utf8, guint16 ref, gboolean use_16bit) } if (ucs2_encoded && (written <= (140 - offset))) { + if (ref_offset) + *ref_offset = 0; + template.submit.udl = written + offset; memcpy(template.submit.ud + offset, ucs2_encoded, written); @@ -2274,6 +2287,9 @@ GSList *sms_text_prepare(const char *utf8, guint16 ref, gboolean use_16bit) offset += 5; } + if (ref_offset) + *ref_offset = offset + 2; + seq = 1; left = written; written = 0; diff --git a/src/smsutil.h b/src/smsutil.h index 36b467be..e01ab285 100644 --- a/src/smsutil.h +++ b/src/smsutil.h @@ -395,4 +395,5 @@ GSList *sms_assembly_add_fragment(struct sms_assembly *assembly, guint16 ref, guint8 max, guint8 seq); void sms_assembly_expire(struct sms_assembly *assembly, time_t before); -GSList *sms_text_prepare(const char *utf8, guint16 ref, gboolean use_16bit); +GSList *sms_text_prepare(const char *utf8, guint16 ref, + gboolean use_16bit, int *ref_offset); -- cgit v1.2.3