From 61a4b0fee97875b24237d99c0869294210634f5b Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Fri, 19 Jun 2009 12:26:04 -0500 Subject: [PATCH] Add address from string utility for SMS --- src/smsutil.c | 12 ++++++++++++ src/smsutil.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/smsutil.c b/src/smsutil.c index 02e6694..61408d5 100644 --- a/src/smsutil.c +++ b/src/smsutil.c @@ -1681,6 +1681,18 @@ time_t sms_scts_to_time(const struct sms_scts *scts, struct tm *remote) return ret; } +void sms_address_from_string(struct sms_address *addr, const char *str) +{ + addr->numbering_plan = SMS_NUMBERING_PLAN_ISDN; + if (str[0] == '+') { + addr->number_type = SMS_NUMBER_TYPE_INTERNATIONAL; + strcpy(addr->address, str+1); + } else { + addr->number_type = SMS_NUMBER_TYPE_UNKNOWN; + strcpy(addr->address, str); + } +} + const char *sms_address_to_string(const struct sms_address *addr) { static char buffer[64]; diff --git a/src/smsutil.h b/src/smsutil.h index e01ab28..77d3d3c 100644 --- a/src/smsutil.h +++ b/src/smsutil.h @@ -356,7 +356,9 @@ gboolean sms_encode(const struct sms *in, int *len, int *tpdu_len, int sms_udl_in_bytes(guint8 ud_len, guint8 dcs); time_t sms_scts_to_time(const struct sms_scts *scts, struct tm *remote); + const char *sms_address_to_string(const struct sms_address *addr); +void sms_address_from_string(struct sms_address *addr, const char *str); const guint8 *sms_extract_common(const struct sms *sms, gboolean *out_udhi, guint8 *out_dcs, guint8 *out_udl, -- 2.7.4