abstract_io.h 752 Bytes
Newer Older
Niels Möller's avatar
Niels Möller committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* abstract_io.h
 *
 * This is the layer separating protocol processing from actual io.
 */

#ifndef LSH_ABSTRACT_IO_H_INCLUDED
#define LSH_ABSTRACT_IO_H_INCLUDED

#include "lsh_types.h"

struct abstract_read;
typedef int (*abstract_read_f)(struct abstract_read *closure,
			       UINT8 *buffer, UINT32 length);
struct abstract_read
{
  abstract_read_f read;
};

#define A_READ(f, buffer, length) (f)->read((f), (buffer), (length))

struct read_handler
{
  int (*handler)(struct read_handler *closure,
		 struct abstract_read *read);
};

struct abstract_write;
typedef int (*abstract_write_f)(struct abstract_write *closure,
				struct lsh_string *packet);

struct abstract_write
{
  abstract_write_f write;
};

#endif /*LSH_ABSTRACT_IO_H_INCLUDED */