aboutsummaryrefslogtreecommitdiffstats
path: root/samsung-ipc
diff options
context:
space:
mode:
authorSimon Busch <morphis@gravedo.de>2011-10-14 16:15:41 +0200
committerSimon Busch <morphis@gravedo.de>2011-10-14 16:15:41 +0200
commite7d27d22237996dbc204cfc46ee08855952c15ef (patch)
tree985dcb13c75ba82842fa4d59b6cdb4d713455d84 /samsung-ipc
parent27ff8ab83b353310a79a5277cff0dd8edffb17cd (diff)
downloadexternal_libsamsung-ipc-e7d27d22237996dbc204cfc46ee08855952c15ef.zip
external_libsamsung-ipc-e7d27d22237996dbc204cfc46ee08855952c15ef.tar.gz
external_libsamsung-ipc-e7d27d22237996dbc204cfc46ee08855952c15ef.tar.bz2
Implement log handler delegate the user can set to forwarding logging output to another target
Signed-off-by: Simon Busch <morphis@gravedo.de>
Diffstat (limited to 'samsung-ipc')
-rw-r--r--samsung-ipc/ipc.c24
-rw-r--r--samsung-ipc/ipc_private.h5
2 files changed, 29 insertions, 0 deletions
diff --git a/samsung-ipc/ipc.c b/samsung-ipc/ipc.c
index d53ae5a..5c3639c 100644
--- a/samsung-ipc/ipc.c
+++ b/samsung-ipc/ipc.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <assert.h>
#include <radio.h>
@@ -31,6 +32,18 @@ extern struct ipc_ops crespo_ipc_ops;
// extern struct ipc_ops h1_ipc_ops;
+void log_handler_default(const char *message, void *user_data)
+{
+ printf("%s\n", message);
+}
+
+void ipc_client_log(struct ipc_client *client, const char *message, ...)
+{
+ assert(client->log_handler != NULL);
+ // FIXME construct message with additional arguments!
+ client->log_handler(message, client->log_data);
+}
+
struct ipc_client* ipc_client_new(int client_type)
{
struct ipc_client *client;
@@ -52,6 +65,7 @@ struct ipc_client* ipc_client_new(int client_type)
client = (struct ipc_client*) malloc(sizeof(struct ipc_client));
client->type = client_type;
client->ops = ops;
+ client->log_handler = log_handler_default;
return client;
}
@@ -63,6 +77,16 @@ int ipc_client_free(struct ipc_client *client)
return 0;
}
+int ipc_client_set_log_handler(struct ipc_client *client, ipc_client_log_handler_cb log_handler_cb, void *user_data)
+{
+ if (client == NULL)
+ return -1;
+
+ client->log_handler = log_handler_cb;
+ client->log_data = user_data;
+}
+
+
int ipc_client_set_delegates(struct ipc_client *client,
ipc_client_transport_cb write, void *write_data,
ipc_client_transport_cb read, void *read_data)
diff --git a/samsung-ipc/ipc_private.h b/samsung-ipc/ipc_private.h
index 1efcd26..d724781 100644
--- a/samsung-ipc/ipc_private.h
+++ b/samsung-ipc/ipc_private.h
@@ -23,6 +23,8 @@
struct ipc_client;
+void ipc_client_log(struct ipc_client *client, const char *message, ...);
+
struct ipc_ops {
int (*bootstrap)(struct ipc_client *client);
int (*open)(struct ipc_client *client);
@@ -40,6 +42,9 @@ struct ipc_client {
ipc_client_transport_cb write;
void *write_data;
+ ipc_client_log_handler_cb log_handler;
+ void *log_data;
+
struct ipc_ops *ops;
};