aboutsummaryrefslogtreecommitdiffstats
path: root/samsung-ipc
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2014-07-26 12:52:43 +0200
committerPaul Kocialkowski <contact@paulk.fr>2014-07-26 12:52:43 +0200
commit285ef23602be46c066aaed450fda8e9ec102bfdb (patch)
tree9a9788ff7cd9d7189495b7a103a6857d2a6af100 /samsung-ipc
parentc0eabb682988712185515a8ea8c360fd72d74811 (diff)
downloadexternal_libsamsung-ipc-285ef23602be46c066aaed450fda8e9ec102bfdb.zip
external_libsamsung-ipc-285ef23602be46c066aaed450fda8e9ec102bfdb.tar.gz
external_libsamsung-ipc-285ef23602be46c066aaed450fda8e9ec102bfdb.tar.bz2
sms: Save/del msg helpers, send msg correction
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Diffstat (limited to 'samsung-ipc')
-rw-r--r--samsung-ipc/sms.c73
1 files changed, 63 insertions, 10 deletions
diff --git a/samsung-ipc/sms.c b/samsung-ipc/sms.c
index 6743776..ace6390 100644
--- a/samsung-ipc/sms.c
+++ b/samsung-ipc/sms.c
@@ -25,21 +25,21 @@
#include <utils.h>
void *ipc_sms_send_msg_setup(struct ipc_sms_send_msg_request_header *header,
- const char *smsc, const char *pdu)
+ const void *smsc, size_t smsc_size, const void *pdu, size_t pdu_size)
{
void *data;
size_t size;
unsigned char smsc_length;
unsigned char *p;
- if (header == NULL || smsc == NULL || pdu == NULL)
- return NULL;
+ if (header == NULL || smsc == NULL || smsc_size == 0 || pdu == NULL || pdu_size == 0)
+ return NULL;
- smsc_length = (unsigned char) strlen(smsc);
+ smsc_length = (unsigned char) smsc_size;
- size = sizeof(struct ipc_sms_send_msg_request_header) + sizeof(smsc_length) + strlen(smsc) + strlen(pdu);
- header->length = (unsigned char) size;
+ header->length = (unsigned char) (sizeof(smsc_length) + smsc_size + pdu_size);
+ size = sizeof(struct ipc_sms_send_msg_request_header) + sizeof(smsc_length) + smsc_size + pdu_size;
data = calloc(1, size);
p = (unsigned char *) data;
@@ -50,11 +50,11 @@ void *ipc_sms_send_msg_setup(struct ipc_sms_send_msg_request_header *header,
memcpy(p, &smsc_length, sizeof(smsc_length));
p += sizeof(smsc_length);
- memcpy(p, smsc, smsc_length);
- p += smsc_length;
+ memcpy(p, smsc, smsc_size);
+ p += smsc_size;
- memcpy(p, pdu, strlen(pdu));
- p += strlen(pdu);
+ memcpy(p, pdu, pdu_size);
+ p += pdu_size;
return data;
}
@@ -79,4 +79,57 @@ char *ipc_sms_incoming_msg_pdu_extract(const void *data, size_t size)
return string;
}
+void *ipc_sms_save_msg_setup(struct ipc_sms_save_msg_request_header *header,
+ const void *smsc, size_t smsc_size, const void *pdu, size_t pdu_size)
+{
+ void *data;
+ size_t size;
+ unsigned char smsc_length;
+ unsigned char *p;
+
+ if (header == NULL || pdu == NULL || pdu_size == 0)
+ return NULL;
+
+ if (smsc == NULL)
+ smsc_size = 0;
+
+ smsc_length = (unsigned char) smsc_size;
+
+ header->magic = 2;
+ header->index = 12 - 1,
+ header->length = (unsigned char) (sizeof(smsc_length) + smsc_size + pdu_size);
+
+ size = sizeof(struct ipc_sms_save_msg_request_header) + sizeof(smsc_length) + smsc_size + pdu_size;
+ data = calloc(1, size);
+
+ p = (unsigned char *) data;
+
+ memcpy(p, header, sizeof(struct ipc_sms_save_msg_request_header));
+ p += sizeof(struct ipc_sms_save_msg_request_header);
+
+ memcpy(p, &smsc_length, sizeof(smsc_length));
+ p += sizeof(smsc_length);
+
+ memcpy(p, smsc, smsc_size);
+ p += smsc_size;
+
+ memcpy(p, pdu, pdu_size);
+ p += pdu_size;
+
+ return data;
+}
+
+int ipc_sms_del_msg_setup(struct ipc_sms_del_msg_request_data *data,
+ unsigned short index)
+{
+ if (data == NULL)
+ return -1;
+
+ memset(data, 0, sizeof(struct ipc_sms_del_msg_request_data));
+ data->magic = 2;
+ data->index = index;
+
+ return 0;
+}
+
// vim:ts=4:sw=4:expandtab