* 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;
}
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;
// 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);