read_line.h 912 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
/* read_line.h
 *
 * Read-handler processing a line at a time.
 */

#ifndef  LSH_READ_HANDLER_H_INCLUDED
#define  LSH_READ_HANDLER_H_INCLUDED

#include "abstract_io.h"

/* This limit follows the ssh specification */
#define MAX_LINE 255

14
#if 0
Niels Möller's avatar
Niels Möller committed
15
16
struct line_handler;

Niels Möller's avatar
Niels Möller committed
17
18
19
typedef struct read_handler * (*line_handler_f)(struct line_handler *closure,
						UINT32 length,
						UINT8 *line);
20
21
22
#endif

/* May store a new handler into *h. */
Niels Möller's avatar
Niels Möller committed
23
24
struct line_handler
{
25
26
27
  struct read_handler * (*handler)(struct line_handler **h,
				   UINT32 length,
				   UINT8 *line);
Niels Möller's avatar
Niels Möller committed
28
29
};

Niels Möller's avatar
Niels Möller committed
30
#define PROCESS_LINE(h, length, line) \
31
((h)->handler(&(h), (length), (line)))
Niels Möller's avatar
Niels Möller committed
32
33
34
35

struct read_line
{
  struct read_handler super; /* Super type */
36
  struct line_handler *handler;
Niels Möller's avatar
Niels Möller committed
37
38
39
40
41

  UINT32 pos;   /* Line buffer */
  UINT8 buffer[MAX_LINE];
};

Niels Möller's avatar
Niels Möller committed
42
43
struct read_handler *make_read_line(struct line_handler *handler);

Niels Möller's avatar
Niels Möller committed
44
#endif /* LSH_READ_HANDLER_H_INCLUDED */