aboutsummaryrefslogtreecommitdiff
path: root/src/appl/gssftp/ftp/ftp_var.h
blob: 469e50686aee7cba8c2ce410c9e6cc834825a3b5 (plain)
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
/*
 * Copyright (c) 1985, 1989 Regents of the University of California.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by the University of
 *	California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *	@(#)ftp_var.h	5.9 (Berkeley) 6/1/90
 */

#ifdef _WIN32
#include <windows.h>
#endif

#ifdef _WIN32
int fclose_socket(FILE* f);
FILE* fdopen_socket(SOCKET s, char* mode);
#define FCLOSE_SOCKET(f) fclose_socket(f)
#define FDOPEN_SOCKET(s, mode) fdopen_socket(s, mode)
#define SOCKETNO(fd) _get_osfhandle(fd)
#define PERROR_SOCKET(str) do { errno = SOCKET_ERRNO; perror(str); } while(0)
#else
#define FCLOSE_SOCKET(f) fclose(f)
#define FDOPEN_SOCKET(s, mode) fdopen(s, mode)
#define SOCKETNO(fd) (fd)
#define PERROR_SOCKET(str) perror(str)
#endif

#ifdef _WIN32
typedef void (*sig_t)(int);
typedef void sigtype;
#else
#define sig_t my_sig_t
#define sigtype krb5_sigtype
typedef sigtype (*sig_t)();
#endif

/*
 * FTP global variables.
 */

#ifdef DEFINITIONS
#define extern
#endif

/*
 * Options and other state info.
 */
extern int	trace;		/* trace packets exchanged */
extern int	hash;		/* print # for each buffer transferred */
extern int	sendport;	/* use PORT cmd for each data connection */
extern int	verbose;	/* print messages coming back from server */
extern int	connected;	/* connected to server */
extern int	fromatty;	/* input is from a terminal */
extern int	interactive;	/* interactively prompt on m* cmds */
extern int	debug;		/* debugging level */
extern int	bell;		/* ring bell on cmd completion */
extern int	doglob;		/* glob local file names */
extern int autoauth;		/* Do authentication on connect */
extern int	autologin;	/* establish user account on connection */
extern int	autoencrypt;	/* negotiate encryption on connection */
extern int	forward;	/* forward credentials */
extern int	proxy;		/* proxy server connection active */
extern int	proxflag;	/* proxy connection exists */
extern int	sunique;	/* store files on server with unique name */
extern int	runique;	/* store local files with unique name */
extern int	mcase;		/* map upper to lower case for mget names */
extern int	ntflag;		/* use ntin ntout tables for name translation */
extern int	mapflag;	/* use mapin mapout templates on file names */
extern int	code;		/* return/reply code for ftp command */
extern int	crflag;		/* if 1, strip car. rets. on ascii gets */
extern char	pasv[64];	/* passive port for proxy data connection */
#ifndef NO_PASSIVE_MODE
extern int	passivemode;	/* passive mode enabled */
#endif
extern char	*altarg;	/* argv[1] with no shell-like preprocessing  */
extern char	ntin[17];	/* input translation table */
extern char	ntout[17];	/* output translation table */
#ifdef _WIN32
#ifndef MAXPATHLEN
#define MAXPATHLEN MAX_PATH
#endif
#else
#include <sys/param.h>
#endif
extern char	mapin[MAXPATHLEN];	/* input map template */
extern char	mapout[MAXPATHLEN];	/* output map template */
extern int	clevel;		/* command channel protection level */
extern int	dlevel;		/* data channel protection level */
extern int	type;		/* requested file transfer type */
extern int	curtype;	/* current file transfer type */
extern int	stru;		/* file transfer structure */
extern int	form;		/* file transfer format */
extern int	mode;		/* file transfer mode */
extern char	bytename[32];	/* local byte size in ascii */
extern int	bytesize;	/* local byte size in binary */

extern char	*hostname;	/* name of host connected to */
extern int	unix_server;	/* server is unix, can use binary for ascii */
extern int	unix_proxy;	/* proxy is unix, can use binary for ascii */

extern struct	servent *sp;	/* service spec for tcp/ftp */

#include <setjmp.h>
extern jmp_buf	toplevel;	/* non-local goto stuff for cmd scanner */

extern char	line[200];	/* input line buffer */
extern char	*stringbase;	/* current scan point in line buffer */
extern char	argbuf[200];	/* argument storage buffer */
extern char	*argbase;	/* current storage point in arg buffer */
extern int	margc;		/* count of arguments on input line */
extern char	*margv[20];	/* args parsed from input line */
extern int     cpend;           /* flag: if != 0, then pending server reply */
extern int	mflag;		/* flag: if != 0, then active multi command */

extern int	options;	/* used during socket creation */

/*
 * Format of command table.
 */
struct cmd {
	char	*c_name;	/* name of command */
	char	*c_help;	/* help string */
	char	c_bell;		/* give bell when command completes */
	char	c_conn;		/* must be connected to use command */
	char	c_proxy;	/* proxy server may execute */
	void	(*c_handler)();	/* function to call */
};

struct macel {
	char mac_name[9];	/* macro name */
	char *mac_start;	/* start of macro in macbuf */
	char *mac_end;		/* end of macro in macbuf */
};

extern int macnum;		/* number of defined macros */
extern struct macel macros[16];
extern char macbuf[4096];

#ifdef DEFINITIONS
#undef extern
#endif

extern	char *tail();
#ifndef _WIN32
extern	char *mktemp();
#endif

extern int command(char *, ...);

char *remglob (char **, int);
int another (int *, char ***, char *);
void makeargv (void);
void setpeer (int, char **);
void setclevel (int, char **);
void setdlevel (int, char **);
void ccc (void);
void setclear (void);
void setsafe (void);
void setprivate (void);
void settype (int, char **);
void changetype (int, int);
void setbinary (void);
void setascii (void);
void settenex (void);
void set_mode  (int, char **);
void setform  (int, char **);
void setstruct  (int, char **);
void siteidle  (int, char **);
void put  (int, char **);
void mput  (int, char **);
void reget  (int, char **);
void get  (int, char **);
void mget  (int, char **);
void status  (int, char **);
void setbell (void);
void settrace (void);
void sethash (void);
void setverbose (void);
void setport (void);
void setprompt (void);
void setglob (void);
void setdebug (int, char **);
void cd (int, char **);
void lcd (int, char **);
void delete_file (int, char **);
void mdelete (int, char **);
void renamefile (int, char **);
void ls (int, char **);
void mls (int, char **);
void shell (int, char **);
void user (int, char **);
void pwd (void);
void makedir (int, char **);
void removedir (int, char **);
void quote (int, char **);
void site (int, char **);
void do_chmod (int, char **);
void do_umask (int, char **);
void setidle (int, char **);
void rmthelp (int, char **);
void quit (void);
void disconnect (void);
void fatal (char *);
void account (int, char **);
void doproxy (int, char **);
void setcase (void);
void setcr (void);
void setntrans (int, char **);
void setnmap (int, char **);
void setsunique (void);
void setrunique (void);
void cdup (void);
void restart (int, char **);
void syst (void);
void macdef (int, char **);
void sizecmd (int, char **);
void modtime (int, char **);
void rmtstatus (int, char **);
void newer (int, char **);
void setpassive (void);

/* ftp.c */
void sendrequest (char *, char *, char *, int);
void recvrequest (char *, char *volatile, char *, char *, int);
int login (char *);
void setpbsz (unsigned int);
void pswitch (int);
int getreply (int);
void reset (void);
char *hookup (char *, int);
int do_auth (void);

/* glob.c */
void blkfree (char **);

/* domacro.c */
void domacro (int, char **);


/* main.c */
void help (int, char **);
struct cmd *getcmd (char *);


/* ruserpass.c */
int ruserpass (char *, char **, char **, char **);

/* radix.h */
int radix_encode (unsigned char *, unsigned char *, int *, int);
char *radix_error (int);

/* getpass.c */
char *mygetpass (char *);

/* glob.c */
char **ftpglob (char *);