main.h
author Lluís Batlle <viric@viric.name>
Thu, 20 Mar 2014 16:33:27 +0100
changeset 97 eea77d5a624c
parent 94 330324fc7c20
permissions -rw-r--r--
Merging the savefile branch. I hope it works; I even don't remember it.
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 */
94
330324fc7c20 Adding a feature: save all stdin/stdout traffic of the server into a file.
viric <viriketo@gmail.com>
parents: 88
diff changeset
    26
        char *savefile;
29
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
    27
        char **command; /* ordono por exec */
21
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    28
    } s_param;
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    29
    struct {
29
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
    30
        enum Transport transport;
21
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    31
        unsigned int wait_until_char; /* -1, don't wait. */
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    32
        char raw_mode; /* bool. else cooked */
29
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
    33
        char * server_address;
21
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    34
    } c_param;
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    35
    int buffer_size;
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    36
};
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    37
0
3bbacfe6797a Something bare.
viric@llimona
parents:
diff changeset
    38
3bbacfe6797a Something bare.
viric@llimona
parents:
diff changeset
    39
/* error.c */
21
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    40
void not_implemented(const char *msg, ...);
14
286b248e402a Adding better error messages and a README.
viric@llimona
parents: 7
diff changeset
    41
void error(const char *msg, ...);
82
5cbe47923060 Added a terminal-creation capability.
lbatlle@npdl268.bpo.hp.com
parents: 75
diff changeset
    42
void warning(const char *msg, ...);
5cbe47923060 Added a terminal-creation capability.
lbatlle@npdl268.bpo.hp.com
parents: 75
diff changeset
    43
void debugmsg(const char *msg, ...);
26
96920c3707b3 Unix sockets version works! Well, signals don't. :)
viric@llimona
parents: 24
diff changeset
    44
void finish(int ret);
0
3bbacfe6797a Something bare.
viric@llimona
parents:
diff changeset
    45
21
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    46
/* signals.c */
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    47
void install_signal_forwarders();
60
18c24be2b1a6 Better ethernet protocol.
viric@llimona
parents: 43
diff changeset
    48
void program_timeout(int secs);
18c24be2b1a6 Better ethernet protocol.
viric@llimona
parents: 43
diff changeset
    49
void unprogram_timeout();
66
b2469563a1dc Reliable ethernet protocol. I still need pselect instead of select.
viric@mandarina
parents: 60
diff changeset
    50
int did_timeout_happen();
71
c209487034d7 True nohup-like behaviour. Programs ignore to SIGHUP.
viric@llimona
parents: 66
diff changeset
    51
void ignore_sighup();
21
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    52
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    53
/* main.c */
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    54
extern int app_stdin;
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    55
extern int app_stdout;
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    56
extern int app_stderr;
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    57
extern struct Command_line command_line;
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    58
int max(int a, int b);
43
625794738afc Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents: 41
diff changeset
    59
int min(int a, int b);
21
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    60
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    61
/* gen_sockets.c */
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    62
extern char *stream_buffer;
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    63
extern int stream_buffer_size;
34
7486e269b794 Added filter engine, xterm resize.
viric@mandarina
parents: 32
diff changeset
    64
extern char *ostream_buffer;
7486e269b794 Added filter engine, xterm resize.
viric@mandarina
parents: 32
diff changeset
    65
extern int ostream_buffer_size;
75
525a97517dc7 command line dump setting -D
viric@llimona
parents: 74
diff changeset
    66
extern char *ostream_buffer2;
525a97517dc7 command line dump setting -D
viric@llimona
parents: 74
diff changeset
    67
extern int ostream_buffer2_size;
34
7486e269b794 Added filter engine, xterm resize.
viric@mandarina
parents: 32
diff changeset
    68
void init_stream_buffers();
36
da427c23d755 Added dumps, telnet_filter, applied filters in tm, improved telnet experience.
viric@llimona
parents: 34
diff changeset
    69
void welcome_new_client_socket(int s);
21
a82c88322eb5 Big change, from stdinmix to multiterminal.
viric@llimona
parents: 14
diff changeset
    70
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents: 21
diff changeset
    71
/* server.c */
29
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
    72
int server();
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents: 21
diff changeset
    73
b3e6c6ffc69c Moving the client out.
viric@llimona
parents: 21
diff changeset
    74
/* client.c */ 
b3e6c6ffc69c Moving the client out.
viric@llimona
parents: 21
diff changeset
    75
int client();
24
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
    76
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
    77
/* app_term.c */
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
    78
int fork_app(char * const command[]);
74
cb3184566c6e Better xterm resize management.
viric@llimona
parents: 71
diff changeset
    79
void pass_winsize_to_slave();
26
96920c3707b3 Unix sockets version works! Well, signals don't. :)
viric@llimona
parents: 24
diff changeset
    80
96920c3707b3 Unix sockets version works! Well, signals don't. :)
viric@llimona
parents: 24
diff changeset
    81
/* server_term.c */
96920c3707b3 Unix sockets version works! Well, signals don't. :)
viric@llimona
parents: 24
diff changeset
    82
void prepare_user_terminal();
96920c3707b3 Unix sockets version works! Well, signals don't. :)
viric@llimona
parents: 24
diff changeset
    83
void restore_user_terminal();
34
7486e269b794 Added filter engine, xterm resize.
viric@mandarina
parents: 32
diff changeset
    84
36
da427c23d755 Added dumps, telnet_filter, applied filters in tm, improved telnet experience.
viric@llimona
parents: 34
diff changeset
    85
/* xterm.c */
34
7486e269b794 Added filter engine, xterm resize.
viric@mandarina
parents: 32
diff changeset
    86
char * get_xterm_resize_string();
36
da427c23d755 Added dumps, telnet_filter, applied filters in tm, improved telnet experience.
viric@llimona
parents: 34
diff changeset
    87
da427c23d755 Added dumps, telnet_filter, applied filters in tm, improved telnet experience.
viric@llimona
parents: 34
diff changeset
    88
/* dump.c */
75
525a97517dc7 command line dump setting -D
viric@llimona
parents: 74
diff changeset
    89
extern int should_dump;
36
da427c23d755 Added dumps, telnet_filter, applied filters in tm, improved telnet experience.
viric@llimona
parents: 34
diff changeset
    90
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
    91
void dump_line(const char *msg, ...);
43
625794738afc Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents: 41
diff changeset
    92
625794738afc Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents: 41
diff changeset
    93
/* eth_proto.c */
87
be4ee314545c Making client and server use different ethernet protocols
viric@llimona
parents: 82
diff changeset
    94
enum Eth_type
be4ee314545c Making client and server use different ethernet protocols
viric@llimona
parents: 82
diff changeset
    95
{
be4ee314545c Making client and server use different ethernet protocols
viric@llimona
parents: 82
diff changeset
    96
    ETH_SERVER,
be4ee314545c Making client and server use different ethernet protocols
viric@llimona
parents: 82
diff changeset
    97
    ETH_CLIENT
be4ee314545c Making client and server use different ethernet protocols
viric@llimona
parents: 82
diff changeset
    98
};
43
625794738afc Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents: 41
diff changeset
    99
void eth_proto_init();
87
be4ee314545c Making client and server use different ethernet protocols
viric@llimona
parents: 82
diff changeset
   100
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
   101
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
   102
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
   103
int eth_proto_allow_sending();
b2469563a1dc Reliable ethernet protocol. I still need pselect instead of select.
viric@mandarina
parents: 60
diff changeset
   104
int eth_proto_max_send();
b2469563a1dc Reliable ethernet protocol. I still need pselect instead of select.
viric@mandarina
parents: 60
diff changeset
   105
int eth_proto_process_timeouts();