aboutsummaryrefslogtreecommitdiffstats
path: root/libexec_send_document.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libexec_send_document.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/libexec_send_document.c b/libexec_send_document.c
new file mode 100644
index 0000000..e69ad72
--- /dev/null
+++ b/libexec_send_document.c
@@ -0,0 +1,26 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+#ifndef TEST
+
+
+int
+libexec_send_document(struct libexec_document *doc)
+{
+ ssize_t r;
+ if (!doc) {
+ errno = EINVAL;
+ return -1;
+ }
+ while (doc->offset < doc->length) {
+ r = write(doc->fd, &doc->text[doc->offset], doc->length - doc->offset);
+ if (r < 0)
+ return -1;
+ doc->offset += (size_t)r;
+ }
+ return 0;
+}
+
+
+#else
+LIBEXEC_CONST__ int main(void) {return 0;} /* TODO test */
+#endif