]> git.ipfire.org Git - pakfire.git/commitdiff
log stream: Move data as second argument of the callback
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 22 Mar 2025 16:29:34 +0000 (16:29 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 22 Mar 2025 16:33:02 +0000 (16:33 +0000)
That way, we are compatible with the PTY stdout callback.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/jail.c
src/pakfire/job.c
src/pakfire/log_stream.c
src/pakfire/log_stream.h
tests/libpakfire/log_stream.c

index 71d317dd41687d1a26d083b78d1679a040742975..d004c79c04a1bb3b6ab50d8e36659879a178f1ab 100644 (file)
@@ -353,21 +353,21 @@ static void pakfire_jail_log_redirect(void* data, int priority, const char* file
 /*
        Passes any log messages on to the context logger
 */
-static int pakfire_jail_INFO(struct pakfire_ctx* ctx, const char* line, size_t length, void* data) {
+static int pakfire_jail_INFO(struct pakfire_ctx* ctx, void* data, const char* line, size_t length) {
        struct pakfire_jail* jail = data;
 
        INFO(jail->ctx, "%.*s", (int)length, line);
        return 0;
 }
 
-static int pakfire_jail_WARN(struct pakfire_ctx* ctx, const char* line, size_t length, void* data) {
+static int pakfire_jail_WARN(struct pakfire_ctx* ctx, void* data, const char* line, size_t length) {
        struct pakfire_jail* jail = data;
 
        ERROR(jail->ctx, "%.*s", (int)length, line);
        return 0;
 }
 
-static int pakfire_jail_ERROR(struct pakfire_ctx* ctx, const char* line, size_t length, void* data) {
+static int pakfire_jail_ERROR(struct pakfire_ctx* ctx, void* data, const char* line, size_t length) {
        struct pakfire_jail* jail = data;
 
        ERROR(jail->ctx, "%.*s", (int)length, line);
@@ -375,7 +375,7 @@ static int pakfire_jail_ERROR(struct pakfire_ctx* ctx, const char* line, size_t
 }
 
 #ifdef ENABLE_DEBUG
-static int pakfire_jail_DEBUG(struct pakfire_ctx* ctx, const char* line, size_t length, void* data) {
+static int pakfire_jail_DEBUG(struct pakfire_ctx* ctx, void* data, const char* line, size_t length) {
        struct pakfire_jail* jail = data;
 
        DEBUG(jail->ctx, "%.*s", (int)length, line);
index 8d6cd15e468975524829b14f0a30ce93633611f8..d9764e5df19a5b0cbf757aa17d5eeb46be304842 100644 (file)
@@ -526,7 +526,7 @@ static int pakfire_job_send_log(struct pakfire_job* job, int priority, const cha
 }
 
 static int pakfire_job_stdout(struct pakfire_ctx* ctx,
-               const char* line, size_t length, void* data) {
+               void* data, const char* line, size_t length) {
        struct pakfire_job* job = data;
 
        // Send the output to the build service
@@ -534,7 +534,7 @@ static int pakfire_job_stdout(struct pakfire_ctx* ctx,
 }
 
 static int pakfire_job_stderr(struct pakfire_ctx* ctx,
-               const char* line, size_t length, void* data) {
+               void* data, const char* line, size_t length) {
        struct pakfire_job* job = data;
 
        // Send the output to the build service
index 75c60ef8a6ec656f415af31b0f2a4a69524b4563..2cf3683244ceba0d37de04ca4cceac1ce19d7c06 100644 (file)
@@ -279,7 +279,7 @@ static int pakfire_log_stream_drain_buffer(struct pakfire_log_stream* stream) {
                        return r;
 
                // Call the callback
-               r = stream->callback(stream->ctx, line, r, stream->data);
+               r = stream->callback(stream->ctx, stream->data, line, r);
                if (r)
                        return r;
 
index 8328edb7215020fe6106af693f063fb6d1c665a6..91b4ce219a82aa5bc330c87fd2728274db35e566 100644 (file)
@@ -30,7 +30,7 @@
 struct pakfire_log_stream;
 
 typedef int (*pakfire_log_stream_callback)(struct pakfire_ctx* ctx,
-       const char* line, size_t length, void* data);
+       void* data, const char* line, size_t length);
 
 int pakfire_log_stream_create(struct pakfire_log_stream** stream, struct pakfire_ctx* ctx,
        pakfire_log_stream_callback callback, void* data);
index bd75bf53ff1a1c0c90939914cc6d8c62de59ded4..e19eae3faaa73e21c0b52e436d317d3168d6cd6e 100644 (file)
@@ -24,7 +24,7 @@
 #include "../testsuite.h"
 
 static int log_callback(struct pakfire_ctx* ctx,
-               const char* line, size_t length, void* data) {
+               void* data, const char* line, size_t length) {
        int* lines_read = data;
 
        // Increment the counter