2 * This file is part of libsamsung-ipc.
4 * Copyright (C) 2011 Simon Busch <morphis@gravedo.de>
5 * Copyright (C) 2014 Paul Kocialkowski <contact@paulk.fr>
7 * libsamsung-ipc is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 2 of the License, or
10 * (at your option) any later version.
12 * libsamsung-ipc is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with libsamsung-ipc. If not, see <http://www.gnu.org/licenses/>.
24 #include <samsung-ipc.h>
26 void *ipc_sms_send_msg_setup(struct ipc_sms_send_msg_request_header *header,
27 const void *smsc, size_t smsc_size, const void *pdu, size_t pdu_size)
31 unsigned char smsc_length;
34 if (header == NULL || smsc == NULL || smsc_size == 0 || pdu == NULL || pdu_size == 0)
37 smsc_length = (unsigned char) smsc_size;
39 header->length = (unsigned char) (sizeof(smsc_length) + smsc_size + pdu_size);
41 size = sizeof(struct ipc_sms_send_msg_request_header) + sizeof(smsc_length) + smsc_size + pdu_size;
42 data = calloc(1, size);
44 p = (unsigned char *) data;
46 memcpy(p, header, sizeof(struct ipc_sms_send_msg_request_header));
47 p += sizeof(struct ipc_sms_send_msg_request_header);
49 memcpy(p, &smsc_length, sizeof(smsc_length));
50 p += sizeof(smsc_length);
52 memcpy(p, smsc, smsc_size);
55 memcpy(p, pdu, pdu_size);
61 char *ipc_sms_incoming_msg_pdu_extract(const void *data, size_t size)
63 struct ipc_sms_incoming_msg_header *header;
67 if (data == NULL || size < sizeof(struct ipc_sms_incoming_msg_header))
70 header = (struct ipc_sms_incoming_msg_header *) data;
71 if (header->length == 0 || header->length > size - sizeof(struct ipc_sms_incoming_msg_header))
74 pdu = (void *) ((unsigned char *) data + sizeof(struct ipc_sms_incoming_msg_header));
76 string = data2string(pdu, header->length);
81 void *ipc_sms_save_msg_setup(struct ipc_sms_save_msg_request_header *header,
82 const void *smsc, size_t smsc_size, const void *pdu, size_t pdu_size)
86 unsigned char smsc_length;
89 if (header == NULL || pdu == NULL || pdu_size == 0)
95 smsc_length = (unsigned char) smsc_size;
98 header->index = 12 - 1,
99 header->length = (unsigned char) (sizeof(smsc_length) + smsc_size + pdu_size);
101 size = sizeof(struct ipc_sms_save_msg_request_header) + sizeof(smsc_length) + smsc_size + pdu_size;
102 data = calloc(1, size);
104 p = (unsigned char *) data;
106 memcpy(p, header, sizeof(struct ipc_sms_save_msg_request_header));
107 p += sizeof(struct ipc_sms_save_msg_request_header);
109 memcpy(p, &smsc_length, sizeof(smsc_length));
110 p += sizeof(smsc_length);
112 if (smsc != NULL && smsc_size > 0) {
113 memcpy(p, smsc, smsc_size);
117 memcpy(p, pdu, pdu_size);
123 int ipc_sms_del_msg_setup(struct ipc_sms_del_msg_request_data *data,
124 unsigned short index)
129 memset(data, 0, sizeof(struct ipc_sms_del_msg_request_data));
136 // vim:ts=4:sw=4:expandtab