diff options
author | Alexander Tarasikov <alexander.tarasikov@gmail.com> | 2012-07-13 16:30:35 +0400 |
---|---|---|
committer | Alexander Tarasikov <alexander.tarasikov@gmail.com> | 2012-07-13 16:30:35 +0400 |
commit | 697e533e23e237cfba07b7054f5e4ab29e4227e2 (patch) | |
tree | 53e1ccc7d7fae2f3e1cd72f1d6771eb6af44d637 | |
parent | 98a8d340281ed71aaa0130accd0061d818d46199 (diff) | |
download | hardware_ril_samsung-ril-697e533e23e237cfba07b7054f5e4ab29e4227e2.zip hardware_ril_samsung-ril-697e533e23e237cfba07b7054f5e4ab29e4227e2.tar.gz hardware_ril_samsung-ril-697e533e23e237cfba07b7054f5e4ab29e4227e2.tar.bz2 |
Move SmsCodingScheme to utils.c for future reuse
-rw-r--r-- | ss.c | 38 | ||||
-rw-r--r-- | util.c | 34 | ||||
-rw-r--r-- | util.h | 8 |
3 files changed, 42 insertions, 38 deletions
@@ -168,44 +168,6 @@ void ipc2ril_ussd_state(struct ipc_ss_ussd *ussd, char *message[2]) } } -typedef enum { - SMS_CODING_SCHEME_UNKNOWN = 0, - SMS_CODING_SCHEME_GSM7, - SMS_CODING_SCHEME_UCS2 -} SmsCodingScheme; - -static SmsCodingScheme sms_get_coding_scheme(int dataCoding) -{ - switch (dataCoding >> 4) { - case 0x00: - case 0x02: - case 0x03: - return SMS_CODING_SCHEME_GSM7; - case 0x01: - if (dataCoding == 0x10) - return SMS_CODING_SCHEME_GSM7; - if (dataCoding == 0x11) - return SMS_CODING_SCHEME_UCS2; - break; - case 0x04: - case 0x05: - case 0x06: - case 0x07: - if (dataCoding & 0x20) - return SMS_CODING_SCHEME_UNKNOWN; - if (((dataCoding >> 2) & 3) == 0) - return SMS_CODING_SCHEME_GSM7; - if (((dataCoding >> 2) & 3) == 2) - return SMS_CODING_SCHEME_UCS2; - break; - case 0xF: - if (!(dataCoding & 4)) - return SMS_CODING_SCHEME_GSM7; - break; - } - return SMS_CODING_SCHEME_UNKNOWN; -} - void ipc_ss_ussd(struct ipc_message_info *info) { char *data_dec = NULL; @@ -23,6 +23,7 @@ #define LOG_TAG "RIL-UTIL" #include <utils/Log.h> +#include "util.h" /** * Converts a hexidecimal string to binary @@ -260,3 +261,36 @@ int utf8_write(char *utf8, int offset, int v) } return result; } + +SmsCodingScheme sms_get_coding_scheme(int dataCoding) +{ + switch (dataCoding >> 4) { + case 0x00: + case 0x02: + case 0x03: + return SMS_CODING_SCHEME_GSM7; + case 0x01: + if (dataCoding == 0x10) + return SMS_CODING_SCHEME_GSM7; + if (dataCoding == 0x11) + return SMS_CODING_SCHEME_UCS2; + break; + case 0x04: + case 0x05: + case 0x06: + case 0x07: + if (dataCoding & 0x20) + return SMS_CODING_SCHEME_UNKNOWN; + if (((dataCoding >> 2) & 3) == 0) + return SMS_CODING_SCHEME_GSM7; + if (((dataCoding >> 2) & 3) == 2) + return SMS_CODING_SCHEME_UCS2; + break; + case 0xF: + if (!(dataCoding & 4)) + return SMS_CODING_SCHEME_GSM7; + break; + } + return SMS_CODING_SCHEME_UNKNOWN; +} + @@ -28,4 +28,12 @@ int ascii2gsm7(char *data, unsigned char **data_enc, int length); void hex_dump(void *data, int size); int utf8_write(char *utf8, int offset, int v); +typedef enum { + SMS_CODING_SCHEME_UNKNOWN = 0, + SMS_CODING_SCHEME_GSM7, + SMS_CODING_SCHEME_UCS2 +} SmsCodingScheme; + +SmsCodingScheme sms_get_coding_scheme(int dataCoding); + #endif |