diff options
-rw-r--r-- | samsung-ipc/call.c | 156 |
1 files changed, 82 insertions, 74 deletions
diff --git a/samsung-ipc/call.c b/samsung-ipc/call.c index b0720ad..1c732c5 100644 --- a/samsung-ipc/call.c +++ b/samsung-ipc/call.c @@ -24,123 +24,131 @@ #include <samsung-ipc.h> int ipc_call_outgoing_setup(struct ipc_call_outgoing_data *data, - unsigned char type, unsigned char identity, unsigned char prefix, - const char *number) + unsigned char type, unsigned char identity, + unsigned char prefix, const char *number) { - size_t number_length; + size_t number_length; - if (data == NULL || number == NULL) - return -1; + if (data == NULL || number == NULL) + return -1; - number_length = strlen(number); - if (number_length > sizeof(data->number)) - number_length = sizeof(data->number); + number_length = strlen(number); + if (number_length > sizeof(data->number)) + number_length = sizeof(data->number); - memset(data, 0, sizeof(struct ipc_call_outgoing_data)); - data->type = type; - data->identity = identity; - data->prefix = prefix; - data->number_length = (unsigned char) number_length; + memset(data, 0, sizeof(struct ipc_call_outgoing_data)); + data->type = type; + data->identity = identity; + data->prefix = prefix; + data->number_length = (unsigned char) number_length; - strncpy((char *) data->number, number, number_length); + strncpy((char *) data->number, number, number_length); - return 0; + return 0; } unsigned char ipc_call_list_count_extract(const void *data, size_t size) { - struct ipc_call_list_header *header; + struct ipc_call_list_header *header; - if (data == NULL || size < sizeof(struct ipc_call_list_header)) - return 0; + if (data == NULL || size < sizeof(struct ipc_call_list_header)) + return 0; - header = (struct ipc_call_list_header *) data; + header = (struct ipc_call_list_header *) data; - return header->count; + return header->count; } -struct ipc_call_list_entry *ipc_call_list_entry_extract(const void *data, - size_t size, unsigned int index) +struct ipc_call_list_entry *ipc_call_list_entry_extract( + const void *data, size_t size, unsigned int index) { - struct ipc_call_list_entry *entry = NULL; - unsigned char count; - unsigned char i; - unsigned int offset; + struct ipc_call_list_entry *entry = NULL; + unsigned char count; + unsigned char i; + unsigned int offset; - if (data == NULL) - return NULL; + if (data == NULL) + return NULL; - count = ipc_call_list_count_extract(data, size); - if (count == 0 || index >= count) - return NULL; + count = ipc_call_list_count_extract(data, size); + if (count == 0 || index >= count) + return NULL; - offset = sizeof(struct ipc_call_list_header); + offset = sizeof(struct ipc_call_list_header); - for (i = 0; i < (index + 1); i++) { - entry = (struct ipc_call_list_entry *) ((unsigned char *) data + offset); - offset += sizeof(struct ipc_call_list_entry) + entry->number_length; - } + for (i = 0; i < (index + 1); i++) { + entry = (struct ipc_call_list_entry *) ( + (unsigned char *) data + offset); + offset += sizeof(struct ipc_call_list_entry) + + entry->number_length; + } - if (offset > size) - return NULL; + if (offset > size) + return NULL; - return entry; + return entry; } -char *ipc_call_list_entry_number_extract(const struct ipc_call_list_entry *entry) +char *ipc_call_list_entry_number_extract( + const struct ipc_call_list_entry *entry) { - char *number; - size_t number_length; + char *number; + size_t number_length; - if (entry == NULL) - return NULL; + if (entry == NULL) + return NULL; - // entry->number_length doesn't count the final null character - number_length = entry->number_length + sizeof(char); + /* entry->number_length doesn't count the final null character */ + number_length = entry->number_length + sizeof(char); - number = (char *) calloc(1, number_length); + number = (char *) calloc(1, number_length); - strncpy(number, (char *) entry + sizeof(struct ipc_call_list_entry), entry->number_length); - number[entry->number_length] = '\0'; + strncpy(number, (char *) entry + sizeof(struct ipc_call_list_entry), + entry->number_length); + number[entry->number_length] = '\0'; - return number; + return number; } -size_t ipc_call_burst_dtmf_size_setup(const struct ipc_call_burst_dtmf_request_entry *entries, - unsigned char count) +size_t ipc_call_burst_dtmf_size_setup( + const struct ipc_call_burst_dtmf_request_entry *entries, + unsigned char count) { - size_t size; + size_t size; - if (entries == NULL) - return 0; + if (entries == NULL) + return 0; - size = sizeof(struct ipc_call_burst_dtmf_request_header) + count * sizeof(struct ipc_call_burst_dtmf_request_entry); + size = sizeof(struct ipc_call_burst_dtmf_request_header) + count * + sizeof(struct ipc_call_burst_dtmf_request_entry); - return size; + return size; } -void *ipc_call_burst_dtmf_setup(const struct ipc_call_burst_dtmf_request_entry *entries, - unsigned char count) +void *ipc_call_burst_dtmf_setup( + const struct ipc_call_burst_dtmf_request_entry *entries, + unsigned char count) { - struct ipc_call_burst_dtmf_request_header *header; - void *data; - size_t size; + struct ipc_call_burst_dtmf_request_header *header; + void *data; + size_t size; - if (entries == NULL) - return NULL; + if (entries == NULL) + return NULL; - size = ipc_call_burst_dtmf_size_setup(entries, count); - if (size == 0) - return NULL; + size = ipc_call_burst_dtmf_size_setup(entries, count); + if (size == 0) + return NULL; - data = calloc(1, size); + data = calloc(1, size); - header = (struct ipc_call_burst_dtmf_request_header *) data; - header->count = count; + header = (struct ipc_call_burst_dtmf_request_header *) data; + header->count = count; - memcpy((void *) ((unsigned char *) data + sizeof(struct ipc_call_burst_dtmf_request_header)), entries, count * sizeof(struct ipc_call_burst_dtmf_request_entry)); + memcpy((void *) ((unsigned char *) data + + sizeof(struct ipc_call_burst_dtmf_request_header)), + entries, + count * sizeof(struct ipc_call_burst_dtmf_request_entry)); - return data; + return data; } - -// vim:ts=4:sw=4:expandtab |