summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/syslog_relay.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/syslog_relay.c b/src/syslog_relay.c
index 579908c..c137297 100644
--- a/src/syslog_relay.c
+++ b/src/syslog_relay.c
@@ -2,7 +2,8 @@
* syslog_relay.c
* com.apple.syslog_relay service implementation.
*
- * Copyright (c) 2013 Martin Szulecki All Rights Reserved.
+ * Copyright (c) 2019-2020 Nikias Bassen, All Rights Reserved.
+ * Copyright (c) 2013-2015 Martin Szulecki, All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -33,6 +34,7 @@ struct syslog_relay_worker_thread {
syslog_relay_client_t client;
syslog_relay_receive_cb_t cbfunc;
void *user_data;
+ int is_raw;
};
/**
@@ -156,8 +158,12 @@ void *syslog_relay_worker(void *arg)
debug_info("Connection to syslog relay interrupted");
break;
}
- if(c != 0) {
+ if (srwt->is_raw) {
srwt->cbfunc(c, srwt->user_data);
+ } else {
+ if (c != 0) {
+ srwt->cbfunc(c, srwt->user_data);
+ }
}
}
@@ -188,6 +194,35 @@ LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_start_capture(syslog_rela
srwt->client = client;
srwt->cbfunc = callback;
srwt->user_data = user_data;
+ srwt->is_raw = 0;
+
+ if (thread_new(&client->worker, syslog_relay_worker, srwt) == 0) {
+ res = SYSLOG_RELAY_E_SUCCESS;
+ }
+ }
+
+ return res;
+}
+
+LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_start_capture_raw(syslog_relay_client_t client, syslog_relay_receive_cb_t callback, void* user_data)
+{
+ if (!client || !callback)
+ return SYSLOG_RELAY_E_INVALID_ARG;
+
+ syslog_relay_error_t res = SYSLOG_RELAY_E_UNKNOWN_ERROR;
+
+ if (client->worker) {
+ debug_info("Another syslog capture thread appears to be running already.");
+ return res;
+ }
+
+ /* start worker thread */
+ struct syslog_relay_worker_thread *srwt = (struct syslog_relay_worker_thread*)malloc(sizeof(struct syslog_relay_worker_thread));
+ if (srwt) {
+ srwt->client = client;
+ srwt->cbfunc = callback;
+ srwt->user_data = user_data;
+ srwt->is_raw = 1;
if (thread_new(&client->worker, syslog_relay_worker, srwt) == 0) {
res = SYSLOG_RELAY_E_SUCCESS;