From 28d8132ed039d3968d88076953b4eecd76dead90 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 22 Mar 2025 16:35:57 +0000 Subject: [PATCH] python: execute: Use the send buffer callback we already have Signed-off-by: Michael Tremer --- src/python/pakfire.c | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/src/python/pakfire.c b/src/python/pakfire.c index 104bbe36..e5358716 100644 --- a/src/python/pakfire.c +++ b/src/python/pakfire.c @@ -533,33 +533,6 @@ ERROR: * Execute */ -struct Pakfire_execute_input { - const char* data; - size_t length; -}; - -static ssize_t Pakfire_execute_stdin_callback( - struct pakfire_ctx* ctx, void* data, char* buffer, size_t length) { - struct Pakfire_execute_input* input = data; - - // Return zero if we are done writing the input - if (!input->length) - return 0; - - // Cap the memory if we have less input - if (input->length < length) - length = input->length; - - // Copy the data into the output buffer - memcpy(buffer, input->data, length); - - // Move the pointer forward - input->data += length; - input->length -= length; - - return length; -} - static int Pakfire_execute_stdout_callback( struct pakfire_ctx* ctx, void* data, const char* line, const size_t length) { PyObject** output = data; @@ -577,7 +550,7 @@ static int Pakfire_execute_stdout_callback( } static PyObject* Pakfire_execute(PakfireObject* self, PyObject* args, PyObject* kwargs) { - struct Pakfire_execute_input input = {}; + struct pakfire_pty_buffer input = {}; struct pakfire_jail* jail = NULL; struct pakfire_env* env = NULL; const char** argv = NULL; @@ -683,7 +656,7 @@ static PyObject* Pakfire_execute(PakfireObject* self, PyObject* args, PyObject* // Register the input callback if (input.data) - stdin_callback = Pakfire_execute_stdin_callback; + stdin_callback = pakfire_pty_send_buffer; // Create a new jail r = pakfire_jail_create(&jail, self->pakfire); -- 2.39.5