summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrzej Zaborowski <andrew.zaborowski@intel.com>2009-08-05 09:08:40 +0200
committerDenis Kenzior <denkenz@gmail.com>2009-08-05 13:17:08 -0500
commit4c3ae72b367ed827df7d746fd34493e4addea151 (patch)
treeca8c919f2777b83e97ece49b79c2e1cce3542536 /src
parent965fc09e6a8555a8d5f41d4b86aca28904d05812 (diff)
downloadofono-4c3ae72b367ed827df7d746fd34493e4addea151.tar.bz2
Add encode_bcd_number utility function
Diffstat (limited to 'src')
-rw-r--r--src/smsutil.c11
-rw-r--r--src/smsutil.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/src/smsutil.c b/src/smsutil.c
index ad38ed98..1eb4e3c8 100644
--- a/src/smsutil.c
+++ b/src/smsutil.c
@@ -110,6 +110,17 @@ static inline int to_semi_oct(char in)
return digit;
}
+void encode_bcd_number(const char *number, unsigned char *out)
+{
+ while (number[0] != '\0' && number[1] != '\0') {
+ *out = to_semi_oct(*number++);
+ *out++ |= to_semi_oct(*number++) << 4;
+ }
+
+ if (*number)
+ *out = to_semi_oct(*number) | 0xf0;
+}
+
/* Returns whether the DCS could be parsed successfully, e.g. no reserved
* values were used
*/
diff --git a/src/smsutil.h b/src/smsutil.h
index d362aa98..4a392665 100644
--- a/src/smsutil.h
+++ b/src/smsutil.h
@@ -401,6 +401,7 @@ static inline unsigned char bit_field(unsigned char oct, int start, int num)
}
void extract_bcd_number(const unsigned char *buf, int len, char *out);
+void encode_bcd_number(const char *number, unsigned char *out);
gboolean sms_decode(const unsigned char *pdu, int len, gboolean outgoing,
int tpdu_len, struct sms *out);