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>
27 void *ipc_sms_send_msg_setup(struct ipc_sms_send_msg_request_header *header,
28 const char *smsc, const char *pdu)
32 unsigned char smsc_length;
35 if (header == NULL || smsc == NULL || pdu == NULL)
38 smsc_length = (unsigned char) strlen(smsc);
40 size = sizeof(struct ipc_sms_send_msg_request_header) + sizeof(smsc_length) + strlen(smsc) + strlen(pdu);
41 header->length = (unsigned char) size;
43 data = calloc(1, size);
45 p = (unsigned char *) data;
47 memcpy(p, header, sizeof(struct ipc_sms_send_msg_request_header));
48 p += sizeof(struct ipc_sms_send_msg_request_header);
50 memcpy(p, &smsc_length, sizeof(smsc_length));
51 p += sizeof(smsc_length);
53 memcpy(p, smsc, smsc_length);
56 memcpy(p, pdu, strlen(pdu));
62 char *ipc_sms_incoming_msg_pdu_extract(const void *data, size_t size)
64 struct ipc_sms_incoming_msg_header *header;
68 if (data == NULL || size < sizeof(struct ipc_sms_incoming_msg_header))
71 header = (struct ipc_sms_incoming_msg_header *) data;
72 if (header->length == 0 || header->length > size - sizeof(struct ipc_sms_incoming_msg_header))
75 pdu = (void *) ((unsigned char *) data + sizeof(struct ipc_sms_incoming_msg_header));
77 string = data2string(pdu, header->length);
82 // vim:ts=4:sw=4:expandtab