]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/lukemftp/lukemftp.h
This commit was generated by cvs2svn to compensate for changes in r82498,
[FreeBSD/FreeBSD.git] / contrib / lukemftp / lukemftp.h
1 /* $Id: lukemftp.h,v 1.36 2000/10/11 03:07:36 lukem Exp $ */
2
3 #define FTP_PRODUCT     "lukemftp"
4 #define FTP_VERSION     "1.5"
5
6 #include "config.h"
7
8 #include <sys/types.h>
9 #include <sys/param.h>
10 #include <sys/ioctl.h>
11 #include <sys/socket.h>
12 #include <sys/stat.h>
13 #include <sys/wait.h>
14
15 #include <netinet/in.h>
16 #include <netinet/in_systm.h>
17 #include <netinet/ip.h>
18
19 #include <arpa/ftp.h>
20 #include <arpa/inet.h>
21
22 #include <ctype.h>
23 #include <errno.h>
24 #include <fcntl.h>
25 #include <limits.h>
26 #include <netdb.h>
27 #include <pwd.h>
28 #include <setjmp.h>
29 #include <signal.h>
30 #include <stdarg.h>
31 #include <stddef.h>
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <string.h>
35 #include <termios.h>
36 #include <unistd.h>
37
38 #if HAVE_POLL
39 # if HAVE_POLL_H
40 #  include <poll.h>
41 # elif HAVE_SYS_POLL_H
42 #  include <sys/poll.h>
43 # endif
44 #elif HAVE_SELECT
45 # define USE_SELECT
46 #else
47 # error "no poll() or select() found"
48 #endif
49
50 #if HAVE_DIRENT_H
51 # include <dirent.h>
52 #else
53 # define dirent direct
54 # if HAVE_SYS_NDIR_H
55 #  include <sys/ndir.h>
56 # endif
57 # if HAVE_SYS_DIR_H
58 #  include <sys/dir.h>
59 # endif
60 # if HAVE_NDIR_H
61 #  include <ndir.h>
62 # endif
63 #endif
64
65 #if TIME_WITH_SYS_TIME
66 # include <sys/time.h>
67 # include <time.h>
68 #else
69 # if HAVE_SYS_TIME_H
70 #  include <sys/time.h>
71 # else
72 #  include <time.h>
73 # endif
74 #endif
75
76 #if HAVE_ERR_H
77 # include <err.h>
78 #endif
79
80 #if HAVE_GLOB_BRACE
81 # include <glob.h>
82 #else
83 # include "ftpglob.h"
84 #endif
85
86 #if HAVE_PATHS_H
87 # include <paths.h>
88 #else
89 # define _PATH_BSHELL   "/bin/sh"
90 # define _PATH_TMP      "/tmp/"
91 #endif
92
93 typedef struct _stringlist {
94         char    **sl_str;
95         size_t    sl_max;
96         size_t    sl_cur;
97 } StringList;
98
99 StringList *sl_init(void);
100 int      sl_add(StringList *, char *);
101 void     sl_free(StringList *, int);
102 char    *sl_find(StringList *, char *);
103
104 #if HAVE_TERMCAP_H
105 # include <termcap.h>
106 #else
107 int      tgetent(char *, const char *);
108 char    *tgetstr(const char *, char **);
109 int      tgetflag(const char *);
110 int      tgetnum(const char *);
111 char    *tgoto(const char *, int, int);
112 void     tputs(const char *, int, int (*)(int));
113 #endif
114
115 #if HAVE_UTIL_H
116 # include <util.h>
117 #endif
118
119 #if HAVE_VIS_H
120 # include <vis.h>
121 #else
122 # include "ftpvis.h"
123 #endif
124
125 #if ! HAVE_IN_PORT_T
126 typedef unsigned short in_port_t;
127 #endif
128
129 #if ! HAVE_SOCKLEN_T
130 typedef unsigned int socklen_t;
131 #endif
132
133 #if HAVE_AF_INET6 && HAVE_SOCKADDR_IN6
134 # define INET6
135 #endif
136
137
138 #if ! HAVE_RFC2553_NETDB
139
140                                 /* RFC 2553 */
141 #undef  EAI_ADDRFAMILY
142 #define EAI_ADDRFAMILY   1      /* address family for hostname not supported */
143 #undef  EAI_AGAIN
144 #define EAI_AGAIN        2      /* temporary failure in name resolution */
145 #undef  EAI_BADFLAGS
146 #define EAI_BADFLAGS     3      /* invalid value for ai_flags */
147 #undef  EAI_FAIL
148 #define EAI_FAIL         4      /* non-recoverable failure in name resolution */
149 #undef  EAI_FAMILY
150 #define EAI_FAMILY       5      /* ai_family not supported */
151 #undef  EAI_MEMORY
152 #define EAI_MEMORY       6      /* memory allocation failure */
153 #undef  EAI_NODATA
154 #define EAI_NODATA       7      /* no address associated with hostname */
155 #undef  EAI_NONAME
156 #define EAI_NONAME       8      /* hostname nor servname provided, or not known */
157 #undef  EAI_SERVICE
158 #define EAI_SERVICE      9      /* servname not supported for ai_socktype */
159 #undef  EAI_SOCKTYPE
160 #define EAI_SOCKTYPE    10      /* ai_socktype not supported */
161 #undef  EAI_SYSTEM
162 #define EAI_SYSTEM      11      /* system error returned in errno */
163
164                                 /* KAME extensions? */
165 #undef  EAI_BADHINTS
166 #define EAI_BADHINTS    12
167 #undef  EAI_PROTOCOL
168 #define EAI_PROTOCOL    13
169 #undef  EAI_MAX
170 #define EAI_MAX         14
171
172                                 /* RFC 2553 */
173 #undef  NI_MAXHOST
174 #define NI_MAXHOST      1025
175 #undef  NI_MAXSERV
176 #define NI_MAXSERV      32
177
178 #undef  NI_NOFQDN
179 #define NI_NOFQDN       0x00000001
180 #undef  NI_NUMERICHOST
181 #define NI_NUMERICHOST  0x00000002
182 #undef  NI_NAMEREQD
183 #define NI_NAMEREQD     0x00000004
184 #undef  NI_NUMERICSERV
185 #define NI_NUMERICSERV  0x00000008
186 #undef  NI_DGRAM
187 #define NI_DGRAM        0x00000010
188
189                                 /* RFC 2553 */
190 #undef  AI_PASSIVE
191 #define AI_PASSIVE      0x00000001 /* get address to use bind() */
192 #undef  AI_CANONNAME
193 #define AI_CANONNAME    0x00000002 /* fill ai_canonname */
194
195                                 /* KAME extensions ? */
196 #undef  AI_NUMERICHOST
197 #define AI_NUMERICHOST  0x00000004 /* prevent name resolution */
198 #undef  AI_MASK
199 #define AI_MASK         (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
200
201                                 /* RFC 2553 */
202 #undef  AI_ALL
203 #define AI_ALL          0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
204 #undef  AI_V4MAPPED_CFG
205 #define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
206 #undef  AI_ADDRCONFIG
207 #define AI_ADDRCONFIG   0x00000400 /* only if any address is assigned */
208 #undef  AI_V4MAPPED
209 #define AI_V4MAPPED     0x00000800 /* accept IPv4-mapped IPv6 address */
210
211 #endif /* ! HAVE_RFC2553_NETDB */
212
213
214 #if ! HAVE_RFC2553_NETDB && ! HAVE_ADDRINFO
215
216 struct addrinfo {
217         int     ai_flags;       /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
218         int     ai_family;      /* PF_xxx */
219         int     ai_socktype;    /* SOCK_xxx */
220         int     ai_protocol;    /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
221         size_t  ai_addrlen;     /* length of ai_addr */
222         char    *ai_canonname;  /* canonical name for hostname */
223         struct sockaddr *ai_addr;       /* binary address */
224         struct addrinfo *ai_next;       /* next structure in linked list */
225 };
226
227 int     getaddrinfo(const char *, const char *,
228             const struct addrinfo *, struct addrinfo **);
229 int     getnameinfo(const struct sockaddr *, socklen_t, char *,
230             size_t, char *, size_t, int);
231 void    freeaddrinfo(struct addrinfo *);
232 char   *gai_strerror(int);
233
234 #endif /* ! HAVE_RFC2553_NETDB && ! HAVE_ADDRINFO */
235
236
237 #if ! HAVE_D_NAMLEN
238 # define DIRENT_MISSING_D_NAMLEN
239 #endif
240
241 #if ! HAVE_H_ERRNO_D
242 extern int      h_errno;
243 #endif
244 #define HAVE_H_ERRNO    1               /* XXX: an assumption for now... */
245
246 #if ! HAVE_FCLOSE_D
247 int     fclose(FILE *);
248 #endif
249
250 #if ! HAVE_GETPASS_D
251 char    *getpass(const char *);
252 #endif
253
254 #if ! HAVE_OPTARG_D
255 extern char    *optarg;
256 #endif
257
258 #if ! HAVE_OPTIND_D
259 extern int      optind;
260 #endif
261
262 #if ! HAVE_PCLOSE_D
263 int     pclose(FILE *);
264 #endif
265
266 #if ! HAVE_ERR
267 void    err(int, const char *, ...);
268 void    errx(int, const char *, ...);
269 void    warn(const char *, ...);
270 void    warnx(const char *, ...);
271 #endif
272
273 #if ! HAVE_FGETLN
274 char   *fgetln(FILE *, size_t *);
275 #endif
276
277 #if ! HAVE_FPARSELN
278 # define FPARSELN_UNESCESC      0x01
279 # define FPARSELN_UNESCCONT     0x02
280 # define FPARSELN_UNESCCOMM     0x04
281 # define FPARSELN_UNESCREST     0x08
282 # define FPARSELN_UNESCALL      0x0f
283 char   *fparseln(FILE *, size_t *, size_t *, const char[3], int);
284 #endif
285
286 #if ! HAVE_INET_NTOP
287 const char *inet_ntop(int, const void *, char *, size_t);
288 #endif
289
290 #if ! HAVE_MKSTEMP
291 int     mkstemp(char *);
292 #endif
293
294 #if ! HAVE_SNPRINTF
295 int     snprintf(char *, size_t, const char *, ...);
296 #endif
297
298 #if ! HAVE_STRDUP
299 char   *strdup(const char *);
300 #endif
301
302 #if ! HAVE_STRERROR
303 char   *strerror(int);
304 #endif
305
306 #if ! HAVE_STRPTIME || ! HAVE_STRPTIME_D
307 char   *strptime(const char *, const char *, struct tm *);
308 #endif
309
310 #if HAVE_QUAD_SUPPORT
311 # if ! HAVE_STRTOLL && HAVE_LONG_LONG
312 long long strtoll(const char *, char **, int);
313 #  if ! defined(QUAD_MIN)
314 #   define QUAD_MIN     (-0x7fffffffffffffffL-1)
315 #  endif
316 #  if ! defined(QUAD_MAX)
317 #   define QUAD_MAX     (0x7fffffffffffffffL)
318 #  endif
319 # endif
320 #else   /* ! HAVE_QUAD_SUPPORT */
321 # define NO_LONG_LONG   1
322 #endif  /* ! HAVE_QUAD_SUPPORT */
323
324 #if ! HAVE_TIMEGM
325 time_t  timegm(struct tm *);
326 #endif
327
328 #if ! HAVE_HSTRERROR
329 char   *strerror(int);
330 #endif
331
332 #if ! HAVE_STRLCAT
333 size_t  strlcat(char *, const char *, size_t);
334 #endif
335
336 #if ! HAVE_STRLCPY
337 size_t  strlcpy(char *, const char *, size_t);
338 #endif
339
340 #if ! HAVE_STRSEP
341 char   *strsep(char **stringp, const char *delim);
342 #endif
343
344 #if ! HAVE_MEMMOVE
345 # define memmove(a,b,c) bcopy((b),(a),(c))
346         /* XXX: add others #defines for borken systems? */
347 #endif
348
349 #if HAVE_GETPASSPHRASE
350 # define getpass getpassphrase
351 #endif
352
353 #if ! defined(MIN)
354 # define MIN(a, b)      ((a) < (b) ? (a) : (b))
355 #endif
356 #if ! defined(MAX)
357 # define MAX(a, b)      ((a) < (b) ? (b) : (a))
358 #endif
359
360 #if ! defined(timersub)
361 # define timersub(tvp, uvp, vvp)                                        \
362         do {                                                            \
363                 (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;          \
364                 (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;       \
365                 if ((vvp)->tv_usec < 0) {                               \
366                         (vvp)->tv_sec--;                                \
367                         (vvp)->tv_usec += 1000000;                      \
368                 }                                                       \
369         } while (0)
370 #endif
371
372 #if ! defined(S_ISLNK)
373 # define S_ISLNK(m)     ((m & S_IFMT) == S_IFLNK)
374 #endif
375
376 #define EPOCH_YEAR      1970
377 #define SECSPERHOUR     3600
378 #define SECSPERDAY      86400
379 #define TM_YEAR_BASE    1900