client.h 4.7 KB
Newer Older
Niels Möller's avatar
Niels Möller committed
1
2
/* client.h
 *
3
4
5
6
7
8
 *
 *
 * $Id$ */

/* lsh, an implementation of the ssh protocol
 *
9
 * Copyright (C) 1998, 1999, 2000, 2001 Niels Möller
10
11
12
13
14
15
16
17
18
19
20
21
22
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
J.H.M. Dassen's avatar
J.H.M. Dassen committed
23
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
Niels Möller's avatar
Niels Möller committed
24
25
26
27
28
 */

#ifndef LSH_CLIENT_H_INCLUDED
#define LSH_CLIENT_H_INCLUDED

29
#include "channel_commands.h"
Niels Möller's avatar
Niels Möller committed
30
#include "io.h"
Niels Möller's avatar
Niels Möller committed
31
#include "keyexchange.h"
Niels Möller's avatar
Niels Möller committed
32

33
34
35
#define GABA_DECLARE
#include "client.h.x"
#undef GABA_DECLARE
Niels Möller's avatar
Niels Möller committed
36

37
38
39
/* The argp option group for actions. */
#define CLIENT_ARGP_ACTION_GROUP 100
#define CLIENT_ARGP_MODIFIER_GROUP 200
40

Niels Möller's avatar
Niels Möller committed
41
struct packet_handler *
42
make_accept_service_handler(UINT32 service,
43
44
			    struct command_continuation *c,
			    struct exception_handler *e);
45

46
47
48
49
50
/* GABA:
   (class
     (name request_service)
     (super command)
     (vars
Niels Möller's avatar
Niels Möller committed
51
       (service . int)))
52
53
54
55
56
57
58
*/

void
do_request_service(struct command *s,
		   struct lsh_object *x,
		   struct command_continuation *c,
		   struct exception_handler *e);
59

60
61
62
63
#define STATIC_REQUEST_SERVICE(service) \
{ STATIC_COMMAND(do_request_service), service } 

struct command *make_request_service(int service);
64
65
66
67
68
69
70
71
72
73
74
75
76
77

/* GABA:
   (class
     (name escape_info)
     (vars
       (escape . UINT8)
       ; Handlers, indexed by character.
       (dispatch array (object lsh_callback) "0x100")))
*/

struct escape_info *make_escape_info(UINT8 escape);
struct abstract_write *
make_handle_escape(struct escape_info *info, struct abstract_write *next);

78
79
80
struct channel_request *make_handle_exit_status(int *exit_code);
struct channel_request *make_handle_exit_signal(int *exit_code);

Niels Möller's avatar
Niels Möller committed
81
struct command *make_open_session_command(struct ssh_channel *session);
82

83
84

extern struct channel_request_command request_shell;
85
86
#define REQUEST_SHELL (&request_shell.super.super)

87
extern struct command client_io;
88
#define CLIENT_START_IO (&client_io.super)
89

90
91
92
93
struct ssh_channel *
make_client_session_channel(struct lsh_fd *in,
			    struct lsh_fd *out,
			    struct lsh_fd *err,
Niels Möller's avatar
Niels Möller committed
94
			    struct escape_info *escape,
95
96
			    UINT32 initial_window,
			    int *exit_status);
Niels Möller's avatar
Niels Möller committed
97

98
99
struct command *
make_exec_request(struct lsh_string *command);
100

101
102
103
struct command *
make_pty_request(struct interact *tty);

104
105
106
107
108
109
110
111
112
113

struct channel_open *
make_channel_open_x11(struct io_backend *backend);

struct command *
make_forward_x11(const char *display, struct lsh_string *fake);

struct client_x11_display *
make_client_x11_display(const char *display, struct lsh_string *fake);

114
115
116
117
118
119
120
121
/* GABA:
   (class
     (name client_options)
     (vars
       (backend object io_backend)

       (tty object interact)

Niels Möller's avatar
Niels Möller committed
122
123
124
       ; -1 means default.
       (escape . int)
       
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
       ; For i/o exceptions 
       (handler object exception_handler)

       (exit_code . "int *")

       (not . int)
       (port . "char *")
       (remote object address_info)

       (local_user . "char *")
       (user . "char *")

       (with_remote_peers . int)
       
       ; -1 means default behaviour
       (with_pty . int)
141
142

       (with_x11 . int)
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
       
       ; Session modifiers
       (stdin_file . "const char *")
       (stdout_file . "const char *")
       (stderr_file . "const char *")

       ; fork() extra processes for handling stdio file-descriptors,
       ; to avoid setting them in non-blocking mode.
       (stdin_fork . int)
       (stdout_fork . int)
       (stderr_fork . int)

       ; True if the process's stdin or pty (respectively) has been used. 
       (used_stdin . int)
       (used_pty . int)
158
159
       (used_x11 . int)
       
160
       (start_shell . int)
Niels Möller's avatar
Niels Möller committed
161
       (remote_forward . int)
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
       (actions struct object_queue)))
*/

void
init_client_options(struct client_options *options,
		    struct io_backend *backend,
		    struct exception_handler *handler,
		    int *exit_code);

struct command *
client_add_action(struct client_options *options,
		  struct command *action);

int
client_parse_forward_arg(char *arg,
			 UINT32 *listen_port,
			 struct address_info **target);

180
181
extern struct command client_options2remote;
#define OPTIONS2REMOTE (&client_options2remote.super)
182

183
184
extern struct command client_options2actions;
#define OPTIONS2ACTIONS (&client_options2actions.super)
185
186
187

extern const struct argp client_argp;

Niels Möller's avatar
Niels Möller committed
188
#endif /* LSH_CLIENT_H_INCLUDED */