]> git.ipfire.org Git - people/ms/pakfire.git/commitdiff
execute: Pass string length to logging function
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 4 Mar 2021 22:02:07 +0000 (22:02 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 4 Mar 2021 22:02:07 +0000 (22:02 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/pakfire.c
src/libpakfire/execute.c
src/libpakfire/include/pakfire/execute.h

index cfb3ce08c3ee598a42336092a7b2a1034f4bd57c..dd568bfd76394f91319178acb04550f837bef030 100644 (file)
@@ -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
index 8c2216f2f7b2ab50eb6cc1de8ab284321d8e324b..c77b34e85d6cfce22c20a477943fa9f7ffed90cb 100644 (file)
@@ -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);
index 1c4b79c1cdf4da97f1c9df11f7b9eb62de9ef74d..09e688ced7661c7c4aa92c68c7e5f71cae507889 100644 (file)
@@ -24,7 +24,7 @@
 #include <pakfire/types.h>
 
 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);