From: Michael Tremer Date: Thu, 4 Mar 2021 22:02:07 +0000 (+0000) Subject: execute: Pass string length to logging function X-Git-Tag: 0.9.28~1285^2~640 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cccbd595674e3e65be8c020641129323eb64439f;p=pakfire.git execute: Pass string length to logging function Signed-off-by: Michael Tremer --- diff --git a/src/_pakfire/pakfire.c b/src/_pakfire/pakfire.c index cfb3ce08c..dd568bfd7 100644 --- a/src/_pakfire/pakfire.c +++ b/src/_pakfire/pakfire.c @@ -372,7 +372,7 @@ static PyObject* Pakfire_make_path(PakfireObject* self, PyObject* args) { static PyObject* Pakfire_execute_logging_callback = NULL; static int __Pakfire_execute_logging_callback(Pakfire pakfire, void* data, - int priority, const char* line) { + int priority, const char* line, size_t length) { int r = 0; // Do nothing if callback isn't set diff --git a/src/libpakfire/execute.c b/src/libpakfire/execute.c index 8c2216f2f..c77b34e85 100644 --- a/src/libpakfire/execute.c +++ b/src/libpakfire/execute.c @@ -120,7 +120,7 @@ static int pakfire_execute_logger_proxy(Pakfire pakfire, int fd, line[length] = '\0'; // Log the line - int r = logging_callback(pakfire, data, priority, line); + int r = logging_callback(pakfire, data, priority, line, length); if (r) { ERROR(pakfire, "The logging callback returned an error: %d\n", r); return r; @@ -230,7 +230,8 @@ OUT: return r; } -static int default_logging_callback(Pakfire pakfire, void* data, int priority, const char* line) { +static int default_logging_callback(Pakfire pakfire, void* data, int priority, + const char* line, size_t length) { switch (priority) { case LOG_INFO: INFO(pakfire, "%s", line); diff --git a/src/libpakfire/include/pakfire/execute.h b/src/libpakfire/include/pakfire/execute.h index 1c4b79c1c..09e688ced 100644 --- a/src/libpakfire/include/pakfire/execute.h +++ b/src/libpakfire/include/pakfire/execute.h @@ -24,7 +24,7 @@ #include typedef int (*pakfire_execute_logging_callback)(Pakfire pakfire, void* data, - int priority, const char* line); + int priority, const char* line, size_t length); int pakfire_execute(Pakfire pakfire, const char* argv[], char* envp[], int flags, pakfire_execute_logging_callback logging_callback, void* data);