diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/skalibs/disize.h | 2 | ||||
-rw-r--r-- | src/include/skalibs/unix-timed.h | 4 | ||||
-rw-r--r-- | src/libunixonacid/buffer_timed_put.c | 17 | ||||
-rw-r--r-- | src/libunixonacid/buffer_timed_puts.c | 10 |
4 files changed, 32 insertions, 1 deletions
diff --git a/src/include/skalibs/disize.h b/src/include/skalibs/disize.h index 0b3cd23..eef82f3 100644 --- a/src/include/skalibs/disize.h +++ b/src/include/skalibs/disize.h @@ -3,7 +3,7 @@ #ifndef SKALIBS_DISIZE_H #define SKALIBS_DISIZE_H -#include <sys/types.h> +#include <stddef.h> typedef struct disize_s disize, *disize_ref ; struct disize_s diff --git a/src/include/skalibs/unix-timed.h b/src/include/skalibs/unix-timed.h index ffff5c3..ca3d9c7 100644 --- a/src/include/skalibs/unix-timed.h +++ b/src/include/skalibs/unix-timed.h @@ -28,6 +28,10 @@ extern int buffer_timed_flush (buffer *, tain const *, tain *) ; #define buffer_timed_flush_g(b, deadline) buffer_timed_flush(b, (deadline), &STAMP) extern size_t buffer_timed_get (buffer *, char *, size_t, tain const *, tain *) ; #define buffer_timed_get_g(b, buf, buflen, deadline) buffer_timed_get(b, buf, buflen, (deadline), &STAMP) +extern size_t buffer_timed_put (buffer *, char const *, size_t, tain const *, tain *) ; +#define buffer_timed_put_g(b, s, len, deadline) buffer_timed_put(b, s, len, (deadline), &STAMP) +extern size_t buffer_timed_puts (buffer *, char const *, tain const *, tain *) ; +#define buffer_timed_puts_g(b, s, deadline) buffer_timed_puts(b, s, (deadline), &STAMP) extern int timed_getln (buffer *, stralloc *, char, tain const *, tain *) ; #define timed_getln_g(b, sa, sep, deadline) timed_getln(b, sa, sep, (deadline), &STAMP) diff --git a/src/libunixonacid/buffer_timed_put.c b/src/libunixonacid/buffer_timed_put.c new file mode 100644 index 0000000..a645465 --- /dev/null +++ b/src/libunixonacid/buffer_timed_put.c @@ -0,0 +1,17 @@ +/* ISC license. */ + +#include <stddef.h> + +#include <skalibs/buffer.h> +#include <skalibs/unix-timed.h> + +size_t buffer_timed_put (buffer *b, char const *s, size_t len, tain const *deadline, tain *stamp) +{ + size_t w = 0 ; + for (;;) + { + w += buffer_putnoflush(b, s + w, len - w) ; + if (w >= len || !buffer_timed_flush(b, deadline, stamp)) break ; + } + return w ; +} diff --git a/src/libunixonacid/buffer_timed_puts.c b/src/libunixonacid/buffer_timed_puts.c new file mode 100644 index 0000000..edc157a --- /dev/null +++ b/src/libunixonacid/buffer_timed_puts.c @@ -0,0 +1,10 @@ +/* ISC license. */ + +#include <string.h> + +#include <skalibs/unix-timed.h> + +size_t buffer_timed_puts (buffer *b, char const *s, tain const *deadline, tain *stamp) +{ + return buffer_timed_put(b, s, strlen(s), deadline, stamp) ; +} |