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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
/* public things from tcp.c */
#ifndef _TCP_H_
#define _TCP_H_
extern int tcp_fd; /* current socket file descriptor */
extern int tcp_main_fd; /* main session socket */
extern int tcp_max_fd; /* highest used fd */
extern int tcp_count; /* number of open connections */
extern int tcp_attachcount; /* number of spawned or attached commands */
extern int conn_max_index; /* 1 + highest used conn_list[] index */
/* multiple connections control */
/* state of telnet connection */
#define NORMAL 0
#define ALTNORMAL 1
#define GOT_N 2
#define GOT_R 3
#define GOTIAC 4
#define GOTWILL 5
#define GOTWONT 6
#define GOTDO 7
#define GOTDONT 8
#define GOTSB 9
#define GOTSBIAC 10
/* connection flags: */
/* ACTIVE: display remote output */
/* SPAWN: spawned cmd, not a mud */
/* IDEDITOR: sent #request editor */
/* IDPROMPT: sent #request prompt */
#define ACTIVE 1
#define SPAWN 2
#define IDEDITOR 4
#define IDPROMPT 8
typedef struct {
char *id; /* session id */
char *host; /* address of remote host */
int port; /* port number of remote host */
int fd; /* fd number */
char *fragment; /* for SPAWN connections: unprocessed text */
char flags;
char state;
} connsess;
extern connsess conn_list[MAX_CONNECTS]; /* connection list */
extern byte conn_table[MAX_FDSCAN]; /* fd -> index translation table */
#define CONN_LIST(n) conn_list[conn_table[n]]
#define CONN_INDEX(n) conn_list[n]
extern fd_set fdset; /* set of descriptors to select() on */
int tcp_connect __P ((char *addr, int port));
int tcp_read __P ((int fd, char *buffer, int maxsize));
void tcp_raw_write __P ((int fd, char *data, int len));
void tcp_write_tty_size __P ((void));
void tcp_write __P ((int fd, char *data));
void tcp_main_write __P ((char *data));
void tcp_flush __P ((void));
void tcp_set_main __P ((int fd));
void tcp_open __P ((char *id, char *initstring, char *host, int port));
int tcp_find __P ((char *id));
void tcp_show __P ((void));
void tcp_close __P ((char *id));
void tcp_togglesnoop __P ((char *id));
void tcp_spawn __P ((char *id, char *cmd));
int tcp_unIAC __P ((char *data, int len));
int tcp_read_addIAC __P ((int fd, char *data, int len));
#endif /* _TCP_H_ */
|