Commit 13395847 authored by Niels Möller's avatar Niels Möller
Browse files

Updated to the new object system.

Rev: src/blocking_write.c:1.8
Rev: src/blocking_write.h:1.5
parent 187fb70b
......@@ -2,16 +2,27 @@
*
*/
#include "blocking_write.h"
#include "xalloc.h"
#include "werror.h"
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#warning blocking_write.c is obsolete
#include <errno.h>
static int do_write(struct abstract_write *w,
struct lsh_string *packet)
#define CLASS_DEFINE
#include "blocking_write.h.x"
#undef CLASS_DEFINE
static int do_blocking_write(struct abstract_write *w,
struct lsh_string *packet)
{
CAST(packet_blocking_write, closure, w);
CAST(blocking_write, closure, w);
UINT32 left = packet->length;
UINT8 *p = packet->data;
......@@ -25,26 +36,29 @@ static int do_write(struct abstract_write *w,
continue;
if (written <= 0)
return 0;
{
werror("blocking_write: writ failed (errno = %d): %s\n",
errno, strerror(errno));
return LSH_FAIL;
}
left -= written;
p += written;
}
lsh_string_free(packet);
return 1;
return LSH_OK;
}
struct abstract_write *make_blocking_write_procesor(int fd)
struct abstract_write *make_blocking_write(int fd)
{
struct blocking_write_processor *closure;
NEW(closure);
NEW(blocking_write, closure);
closure->p->f = do_write;
closure->super.write = do_blocking_write;
closure->fd = fd;
return &closure->super;
}
......@@ -5,14 +5,20 @@
#ifndef LSH_BLOCKING_WRITE_H_INCLUDED
#define LSH_BLOCKING_WRITE_H_INCLUDED
#warning blocking_write is not used
#include "abstract_io.h"
struct packet_blocking_write
{
struct abstract_write super;
int fd;
};
#define CLASS_DECLARE
#include "blocking_write.h.x"
#undef CLASS_DECLARE
struct abstract_write *make_blocking_write_procesor(int fd);
/* CLASS:
(class
(name blocking_write)
(super abstract_write)
(vars
(fd . int)))
*/
struct abstract_write *make_blocking_write(int fd);
#endif /* LSH_BLOCKING_WRITE_H_INCLUDED */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment