No longer needed.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* {
* assert(c == b->reader);
* b->len = sizeof(b->inbuf);
- * return io_read_partial(c, b->inbuf, &b->len, wake_writer, b);
+ * return io_read_partial(b->inbuf, &b->len, wake_writer, b);
* }
*
* static struct io_plan wake_writer(struct io_conn *c, struct stdin_buffer *b)
* {
* assert(c == b->reader);
* io_wake(b->writer, write_to_child, b);
- * return io_idle(c);
+ * return io_idle();
* }
*
* static void reader_exit(struct io_conn *c, struct stdin_buffer *b)
* {
* assert(c == b->writer);
* io_wake(b->reader, read_stdin, b);
- * return io_idle(c);
+ * return io_idle();
* }
*
* static struct io_plan write_to_child(struct io_conn *conn,
* assert(conn == b->writer);
* if (!b->reader)
* return io_close(conn, NULL);
- * return io_write(conn, b->inbuf, b->len, wake_reader, b);
+ * return io_write(b->inbuf, b->len, wake_reader, b);
* }
*
* static struct io_plan start_writer(struct io_conn *conn,
* struct stdin_buffer *b)
* {
* assert(conn == b->writer);
- * return io_idle(conn);
+ * return io_idle();
* }
*
* static void fail_child_write(struct io_conn *conn, struct stdin_buffer *b)
* }
*
* b->rlen = b->max - b->off;
- * return io_read_partial(conn, b->buf + b->off, &b->rlen,
- * read_from_child, b);
+ * return io_read_partial(b->buf + b->off, &b->rlen, read_from_child, b);
* }
*
* // Feed a program our stdin, gather its stdout, print that at end.
}
/* Queue some data to be written. */
-struct io_plan io_write_(struct io_conn *conn, const void *data, size_t len,
+struct io_plan io_write_(const void *data, size_t len,
struct io_plan (*cb)(struct io_conn *, void *),
void *arg)
{
}
/* Queue a request to read into a buffer. */
-struct io_plan io_read_(struct io_conn *conn, void *data, size_t len,
+struct io_plan io_read_(void *data, size_t len,
struct io_plan (*cb)(struct io_conn *, void *),
void *arg)
{
}
/* Queue a partial request to read into a buffer. */
-struct io_plan io_read_partial_(struct io_conn *conn, void *data, size_t *len,
+struct io_plan io_read_partial_(void *data, size_t *len,
struct io_plan (*cb)(struct io_conn *, void *),
void *arg)
{
}
/* Queue a partial write request. */
-struct io_plan io_write_partial_(struct io_conn *conn,
- const void *data, size_t *len,
+struct io_plan io_write_partial_(const void *data, size_t *len,
struct io_plan (*cb)(struct io_conn*, void *),
void *arg)
{
return plan;
}
-struct io_plan io_idle(struct io_conn *conn)
+struct io_plan io_idle(void)
{
struct io_plan plan;
}
/* Exit the loop, returning this (non-NULL) arg. */
-struct io_plan io_break_(struct io_conn *conn, void *ret,
+struct io_plan io_break_(void *ret,
struct io_plan (*fn)(struct io_conn *, void *),
void *arg)
{
/**
* io_write - queue data to be written.
- * @conn: the current connection.
* @data: the data buffer.
* @len: the length to write.
* @cb: function to call once it's done.
*
* Note that the I/O may actually be done immediately.
*/
-#define io_write(conn, data, len, cb, arg) \
- io_write_((conn), (data), (len), \
+#define io_write(data, len, cb, arg) \
+ io_write_((data), (len), \
typesafe_cb_preargs(struct io_plan, void *, \
(cb), (arg), struct io_conn *), \
(arg))
-struct io_plan io_write_(struct io_conn *conn, const void *data, size_t len,
+struct io_plan io_write_(const void *data, size_t len,
struct io_plan (*cb)(struct io_conn *, void *),
void *arg);
/**
* io_read - queue buffer to be read.
- * @conn: the current connection.
* @data: the data buffer.
* @len: the length to read.
* @cb: function to call once it's done.
*
* Note that the I/O may actually be done immediately.
*/
-#define io_read(conn, data, len, cb, arg) \
- io_read_((conn), (data), (len), \
+#define io_read(data, len, cb, arg) \
+ io_read_((data), (len), \
typesafe_cb_preargs(struct io_plan, void *, \
(cb), (arg), struct io_conn *), \
(arg))
-struct io_plan io_read_(struct io_conn *conn, void *data, size_t len,
+struct io_plan io_read_(void *data, size_t len,
struct io_plan (*cb)(struct io_conn *, void *),
void *arg);
/**
* io_read_partial - queue buffer to be read (partial OK).
- * @conn: the current connection.
* @data: the data buffer.
* @len: the maximum length to read, set to the length actually read.
* @cb: function to call once it's done.
*
* Note that the I/O may actually be done immediately.
*/
-#define io_read_partial(conn, data, len, cb, arg) \
- io_read_partial_((conn), (data), (len), \
+#define io_read_partial(data, len, cb, arg) \
+ io_read_partial_((data), (len), \
typesafe_cb_preargs(struct io_plan, void *, \
(cb), (arg), struct io_conn *), \
(arg))
-struct io_plan io_read_partial_(struct io_conn *conn, void *data, size_t *len,
+struct io_plan io_read_partial_(void *data, size_t *len,
struct io_plan (*cb)(struct io_conn *, void *),
void *arg);
/**
* io_write_partial - queue data to be written (partial OK).
- * @conn: the current connection.
* @data: the data buffer.
* @len: the maximum length to write, set to the length actually written.
* @cb: function to call once it's done.
*
* Note that the I/O may actually be done immediately.
*/
-#define io_write_partial(conn, data, len, cb, arg) \
- io_write_partial_((conn), (data), (len), \
+#define io_write_partial(data, len, cb, arg) \
+ io_write_partial_((data), (len), \
typesafe_cb_preargs(struct io_plan, void *, \
(cb), (arg), struct io_conn *), \
(arg))
-struct io_plan io_write_partial_(struct io_conn *conn,
- const void *data, size_t *len,
+struct io_plan io_write_partial_(const void *data, size_t *len,
struct io_plan (*cb)(struct io_conn *, void*),
void *arg);
/**
* io_idle - explicitly note that this connection will do nothing.
- * @conn: the current connection.
*
* This indicates the connection is idle: some other function will
* later call io_read/io_write etc. (or io_close) on it, in which case
* it will do that.
*/
-struct io_plan io_idle(struct io_conn *conn);
+struct io_plan io_idle(void);
/**
* io_timeout - set timeout function if the callback doesn't fire.
/**
* io_break - return from io_loop()
- * @conn: the current connection.
* @ret: non-NULL value to return from io_loop().
* @cb: function to call once on return
* @arg: @cb argument
*
* If io_loop() is called again, then @cb will be called.
*/
-#define io_break(conn, ret, fn, arg) \
- io_break_((conn), (ret), \
+#define io_break(ret, fn, arg) \
+ io_break_((ret), \
typesafe_cb_preargs(struct io_plan, void *, \
(fn), (arg), struct io_conn *), \
(arg))
-struct io_plan io_break_(struct io_conn *conn, void *ret,
+struct io_plan io_break_(void *ret,
struct io_plan (*fn)(struct io_conn *, void *),
void *arg);
{
ok1(*state == 1);
(*state)++;
- io_break(conn, state + 1, NULL, NULL);
+ io_break(state + 1, NULL, NULL);
}
static int make_listen_fd(const char *port, struct addrinfo **info)
{
ok1(d->state == 0);
d->state++;
- return io_read(conn, d->buf, sizeof(d->buf), io_close, d);
+ return io_read(d->buf, sizeof(d->buf), io_close, d);
}
static void finish_ok(struct io_conn *conn, struct data *d)
{
ok1(d->state == 1);
d->state++;
- io_break(conn, d, NULL, NULL);
+ io_break(d, NULL, NULL);
}
static int make_listen_fd(const char *port, struct addrinfo **info)
ok1(d->state == 0);
d->state++;
d->bytes = sizeof(d->buf);
- return io_read_partial(conn, d->buf, &d->bytes, io_close, d);
+ return io_read_partial(d->buf, &d->bytes, io_close, d);
}
static void finish_ok(struct io_conn *conn, struct data *d)
{
ok1(d->state == 1);
d->state++;
- io_break(conn, d, NULL, NULL);
+ io_break(d, NULL, NULL);
}
static int make_listen_fd(const char *port, struct addrinfo **info)
{
ok1(d->state == 0);
d->state++;
- return io_write_partial(conn, d->buf, &d->bytes, io_close, d);
+ return io_write_partial(d->buf, &d->bytes, io_close, d);
}
static void finish_ok(struct io_conn *conn, struct data *d)
{
ok1(d->state == 1);
d->state++;
- io_break(conn, d, NULL, NULL);
+ io_break(d, NULL, NULL);
}
static int make_listen_fd(const char *port, struct addrinfo **info)
{
ok1(d->state == 0);
d->state++;
- return io_write(conn, d->buf, d->bytes, io_close, d);
+ return io_write(d->buf, d->bytes, io_close, d);
}
static void finish_ok(struct io_conn *conn, struct data *d)
{
ok1(d->state == 1);
d->state++;
- io_break(conn, d, NULL, NULL);
+ io_break(d, NULL, NULL);
}
static int make_listen_fd(const char *port, struct addrinfo **info)
{
ok1(d->state == 2 || d->state == 3);
d->state++;
- return io_read(conn, d->buf, sizeof(d->buf), io_close, d);
+ return io_read(d->buf, sizeof(d->buf), io_close, d);
}
static struct io_plan start_waker(struct io_conn *conn, struct data *d)
ok1(fd >= 0);
ok1(io_new_conn(fd, start_waker, finish_waker, d));
- return io_idle(conn);
+ return io_idle();
}
static void finish_idle(struct io_conn *conn, struct data *d)
{
ok1(d->state == 4);
d->state++;
- io_break(conn, d, NULL, NULL);
+ io_break(d, NULL, NULL);
}
static int make_listen_fd(const char *port, struct addrinfo **info)
{
ok1(d->state == 1);
d->state++;
- return io_read(conn, d->buf, sizeof(d->buf), io_close, d);
+ return io_read(d->buf, sizeof(d->buf), io_close, d);
}
static struct io_plan start_break(struct io_conn *conn, struct data *d)
{
ok1(d->state == 0);
d->state++;
- return io_break(conn, d, plan_read, d);
+ return io_break(d, plan_read, d);
}
static void finish_ok(struct io_conn *conn, struct data *d)
{
assert(conn == buf->reader);
- return io_read(conn, &buf->buf, sizeof(buf->buf),
- poke_writer, buf);
+ return io_read(&buf->buf, sizeof(buf->buf), poke_writer, buf);
}
static struct io_plan plan_write(struct io_conn *conn, struct buffer *buf)
{
assert(conn == buf->writer);
- return io_write(conn, &buf->buf, sizeof(buf->buf),
- poke_reader, buf);
+ return io_write(&buf->buf, sizeof(buf->buf), poke_reader, buf);
}
static struct io_plan poke_writer(struct io_conn *conn, struct buffer *buf)
io_wake(buf->writer, plan_write, buf);
/* I'll wait until you wake me. */
- return io_idle(conn);
+ return io_idle();
}
static struct io_plan poke_reader(struct io_conn *conn, struct buffer *buf)
return io_close(conn, NULL);
/* I'll wait until you tell me to write. */
- return io_idle(conn);
+ return io_idle();
}
static struct io_plan reader(struct io_conn *conn, struct buffer *buf)
assert(conn == buf->reader);
/* Wait for writer to tell us to read. */
- return io_idle(conn);
+ return io_idle();
}
static struct buffer buf[NUM];
static struct io_plan write_out(struct io_conn *conn, struct data *d)
{
d->state++;
- return io_write(conn, d->wbuf, sizeof(d->wbuf), io_close, d);
+ return io_write(d->wbuf, sizeof(d->wbuf), io_close, d);
}
static struct io_plan start_ok(struct io_conn *conn, struct data *d)
memset(d->wbuf, 7, sizeof(d->wbuf));
ok1(io_duplex(conn, write_out, finish_ok, d));
- return io_read(conn, d->buf, sizeof(d->buf), io_close, d);
+ return io_read(d->buf, sizeof(d->buf), io_close, d);
}
static int make_listen_fd(const char *port, struct addrinfo **info)
static struct io_plan start(struct io_conn *conn, void *unused)
{
- return io_idle(conn);
+ return io_idle();
}
int main(void)
ok1(d->state == 0);
d->state++;
io_timeout(conn, time_from_usec(d->timeout_usec), timeout, d);
- return io_read(conn, d->buf, sizeof(d->buf), no_timeout, d);
+ return io_read(d->buf, sizeof(d->buf), no_timeout, d);
}
static void finish_ok(struct io_conn *conn, struct data *d)
{
ok1(d->state == 2);
d->state++;
- io_break(conn, d, NULL, NULL);
+ io_break(d, NULL, NULL);
}
static int make_listen_fd(const char *port, struct addrinfo **info)