| 1 |
/* |
| 2 |
Copyright (C) 1995-2026 Free Software Foundation, Inc. |
| 3 |
|
| 4 |
This file is part of GNU Inetutils. |
| 5 |
|
| 6 |
GNU Inetutils is free software: you can redistribute it and/or modify |
| 7 |
it under the terms of the GNU General Public License as published by |
| 8 |
the Free Software Foundation, either version 3 of the License, or (at |
| 9 |
your option) any later version. |
| 10 |
|
| 11 |
GNU Inetutils is distributed in the hope that it will be useful, but |
| 12 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 |
General Public License for more details. |
| 15 |
|
| 16 |
You should have received a copy of the GNU General Public License |
| 17 |
along with this program. If not, see `http://www.gnu.org/licenses/'. */ |
| 18 |
|
| 19 |
/* |
| 20 |
* Copyright (c) 1985, 1989, 1993, 1994 |
| 21 |
* The Regents of the University of California. All rights reserved. |
| 22 |
* |
| 23 |
* Redistribution and use in source and binary forms, with or without |
| 24 |
* modification, are permitted provided that the following conditions |
| 25 |
* are met: |
| 26 |
* 1. Redistributions of source code must retain the above copyright |
| 27 |
* notice, this list of conditions and the following disclaimer. |
| 28 |
* 2. Redistributions in binary form must reproduce the above copyright |
| 29 |
* notice, this list of conditions and the following disclaimer in the |
| 30 |
* documentation and/or other materials provided with the distribution. |
| 31 |
* 3. Neither the name of the University nor the names of its contributors |
| 32 |
* may be used to endorse or promote products derived from this software |
| 33 |
* without specific prior written permission. |
| 34 |
* |
| 35 |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 36 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 37 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 38 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 39 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 40 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 41 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 42 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 43 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 44 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 45 |
* SUCH DAMAGE. |
| 46 |
*/ |
| 47 |
|
| 48 |
/* |
| 49 |
* FTP global variables. |
| 50 |
*/ |
| 51 |
|
| 52 |
#include <sys/param.h> |
| 53 |
#include <setjmp.h> |
| 54 |
#include <progname.h> |
| 55 |
|
| 56 |
/* For in_port_t. */ |
| 57 |
#include <netinet/in.h> |
| 58 |
|
| 59 |
#ifndef FTP_EXTERN |
| 60 |
# define FTP_EXTERN extern |
| 61 |
#endif |
| 62 |
|
| 63 |
#define MAXLINE 200 |
| 64 |
|
| 65 |
/* |
| 66 |
* Options and other state info. |
| 67 |
*/ |
| 68 |
FTP_EXTERN int trace; /* trace packets exchanged */ |
| 69 |
FTP_EXTERN int hash; /* print # for each buffer transferred */ |
| 70 |
FTP_EXTERN int hashbytes; /* number of bytes per # printed */ |
| 71 |
FTP_EXTERN int sendport; /* use PORT cmd for each data connection */ |
| 72 |
FTP_EXTERN int verbose; /* print messages coming back from server */ |
| 73 |
FTP_EXTERN int connected; /* connected to server */ |
| 74 |
FTP_EXTERN int fromatty; /* input is from a terminal */ |
| 75 |
FTP_EXTERN int interactive; /* interactively prompt on m* cmds */ |
| 76 |
FTP_EXTERN int debug; /* debugging level */ |
| 77 |
FTP_EXTERN int bell; /* ring bell on cmd completion */ |
| 78 |
FTP_EXTERN int doglob; /* glob local file names */ |
| 79 |
FTP_EXTERN int autologin; /* establish user account on connection */ |
| 80 |
FTP_EXTERN int proxy; /* proxy server connection active */ |
| 81 |
FTP_EXTERN int proxflag; /* proxy connection exists */ |
| 82 |
FTP_EXTERN int sunique; /* store files on server with unique name */ |
| 83 |
FTP_EXTERN int runique; /* store local files with unique name */ |
| 84 |
FTP_EXTERN int mcase; /* map upper to lower case for mget names */ |
| 85 |
FTP_EXTERN int ntflag; /* use ntin ntout tables for name translation */ |
| 86 |
FTP_EXTERN int mapflag; /* use mapin mapout templates on file names */ |
| 87 |
FTP_EXTERN int code; /* return/reply code for ftp command */ |
| 88 |
FTP_EXTERN int crflag; /* if 1, strip car. rets. on ascii gets */ |
| 89 |
FTP_EXTERN char pasv[64]; /* passive port for proxy data connection */ |
| 90 |
FTP_EXTERN int passivemode; /* passive mode enabled */ |
| 91 |
FTP_EXTERN int doepsv4; /* EPSV/EPRT for IPv4 enabled */ |
| 92 |
FTP_EXTERN int usefamily; /* Precondition on an address family */ |
| 93 |
FTP_EXTERN int usereadline; /* Use readline support, given a TTY. */ |
| 94 |
FTP_EXTERN char *altarg; /* argv[1] with no shell-like preprocessing */ |
| 95 |
FTP_EXTERN char ntin[17]; /* input translation table */ |
| 96 |
FTP_EXTERN char ntout[17]; /* output translation table */ |
| 97 |
extern char *mapin; /* input map template */ |
| 98 |
extern char *mapout; /* output map template */ |
| 99 |
FTP_EXTERN char typename[32]; /* name of file transfer type */ |
| 100 |
FTP_EXTERN int type; /* requested file transfer type */ |
| 101 |
FTP_EXTERN int curtype; /* current file transfer type */ |
| 102 |
FTP_EXTERN char structname[32]; /* name of file transfer structure */ |
| 103 |
FTP_EXTERN int stru; /* file transfer structure */ |
| 104 |
FTP_EXTERN char formname[32]; /* name of file transfer format */ |
| 105 |
FTP_EXTERN int form; /* file transfer format */ |
| 106 |
FTP_EXTERN char modename[32]; /* name of file transfer mode */ |
| 107 |
FTP_EXTERN int mode; /* file transfer mode */ |
| 108 |
FTP_EXTERN char bytename[32]; /* local byte size in ascii */ |
| 109 |
FTP_EXTERN int bytesize; /* local byte size in binary */ |
| 110 |
|
| 111 |
FTP_EXTERN char *hostname; /* name of host connected to */ |
| 112 |
FTP_EXTERN char *netrc; /* netrc file chosen on command line */ |
| 113 |
FTP_EXTERN int unix_server; /* server is unix, can use binary for ascii */ |
| 114 |
FTP_EXTERN int unix_proxy; /* proxy is unix, can use binary for ascii */ |
| 115 |
|
| 116 |
FTP_EXTERN jmp_buf toplevel; /* non-local goto stuff for cmd scanner */ |
| 117 |
|
| 118 |
FTP_EXTERN char *line; /* input produced by readline or getline */ |
| 119 |
FTP_EXTERN size_t linelen; /* allocated length of the same, if known */ |
| 120 |
|
| 121 |
#ifndef MAXMARGV |
| 122 |
# define MAXMARGV 20 |
| 123 |
#endif |
| 124 |
|
| 125 |
FTP_EXTERN int margc; /* count of arguments on input line */ |
| 126 |
FTP_EXTERN char *margv[MAXMARGV]; /* args parsed from input line */ |
| 127 |
FTP_EXTERN int cpend; /* flag: if != 0, then pending server reply */ |
| 128 |
FTP_EXTERN int mflag; /* flag: if != 0, then active multi command */ |
| 129 |
|
| 130 |
FTP_EXTERN int options; /* used during socket creation */ |
| 131 |
|
| 132 |
/* |
| 133 |
* Format of command table. |
| 134 |
*/ |
| 135 |
struct cmd |
| 136 |
{ |
| 137 |
char *c_name; /* name of command */ |
| 138 |
char *c_help; /* help string */ |
| 139 |
char c_bell; /* give bell when command completes */ |
| 140 |
char c_conn; /* must be connected to use command */ |
| 141 |
char c_proxy; /* proxy server may execute */ |
| 142 |
void (*c_handler) (int, char **); /* function to call */ |
| 143 |
}; |
| 144 |
|
| 145 |
struct macel |
| 146 |
{ |
| 147 |
char mac_name[9]; /* macro name */ |
| 148 |
char *mac_start; /* start of macro in macbuf */ |
| 149 |
char *mac_end; /* end of macro in macbuf */ |
| 150 |
}; |
| 151 |
|
| 152 |
FTP_EXTERN int macnum; /* number of defined macros */ |
| 153 |
FTP_EXTERN struct macel macros[16]; |
| 154 |
FTP_EXTERN char macbuf[4096]; |
| 155 |
|
| 156 |
#include "extern.h" |