main.h
author viric@mandarina
Thu, 21 Aug 2008 23:21:22 +0200
changeset 93 7d9b7a6da507
parent 88 a7f546938313
child 94 330324fc7c20
permissions -rw-r--r--
Removing direct references to /usr in the Makefile, for nix.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
     1
enum Transport
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
     2
{
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
     3
    UNIX,
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
     4
    TCP,
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
     5
    ETHERNET
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
     6
};
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
     7
21
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
     8
struct Command_line {
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
     9
    int is_server;
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    10
    char *unix_path; /* path or 0 if not to be used */
29
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
    11
    int tcp_port;
43
625794738afc Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents: 41
diff changeset
    12
    char *eth_device;
88
a7f546938313 Adding port number on the ethernet protocol.
viric@llimona
parents: 87
diff changeset
    13
    int eth_port;
21
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    14
    struct {
29
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
    15
        int serve_tcp; /* yes/no */
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
    16
        int serve_unix; /* yes/no */
43
625794738afc Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents: 41
diff changeset
    17
        int serve_eth; /* yes/no */
29
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
    18
        int max_served; /* how many */
21
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    19
        char run_in_subterminal; /* use opentty */
36
da427c23d755 Added dumps, telnet_filter, applied filters in tm, improved telnet experience.
viric@llimona
parents: 34
diff changeset
    20
        char echo_in_local_terminal;
21
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    21
        char use_blocking_sockets;
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    22
        char send_xterm_resize;
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents: 21
diff changeset
    23
        char client_may_close_app_stdin;
32
df110f784648 Added read-only clients, added stdin-close option to clients.
lbatlle@npdl268.bpo.hp.com
parents: 29
diff changeset
    24
        char client_can_write;
41
954941c6e40a Added 'nohup' option -n.
viric@llimona
parents: 36
diff changeset
    25
        char nohup; /* detach from terminal as nohup */
29
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
    26
        char **command; /* ordono por exec */
21
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    27
    } s_param;
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    28
    struct {
29
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
    29
        enum Transport transport;
21
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    30
        unsigned int wait_until_char; /* -1, don't wait. */
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    31
        char raw_mode; /* bool. else cooked */
29
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
    32
        char * server_address;
21
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    33
    } c_param;
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    34
    int buffer_size;
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    35
};
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    36
0
3bbacfe6797a Something bare.
viric@llimona
parents:
diff changeset
    37
3bbacfe6797a Something bare.
viric@llimona
parents:
diff changeset
    38
/* error.c */
21
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    39
void not_implemented(const char *msg, ...);
14
286b248e402a Adding better error messages and a README.
viric@llimona
parents: 7
diff changeset
    40
void error(const char *msg, ...);
82
5cbe47923060 Added a terminal-creation capability.
lbatlle@npdl268.bpo.hp.com
parents: 75
diff changeset
    41
void warning(const char *msg, ...);
5cbe47923060 Added a terminal-creation capability.
lbatlle@npdl268.bpo.hp.com
parents: 75
diff changeset
    42
void debugmsg(const char *msg, ...);
26
96920c3707b3 Unix sockets version works! Well, signals don't. :)
viric@llimona
parents: 24
diff changeset
    43
void finish(int ret);
0
3bbacfe6797a Something bare.
viric@llimona
parents:
diff changeset
    44
21
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    45
/* signals.c */
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    46
void install_signal_forwarders();
60
18c24be2b1a6 Better ethernet protocol.
viric@llimona
parents: 43
diff changeset
    47
void program_timeout(int secs);
18c24be2b1a6 Better ethernet protocol.
viric@llimona
parents: 43
diff changeset
    48
void unprogram_timeout();
66
b2469563a1dc Reliable ethernet protocol. I still need pselect instead of select.
viric@mandarina
parents: 60
diff changeset
    49
int did_timeout_happen();
71
c209487034d7 True nohup-like behaviour. Programs ignore to SIGHUP.
viric@llimona
parents: 66
diff changeset
    50
void ignore_sighup();
21
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    51
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    52
/* main.c */
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    53
extern int app_stdin;
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    54
extern int app_stdout;
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    55
extern int app_stderr;
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    56
extern struct Command_line command_line;
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    57
int max(int a, int b);
43
625794738afc Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents: 41
diff changeset
    58
int min(int a, int b);
21
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    59
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    60
/* gen_sockets.c */
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    61
extern char *stream_buffer;
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    62
extern int stream_buffer_size;
34
7486e269b794 Added filter engine, xterm resize.
viric@mandarina
parents: 32
diff changeset
    63
extern char *ostream_buffer;
7486e269b794 Added filter engine, xterm resize.
viric@mandarina
parents: 32
diff changeset
    64
extern int ostream_buffer_size;
75
525a97517dc7 command line dump setting -D
viric@llimona
parents: 74
diff changeset
    65
extern char *ostream_buffer2;
525a97517dc7 command line dump setting -D
viric@llimona
parents: 74
diff changeset
    66
extern int ostream_buffer2_size;
34
7486e269b794 Added filter engine, xterm resize.
viric@mandarina
parents: 32
diff changeset
    67
void init_stream_buffers();
36
da427c23d755 Added dumps, telnet_filter, applied filters in tm, improved telnet experience.
viric@llimona
parents: 34
diff changeset
    68
void welcome_new_client_socket(int s);
21
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    69
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents: 21
diff changeset
    70
/* server.c */
29
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
    71
int server();
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents: 21
diff changeset
    72
b3e6c6ffc69c Moving the client out.
viric@llimona
parents: 21
diff changeset
    73
/* client.c */ 
b3e6c6ffc69c Moving the client out.
viric@llimona
parents: 21
diff changeset
    74
int client();
24
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
    75
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
    76
/* app_term.c */
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
    77
int fork_app(char * const command[]);
74
cb3184566c6e Better xterm resize management.
viric@llimona
parents: 71
diff changeset
    78
void pass_winsize_to_slave();
26
96920c3707b3 Unix sockets version works! Well, signals don't. :)
viric@llimona
parents: 24
diff changeset
    79
96920c3707b3 Unix sockets version works! Well, signals don't. :)
viric@llimona
parents: 24
diff changeset
    80
/* server_term.c */
96920c3707b3 Unix sockets version works! Well, signals don't. :)
viric@llimona
parents: 24
diff changeset
    81
void prepare_user_terminal();
96920c3707b3 Unix sockets version works! Well, signals don't. :)
viric@llimona
parents: 24
diff changeset
    82
void restore_user_terminal();
34
7486e269b794 Added filter engine, xterm resize.
viric@mandarina
parents: 32
diff changeset
    83
36
da427c23d755 Added dumps, telnet_filter, applied filters in tm, improved telnet experience.
viric@llimona
parents: 34
diff changeset
    84
/* xterm.c */
34
7486e269b794 Added filter engine, xterm resize.
viric@mandarina
parents: 32
diff changeset
    85
char * get_xterm_resize_string();
36
da427c23d755 Added dumps, telnet_filter, applied filters in tm, improved telnet experience.
viric@llimona
parents: 34
diff changeset
    86
da427c23d755 Added dumps, telnet_filter, applied filters in tm, improved telnet experience.
viric@llimona
parents: 34
diff changeset
    87
/* dump.c */
75
525a97517dc7 command line dump setting -D
viric@llimona
parents: 74
diff changeset
    88
extern int should_dump;
36
da427c23d755 Added dumps, telnet_filter, applied filters in tm, improved telnet experience.
viric@llimona
parents: 34
diff changeset
    89
void hex_dump(const char *head, const unsigned char *data, int len);
da427c23d755 Added dumps, telnet_filter, applied filters in tm, improved telnet experience.
viric@llimona
parents: 34
diff changeset
    90
void dump_line(const char *msg, ...);
43
625794738afc Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents: 41
diff changeset
    91
625794738afc Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents: 41
diff changeset
    92
/* eth_proto.c */
87
be4ee314545c Making client and server use different ethernet protocols
viric@llimona
parents: 82
diff changeset
    93
enum Eth_type
be4ee314545c Making client and server use different ethernet protocols
viric@llimona
parents: 82
diff changeset
    94
{
be4ee314545c Making client and server use different ethernet protocols
viric@llimona
parents: 82
diff changeset
    95
    ETH_SERVER,
be4ee314545c Making client and server use different ethernet protocols
viric@llimona
parents: 82
diff changeset
    96
    ETH_CLIENT
be4ee314545c Making client and server use different ethernet protocols
viric@llimona
parents: 82
diff changeset
    97
};
43
625794738afc Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents: 41
diff changeset
    98
void eth_proto_init();
87
be4ee314545c Making client and server use different ethernet protocols
viric@llimona
parents: 82
diff changeset
    99
int eth_proto_open(enum Eth_type type);
43
625794738afc Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents: 41
diff changeset
   100
int eth_proto_recv(char *data, int size);
625794738afc Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents: 41
diff changeset
   101
int eth_proto_send(const char *data, int size);
66
b2469563a1dc Reliable ethernet protocol. I still need pselect instead of select.
viric@mandarina
parents: 60
diff changeset
   102
int eth_proto_allow_sending();
b2469563a1dc Reliable ethernet protocol. I still need pselect instead of select.
viric@mandarina
parents: 60
diff changeset
   103
int eth_proto_max_send();
b2469563a1dc Reliable ethernet protocol. I still need pselect instead of select.
viric@mandarina
parents: 60
diff changeset
   104
int eth_proto_process_timeouts();