aboutsummaryrefslogtreecommitdiffstats
path: root/samsung-ipc/call.c
diff options
context:
space:
mode:
Diffstat (limited to 'samsung-ipc/call.c')
-rw-r--r--samsung-ipc/call.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/samsung-ipc/call.c b/samsung-ipc/call.c
index 9573a8d..9d94931 100644
--- a/samsung-ipc/call.c
+++ b/samsung-ipc/call.c
@@ -36,3 +36,75 @@ void ipc_call_outgoing_setup(struct ipc_call_outgoing *message, unsigned char ty
strncpy(message->number, number, OUTGOING_NUMBER_MAX_LENGTH);
}
+/**
+ * Retrieve number of calls in list of calls.
+ **/
+unsigned int ipc_call_list_response_get_num_entries(struct ipc_response *response)
+{
+ unsigned int count = 0, n = 0;
+
+ assert(response != NULL);
+ assert(response->data != NULL);
+
+ count = (unsigned int) *((unsigned char*) response->data);
+ return count;
+}
+
+/**
+ * Retrieve one specific entry from a list of calls.
+ **/
+struct ipc_call_list_entry* ipc_call_list_response_get_entry(struct ipc_response *response, unsigned int num)
+{
+ unsigned int count = 0, pos = 1, n = 0;
+ struct ipc_call_list_entry *entry = NULL;
+
+ assert(response != NULL);
+ assert(response->data != NULL);
+
+ count = ipc_call_list_response_get_num_entries(response);
+ if (num > count)
+ return NULL;
+
+ for (n = 0; n < num; n++)
+ {
+ entry = (struct ipc_call_list_entry*) (response->data + pos);
+ pos += (unsigned int) (sizeof(struct ipc_call_list_entry) + entry->number_len);
+ }
+
+ return entry;
+}
+
+/**
+ * Retrieve the number of a call entry in the list of calls
+ **/
+char* ipc_call_list_response_get_entry_number(struct ipc_response *response, unsigned int num)
+{
+ unsigned int count = 0, pos = 1, n = 0;
+ struct ipc_call_list_entry *entry = NULL;
+ char *number = NULL;
+
+ assert(response != NULL);
+ assert(response->data != NULL);
+
+ count = ipc_call_list_response_get_num_entries(response);
+ if (num > count)
+ return NULL;
+
+ for (n = 0; n < num; n++)
+ {
+ entry = (struct ipc_call_list_entry*) (response->data + pos);
+ pos += (unsigned int) (sizeof(struct ipc_call_list_entry) + entry->number_len);
+ }
+
+ if (entry == NULL ||
+ (unsigned char*) (response->data + pos) == NULL ||
+ (unsigned char*) (response->data + pos + entry->number_len) == NULL)
+ return NULL;
+
+ number = (char*) malloc(sizeof(char) * entry->number_len);
+ strncpy(number, response->data + pos, entry->number_len);
+
+ return number;
+}
+
+