diff options
author | Paul Kocialkowski <contact@paulk.fr> | 2014-07-26 12:52:43 +0200 |
---|---|---|
committer | Paul Kocialkowski <contact@paulk.fr> | 2014-07-26 12:52:43 +0200 |
commit | 285ef23602be46c066aaed450fda8e9ec102bfdb (patch) | |
tree | 9a9788ff7cd9d7189495b7a103a6857d2a6af100 | |
parent | c0eabb682988712185515a8ea8c360fd72d74811 (diff) | |
download | external_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>
-rw-r--r-- | include/sms.h | 8 | ||||
-rw-r--r-- | samsung-ipc/sms.c | 73 |
2 files changed, 69 insertions, 12 deletions
diff --git a/include/sms.h b/include/sms.h index b1b7518..5dd4b9f 100644 --- a/include/sms.h +++ b/include/sms.h @@ -92,7 +92,7 @@ struct ipc_sms_incoming_msg_header { unsigned char length; } __attribute__((__packed__)); -struct ipc_sms_save_msg_request_data { +struct ipc_sms_save_msg_request_header { unsigned char magic; unsigned short index; unsigned char status; // IPC_SMS_STATUS @@ -136,8 +136,12 @@ struct ipc_sms_svc_center_addr_header { */ 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); char *ipc_sms_incoming_msg_pdu_extract(const void *data, size_t size); +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); +int ipc_sms_del_msg_setup(struct ipc_sms_del_msg_request_data *data, + unsigned short index); #endif 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 |