From e2a4c4bee8d2e468204925a5d822cbec8894a3c0 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Thu, 17 Sep 2009 11:53:37 -0500 Subject: [PATCH] Use existing function for converting to iso639 --- src/sim.c | 30 +++--------------------------- src/smsutil.c | 2 +- src/smsutil.h | 1 + 3 files changed, 5 insertions(+), 28 deletions(-) diff --git a/src/sim.c b/src/sim.c index 3f26678c..f6a5d3f4 100644 --- a/src/sim.c +++ b/src/sim.c @@ -679,47 +679,23 @@ static void parse_language_list(char **out_list, int *count, } } -static const char* const dcs_lang_to_iso[0x30] = { - [0x00] = "de", - [0x01] = "en", - [0x02] = "it", - [0x03] = "fr", - [0x04] = "es", - [0x05] = "nl", - [0x06] = "sv", - [0x07] = "da", - [0x08] = "pt", - [0x09] = "fi", - [0x0a] = "no", - [0x0b] = "el", - [0x0c] = "tr", - [0x0d] = "hu", - [0x0e] = "pl", - [0x20] = "cs", - [0x21] = "ar", - [0x22] = "he", - [0x23] = "ar", - [0x24] = "ru", - [0x25] = "is", -}; - static void parse_eflp(char **out_list, int *count, const unsigned char *eflp, int length) { int i, j; - const char *code; + char code[3]; for (i = 0; i < length; i++) { if (eflp[i] >= 0x30) continue; - code = dcs_lang_to_iso[eflp[i]]; - if (!code) + if (iso639_2_from_language(eflp[i], code) == FALSE) continue; for (j = 0; j < *count; j ++) if (!memcmp(out_list[j], code, 2)) break; + if (j < *count) continue; diff --git a/src/smsutil.c b/src/smsutil.c index 863b68f5..106a39a9 100644 --- a/src/smsutil.c +++ b/src/smsutil.c @@ -2911,7 +2911,7 @@ gboolean cbs_extract_app_port(const struct cbs *cbs, int *dst, int *src, return extract_app_port_common(&iter, dst, src, is_8bit); } -static gboolean iso639_2_from_language(enum cbs_language lang, char *iso639) +gboolean iso639_2_from_language(enum cbs_language lang, char *iso639) { switch (lang) { case CBS_LANGUAGE_GERMAN: diff --git a/src/smsutil.h b/src/smsutil.h index 2e176d11..428af91c 100644 --- a/src/smsutil.h +++ b/src/smsutil.h @@ -477,6 +477,7 @@ gboolean cbs_dcs_decode(guint8 dcs, gboolean *udhi, enum sms_class *cls, enum sms_charset *charset, gboolean *compressed, enum cbs_language *language, gboolean *iso639); +gboolean iso639_2_from_language(enum cbs_language lang, char *iso639); gboolean cbs_decode(const unsigned char *pdu, int len, struct cbs *out); gboolean cbs_encode(const struct cbs *cbs, int *len, unsigned char *pdu); gboolean cbs_extract_app_port(const struct cbs *cbs, int *dst, int *src,