Move SmsCodingScheme to utils.c for future reuse
authorAlexander Tarasikov <alexander.tarasikov@gmail.com>
Fri, 13 Jul 2012 12:30:35 +0000 (16:30 +0400)
committerAlexander Tarasikov <alexander.tarasikov@gmail.com>
Fri, 13 Jul 2012 12:30:35 +0000 (16:30 +0400)
ss.c
util.c
util.h

diff --git a/ss.c b/ss.c
index 035c97a..eb6b441 100644 (file)
--- 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 (file)
--- 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 (file)
--- 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