File: ttybuf.h

package info (click to toggle)
modemu 0.0.1-9
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 200 kB
  • ctags: 266
  • sloc: ansic: 1,860; lex: 146; makefile: 72
file content (58 lines) | stat: -rw-r--r-- 1,143 bytes parent folder | download | duplicates (4)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#if 0
#include <sys/time.h>	/*->ttybuf.h (timeval)*/
#include "defs.h"	/*->ttybuf.h (uchar,SOCKBUFR_SIZE,TTYBUFR_SIZE)*/
#endif

struct {
    int rfd;
    int wfd;
} tty;


/* reading tty */

struct {
    uchar buf[TTYBUFR_SIZE];
    uchar *ptr;
    uchar *end;
    struct timeval newT;
    struct timeval prevT;
} ttyBufR;

#define ttyBufRReset() \
{ \
    ttyBufR.ptr = ttyBufR.end = ttyBufR.buf; \
    ttyBufR.prevT.tv_sec = ttyBufR.prevT.tv_usec = 0; \
}
#define getTty1() ((ttyBufR.ptr >= ttyBufR.end)? -1 : *ttyBufR.ptr++)

void
ttyBufRead(void);


/* writing tty */

#define TTYBUFW_SIZE (2 * SOCKBUFR_SIZE) /* this seems to be any number */
#define TTYBUFW_SIZE_A (TTYBUFW_SIZE + SOCKBUFR_SIZE) /* important */

struct {
    uchar buf[TTYBUFW_SIZE_A];
    uchar *top;
    uchar *ptr;
    int stop;
} ttyBufW;

#define ttyBufWReset() { \
    ttyBufW.ptr = ttyBufW.top = ttyBufW.buf; \
    ttyBufW.stop = 0; \
}
#define ttyBufWHasData() (ttyBufW.ptr > ttyBufW.buf)
#define ttyBufWReady() (!ttyBufW.stop)
#define putTtyStr(s) putTtyN(s, sizeof(s)-1)

void
ttyBufWrite(void);
void
putTty1(uchar c);
void
putTtyN(const uchar *cp, int n);