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

Changed the closure mechanism. Now, the first argument to all closures

is a pointer to a pointer to itself, which may be changed. They no
longer return themselves (or a replacement).

Rev: src/client.c:1.6
parent a797c22c
...@@ -19,11 +19,11 @@ ...@@ -19,11 +19,11 @@
struct read_handler *make_client_read_line(); struct read_handler *make_client_read_line();
struct callback *make_client_close_handler(); struct callback *make_client_close_handler();
static int client_initiate(struct fd_callback *c, static int client_initiate(struct fd_callback **c,
int fd) int fd)
{ {
struct client_callback *closure struct client_callback *closure
= (struct client_callback *) c; = (struct client_callback *) *c;
struct ssh_connection *connection = ssh_connection_alloc(); struct ssh_connection *connection = ssh_connection_alloc();
struct abstract_write *write = struct abstract_write *write =
...@@ -33,12 +33,12 @@ static int client_initiate(struct fd_callback *c, ...@@ -33,12 +33,12 @@ static int client_initiate(struct fd_callback *c,
make_client_close_handler()); make_client_close_handler());
connection->client_version connection->client_version
= ssh_format("SSH-%z-%z %z\r\n", = ssh_format("SSH-%lz-%lz %lz",
PROTOCOL_VERSION, PROTOCOL_VERSION,
SOFTWARE_CLIENT_VERSION, SOFTWARE_CLIENT_VERSION,
closure->id_comment); closure->id_comment);
/* Copies the version string, so that it is isn't freed */
return A_WRITE(write, ssh_format("%lS", connection->client_version)); return A_WRITE(write, ssh_format("%lS\r\n", connection->client_version));
} }
struct client_line_handler struct client_line_handler
...@@ -66,10 +66,18 @@ static struct read_handler *do_line(struct line_handler **h, ...@@ -66,10 +66,18 @@ static struct read_handler *do_line(struct line_handler **h,
closure->connection->max_packet); closure->connection->max_packet);
closure->connection->server_version closure->connection->server_version
= ssh_format("%s", length, line); = ssh_format("%ls", length, line);
verbose("Client version: ");
verbose_safe(closure->connection->client_version->length,
closure->connection->client_version->data);
verbose("\nServer version: ");
verbose_safe(closure->connection->server_version->length,
closure->connection->server_version->data);
verbose("\n");
/* FIXME: Cleanup properly. */ /* FIXME: Cleanup properly. */
free(closure); lsh_free(closure);
return new; return new;
} }
...@@ -80,7 +88,7 @@ static struct read_handler *do_line(struct line_handler **h, ...@@ -80,7 +88,7 @@ static struct read_handler *do_line(struct line_handler **h,
werror("\n"); werror("\n");
/* FIXME: Clean up properly */ /* FIXME: Clean up properly */
free(closure); lsh_free(closure);
*h = 0; *h = 0;
return 0; return 0;
......
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