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 void *smsc, size_t smsc_size, const void *pdu, size_t pdu_size)
32 unsigned char smsc_length;
35 if (header == NULL || smsc == NULL || smsc_size == 0 || pdu == NULL || pdu_size == 0)
38 smsc_length = (unsigned char) smsc_size;
40 header->length = (unsigned char) (sizeof(smsc_length) + smsc_size + pdu_size);
42 size = sizeof(struct ipc_sms_send_msg_request_header) + sizeof(smsc_length) + smsc_size + pdu_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_size);
56 memcpy(p, pdu, pdu_size);
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 void *ipc_sms_save_msg_setup(struct ipc_sms_save_msg_request_header *header,
83 const void *smsc, size_t smsc_size, const void *pdu, size_t pdu_size)
87 unsigned char smsc_length;
90 if (header == NULL || pdu == NULL || pdu_size == 0)
96 smsc_length = (unsigned char) smsc_size;
99 header->index = 12 - 1,
100 header->length = (unsigned char) (sizeof(smsc_length) + smsc_size + pdu_size);
102 size = sizeof(struct ipc_sms_save_msg_request_header) + sizeof(smsc_length) + smsc_size + pdu_size;
103 data = calloc(1, size);
105 p = (unsigned char *) data;
107 memcpy(p, header, sizeof(struct ipc_sms_save_msg_request_header));
108 p += sizeof(struct ipc_sms_save_msg_request_header);
110 memcpy(p, &smsc_length, sizeof(smsc_length));
111 p += sizeof(smsc_length);
113 memcpy(p, smsc, smsc_size);
116 memcpy(p, pdu, pdu_size);
122 int ipc_sms_del_msg_setup(struct ipc_sms_del_msg_request_data *data,
123 unsigned short index)
128 memset(data, 0, sizeof(struct ipc_sms_del_msg_request_data));
135 // vim:ts=4:sw=4:expandtab