2 * This file is part of libsamsung-ipc.
4 * Copyright (C) 2011 Simon Busch <morphis@gravedo.de>
5 * Copyright (C) 2013-2014 Paul Kocialkowsk <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 int ipc_call_outgoing_setup(struct ipc_call_outgoing_data *data,
27 unsigned char type, unsigned char identity, unsigned char prefix,
32 if (data == NULL || number == NULL)
35 number_length = strlen(number);
36 if (number_length > sizeof(data->number))
37 number_length = sizeof(data->number);
39 memset(data, 0, sizeof(struct ipc_call_outgoing_data));
41 data->identity = identity;
42 data->prefix = prefix;
43 data->number_length = (unsigned char) number_length;
45 strncpy((char *) data->number, number, number_length);
50 unsigned char ipc_call_list_count_extract(const void *data, size_t size)
52 struct ipc_call_list_header *header;
54 if (data == NULL || size < sizeof(struct ipc_call_list_header))
57 header = (struct ipc_call_list_header *) data;
62 struct ipc_call_list_entry *ipc_call_list_entry_extract(const void *data,
63 size_t size, unsigned int index)
65 struct ipc_call_list_entry *entry = NULL;
73 count = ipc_call_list_count_extract(data, size);
77 offset = sizeof(struct ipc_call_list_header);
79 for (i = 0; i < (index + 1); i++) {
80 entry = (struct ipc_call_list_entry *) ((unsigned char *) data + offset);
81 offset += sizeof(struct ipc_call_list_entry) + entry->number_length;
90 char *ipc_call_list_entry_number_extract(const struct ipc_call_list_entry *entry)
98 // entry->number_length doesn't count the final null character
99 number_length = entry->number_length + sizeof(char);
101 number = (char *) calloc(1, number_length);
103 strncpy(number, (char *) entry + sizeof(struct ipc_call_list_entry), entry->number_length);
104 number[entry->number_length] = '\0';
109 void *ipc_call_burst_dtmf_setup(const struct ipc_call_burst_dtmf_entry *entries,
112 struct ipc_call_burst_dtmf_header *header;
119 size = sizeof(struct ipc_call_burst_dtmf_header) + count * sizeof(struct ipc_call_burst_dtmf_entry);
121 data = calloc(1, size);
123 header = (struct ipc_call_burst_dtmf_header *) data;
124 header->count = count;
126 memcpy((void *) ((unsigned char *) data + sizeof(struct ipc_call_burst_dtmf_header)), entries, count * sizeof(struct ipc_call_burst_dtmf_entry));
131 // vim:ts=4:sw=4:expandtab