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

Changed the order of the arguments to abstract-read-functions.

Rev: src/abstract_io.h:1.11
Rev: src/read_data.c:1.5
Rev: src/read_line.c:1.6
Rev: src/read_packet.c:1.11
parent 9634d28b
...@@ -41,10 +41,10 @@ ...@@ -41,10 +41,10 @@
struct abstract_read struct abstract_read
{ {
int (*read)(struct abstract_read **r, int (*read)(struct abstract_read **r,
UINT8 *buffer, UINT32 length); UINT32 length, UINT8 *buffer);
}; };
#define A_READ(f, buffer, length) (f)->read(&(f), (buffer), (length)) #define A_READ(f, length, buffer) (f)->read(&(f), (length), (buffer))
/* May store a new handler into *h. */ /* May store a new handler into *h. */
struct read_handler struct read_handler
......
...@@ -35,7 +35,7 @@ static int do_read_data(struct read_handler **h, ...@@ -35,7 +35,7 @@ static int do_read_data(struct read_handler **h,
while(1) while(1)
{ {
struct lsh_string *packet = lsh_string_alloc(closure->block_size); struct lsh_string *packet = lsh_string_alloc(closure->block_size);
int n = A_READ(read, packet->data, packet->length); int n = A_READ(read, packet->length, packet->data);
switch(n) switch(n)
{ {
......
...@@ -37,7 +37,7 @@ struct string_read ...@@ -37,7 +37,7 @@ struct string_read
}; };
static int do_string_read(struct abstract_read **r, static int do_string_read(struct abstract_read **r,
UINT8 *buffer, UINT32 length) UINT32 length, UINT8 *buffer)
{ {
struct string_read *closure struct string_read *closure
= (struct string_read *) *r; = (struct string_read *) *r;
...@@ -60,7 +60,7 @@ static int do_read_line(struct read_handler **h, ...@@ -60,7 +60,7 @@ static int do_read_line(struct read_handler **h,
UINT32 length; UINT32 length;
struct read_handler *next; struct read_handler *next;
int n = A_READ(read, closure->buffer, MAX_LINE - closure->pos); int n = A_READ(read, MAX_LINE - closure->pos, closure->buffer);
if (n<0) if (n<0)
{ {
......
...@@ -59,7 +59,7 @@ int do_read_packet(struct read_handler **h, ...@@ -59,7 +59,7 @@ int do_read_packet(struct read_handler **h,
{ {
UINT32 block_size = closure->connection->rec_crypto UINT32 block_size = closure->connection->rec_crypto
? closure->connection->rec_crypto->block_size : 8; ? closure->connection->rec_crypto->block_size : 8;
UINT32 left = block_size - closure->pos; UINT32 left;
int n; int n;
if (!closure->buffer) if (!closure->buffer)
...@@ -68,13 +68,18 @@ int do_read_packet(struct read_handler **h, ...@@ -68,13 +68,18 @@ int do_read_packet(struct read_handler **h,
= lsh_string_alloc(block_size); = lsh_string_alloc(block_size);
closure->pos = 0; closure->pos = 0;
} }
n = A_READ(read, closure->buffer->data + closure->pos, left);
left = block_size - closure->pos;
n = A_READ(read, left, closure->buffer->data + closure->pos);
switch(n) switch(n)
{ {
case 0: case 0:
return 1; return 1;
case A_FAIL: case A_FAIL:
#if 0
werror("do_read_packet: read() failed, %s\n", strerror(errno)); werror("do_read_packet: read() failed, %s\n", strerror(errno));
#endif
/* Fall through */ /* Fall through */
case A_EOF: case A_EOF:
/* FIXME: Free associated resources! */ /* FIXME: Free associated resources! */
...@@ -143,7 +148,7 @@ int do_read_packet(struct read_handler **h, ...@@ -143,7 +148,7 @@ int do_read_packet(struct read_handler **h,
case WAIT_CONTENTS: case WAIT_CONTENTS:
{ {
UINT32 left = closure->buffer->length - closure->pos; UINT32 left = closure->buffer->length - closure->pos;
int n = A_READ(read, closure->buffer->data + closure->pos, left); int n = A_READ(read, left, closure->buffer->data + closure->pos);
switch(n) switch(n)
{ {
...@@ -189,7 +194,7 @@ int do_read_packet(struct read_handler **h, ...@@ -189,7 +194,7 @@ int do_read_packet(struct read_handler **h,
- closure->pos); - closure->pos);
UINT8 *mac = alloca(left); UINT8 *mac = alloca(left);
int n = A_READ(read, mac, left); int n = A_READ(read, left, mac);
switch(n) switch(n)
{ {
......
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