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

* src/io_commands.c (connect_port): Renamed from

connect_connection.
(connect_connection): New command.

Rev: src/io_commands.c:1.11
Rev: src/io_commands.h:1.9
parent 07562daf
......@@ -227,33 +227,35 @@ static int do_connect(struct io_backend *backend,
/* Connect variant, taking a connection object as argument (used for
* rememembering the connected fd). */
* rememembering the connected fd).
*
* (connect backend port connection) -> fd */
/* GABA:
(class
(name connect_connection)
(name connect_port)
(super command)
(vars
(backend object io_backend)
(target object address_info)))
*/
static int do_connect_connection(struct command *s,
static int do_connect_port(struct command *s,
struct lsh_object *x,
struct command_continuation *c)
{
CAST(connect_connection, self, s);
CAST(connect_port, self, s);
CAST(ssh_connection, connection, x);
return do_connect(self->backend, self->target, connection->resources, c);
}
struct command *make_connect_connection(struct io_backend *backend,
struct address_info *target)
struct command *make_connect_port(struct io_backend *backend,
struct address_info *target)
{
NEW(connect_connection, self);
self->super.call = do_connect_connection;
NEW(connect_port, self);
self->super.call = do_connect_port;
self->backend = backend;
self->target = target;
......@@ -261,7 +263,7 @@ struct command *make_connect_connection(struct io_backend *backend,
}
static struct lsh_object *
collect_connect_connection(struct collect_info_2 *info,
collect_connect_port(struct collect_info_2 *info,
struct lsh_object *a,
struct lsh_object *b)
{
......@@ -271,11 +273,11 @@ collect_connect_connection(struct collect_info_2 *info,
assert(backend);
assert(target);
return &make_connect_connection(backend, target)->super;
return &make_connect_port(backend, target)->super;
}
static struct collect_info_2 collect_info_connect_2 =
STATIC_COLLECT_2_FINAL(collect_connect_connection);
STATIC_COLLECT_2_FINAL(collect_connect_port);
struct collect_info_1 connect_with_connection =
STATIC_COLLECT_1(&collect_info_connect_2);
......@@ -319,6 +321,35 @@ make_simple_connect(struct io_backend *backend,
}
/* GABA:
(class
(name connect_connection)
(super command)
(vars
(backend object io_backend)))
*/
static int do_connect_connection(struct command *s,
struct lsh_object *x,
struct command_continuation *c)
{
CAST(connect_connection, self, s);
CAST(ssh_connection, connection, x);
return
COMMAND_RETURN(c,
make_simple_connect(self->backend, connection->resources));
}
struct command *make_connect_connection(struct io_backend *backend)
{
NEW(connect_connection, self);
self->super.call = do_connect_connection;
self->backend = backend;
return &self->super;
}
static int do_simple_listen(struct command *s,
struct lsh_object *a,
struct command_continuation *c)
......
......@@ -48,8 +48,9 @@ struct command *make_listen_command(struct command *callback,
extern struct collect_info_1 listen_command;
#define LISTEN_COMMAND (&listen_command.super.super.super)
struct command *make_connect_connection(struct io_backend *backend,
struct command *make_connect_port(struct io_backend *backend,
struct address_info *target);
struct command *make_connect_connection(struct io_backend *backend);
extern struct collect_info_1 connect_with_connection;
......
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