summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Tarasikov <alexander.tarasikov@gmail.com>2012-07-13 16:30:35 +0400
committerAlexander Tarasikov <alexander.tarasikov@gmail.com>2012-07-13 16:30:35 +0400
commit697e533e23e237cfba07b7054f5e4ab29e4227e2 (patch)
tree53e1ccc7d7fae2f3e1cd72f1d6771eb6af44d637
parent98a8d340281ed71aaa0130accd0061d818d46199 (diff)
downloadhardware_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.c38
-rw-r--r--util.c34
-rw-r--r--util.h8
3 files changed, 42 insertions, 38 deletions
diff --git a/ss.c b/ss.c
index 035c97a..eb6b441 100644
--- a/ss.c
+++ b/ss.c
@@ -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;
diff --git a/util.c b/util.c
index 798808d..47cb2c0 100644
--- a/util.c
+++ b/util.c
@@ -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;
+}
+
diff --git a/util.h b/util.h
index fc858d4..9d5e51b 100644
--- a/util.h
+++ b/util.h
@@ -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