// We are now ready to write
pty->stdout.io |= PAKFIRE_PTY_READY_TO_WRITE|PAKFIRE_PTY_MAP_CRNL;
}
+
+ssize_t pakfire_pty_send_buffer(struct pakfire_ctx* ctx,
+ void* data, char* buffer, size_t length) {
+ struct pakfire_pty_buffer* input = data;
+
+ // Check input
+ if (!input)
+ return -EINVAL;
+
+ // If there is nothing left to send we are done
+ if (!input->length)
+ return 0;
+
+ // Cap length if we have less data to send
+ if (input->length < length)
+ length = input->length;
+
+ // Copy the data
+ memcpy(buffer, input->data, length);
+
+ // Advance the buffer
+ input->data += length;
+ input->length -= length;
+
+ return length;
+}
void pakfire_pty_set_stdout_callback(struct pakfire_pty* pty,
pakfire_pty_stdout_callback callback, void* data);
+struct pakfire_pty_buffer {
+ const char* data;
+ size_t length;
+};
+
+ssize_t pakfire_pty_send_buffer(struct pakfire_ctx* ctx,
+ void* data, char* buffer, size_t length);
+
#endif /* PAKFIRE_PTY_H */