22 #define L_SET SEEK_SET 23 #define L_INCR SEEK_CUR 24 #define caddr_t void * 27 static char sccsid[] =
"@(#)ftp.c 5.28 (Berkeley) 4/20/89";
30 #ifndef MAXHOSTNAMELEN 31 #define MAXHOSTNAMELEN 64 35 #define vfprintf(a,b,c) _doprnt(b,c,a) 49 #define FD_SETSIZE 256 53 #define NFDBITS (sizeof(fd_mask) * NBBY) 55 #define howmany(x, y) (((x)+((y)-1))/(y)) 58 #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) 59 #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) 60 #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) 61 #define FD_ZERO(p) bzero((char *)(p), sizeof(*(p))) 98 register struct hostent *hp = 0;
101 static char hostnamebuf[80];
105 if (
hisctladdr.sin_addr.s_addr != (
unsigned long)-1) {
158 perror(
"ftp: getsockname");
178 perror(
"ftp: setsockopt");
181 #endif //SO_OOBINLINE 192 char *puser, *ppass, *pacct;
208 const char *myname =
"none";
216 tmp[
strlen(tmp) - 1] =
'\0';
238 if (!aflag && acct !=
NULL)
282 perror (
"No control connection for command");
320 int originalcode = 0, continuation = 0;
356 printf(
"421 Service not available, remote server has closed connection\n");
363 (
verbose > -1 &&
n ==
'5' && dig > 4))) {
365 ((dig == 1 || dig == 5) &&
verbose == 0))
372 if (!pflag &&
code == 227)
374 if (dig > 4 && pflag == 1 &&
isdigit(
c))
377 if (
c !=
'\r' &&
c !=
')')
384 if (dig == 4 &&
c ==
'-') {
398 if (continuation &&
code != originalcode) {
399 if (originalcode == 0)
407 if (
code == 421 || originalcode == 421)
435 printf(
"\nsend aborted\n");
441 #define HASHBYTES 1024 448 sig_t (*oldintr)(), (*oldintp)();
460 printf(
"remote: %s\n", remote);
489 else if (*
local ==
'|') {
524 if (closefunc !=
NULL)
536 if (closefunc !=
NULL)
543 if (closefunc !=
NULL)
555 if (closefunc !=
NULL)
564 if (closefunc !=
NULL)
580 for (bufp =
buf;
c > 0;
c -=
d, bufp +=
d)
581 if ((
d =
send(dout, bufp,
c, 0)) <= 0)
584 while (
bytes >= hashbytes) {
639 if (
bytes < hashbytes)
660 if (closefunc !=
NULL)
697 if (closefunc !=
NULL && fin !=
NULL)
724 int oldverbose = 0, oldtype = 0, is_retr, tcrflag, nfnd, bare_lfs = 0;
737 if (is_retr &&
verbose && printnames) {
741 printf(
"remote: %s\n", remote);
744 if (
proxy && is_retr) {
751 tcrflag = !
crflag && is_retr;
879 else if (*
local ==
'|') {
903 if (closefunc !=
NULL)
916 while (
bytes >= hashbytes) {
944 register int i,
n,
c;
959 if (closefunc !=
NULL)
992 printf(
"WARNING! %d bare linefeeds received in ASCII mode\n", bare_lfs);
993 printf(
"File may not have transferred correctly.\n");
997 if (
bytes < hashbytes)
1011 if (closefunc !=
NULL)
1024 if (
bytes > 0 && is_retr)
1110 if (closefunc !=
NULL && fout !=
NULL)
1127 register char *
p, *
a;
1130 int a0,
a1,
a2,
a3, p0, p1;
1142 perror(
"ftp: setsockopt (ignored)");
1144 printf(
"Passive mode refused.\n");
1157 &a0, &
a1, &
a2, &
a3, &p0, &p1) != 6) {
1158 printf(
"Passive mode address scan failure. Shouldn't happen!\n");
1197 perror(
"ftp: setsockopt (reuse address)");
1206 perror(
"ftp: setsockopt (ignored)");
1209 perror(
"ftp: getsockname");
1217 #define UC(b) (((int)b)&0xff) 1219 command(
"PORT %d,%d,%d,%d,%d,%d",
1243 int s, fromlen =
sizeof (
from);
1265 const char *direction;
1275 #define nz(x) ((x) == 0 ? 1 : (x)) 1277 printf(
"%ld bytes %s in %.1f seconds (%.0f Kbytes/s)\n",
1294 struct timeval *tdiff, *t1, *t0;
1314 static struct comvars {
1332 } proxstruct, tmpstruct;
1333 struct comvars *
ip, *
op;
1422 int tmptype, oldtype = 0, secndflag = 0, nfnd;
1431 cmd2 =
runique ?
"STOU" :
"STOR";
1433 printf(
"proxy server does not support third part transfers.\n");
1440 printf(
"No primary connection\n");
1446 if (
type != tmptype) {
1545 if (!
cpend && !secndflag) {
1569 *(
msg+1) = (
char)
DM;
1598 *(
msg+1) = (
char)
DM;
1616 if (!
cpend && !secndflag) {
1640 *(
msg+1) = (
char)
DM;
1669 *(
msg+1) = (
char)
DM;
1768 if (++
count == 100) {
1769 printf(
"runique: can't find unique file name.\n");
1783 else if (*(
cp - 2) ==
'.')
1786 *(
cp - 2) = *(
cp - 2) + 1;
void setbinary(int argc, const char *argv[])
int getreply(int expecteof)
_Check_return_ _CRTIMP int __cdecl ferror(_In_ FILE *_File)
struct sockaddr_in hisctladdr
static const struct update_accum a3
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
char * strcat(char *DstString, const char *SrcString)
void recvrequest(const char *cmd, const char *local, const char *remote, const char *mode, int printnames)
ACPI_SIZE strlen(const char *String)
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
GLdouble GLdouble GLdouble r
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
GLuint GLuint GLsizei count
void setascii(int argc, const char *argv[])
_Check_return_opt_ _CRTIMP int __cdecl _pclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl _popen(_In_z_ const char *_Command, _In_z_ const char *_Mode)
_Check_return_ _CRTIMP int __cdecl getc(_Inout_ FILE *_File)
void tvsub(struct timeval *tdiff, struct timeval *t1, struct timeval *t0)
static void cmdabort(int sig)
_Check_return_opt_ _CRTIMP long __cdecl lseek(_In_ int _FileHandle, _In_ long _Offset, _In_ int _Origin)
int __MINGW_NOTHROW __cdecl setjmp(jmp_buf _Buf)
int login(const char *host)
int ruserpass(const char *host, char **aname, char **apass, char **aacct)
GLenum GLuint GLsizei bufsize
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
GLenum GLuint GLenum GLsizei const GLchar * buf
#define gettimeofday(tv, tz)
struct sockaddr_in data_addr
char * getpass(const char *prompt)
static unsigned char bytes[4]
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
#define FD_ISSET(fd, set)
INT WSAAPI select(IN INT s, IN OUT LPFD_SET readfds, IN OUT LPFD_SET writefds, IN OUT LPFD_SET exceptfds, IN CONST struct timeval *timeout)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
void proxtrans(char *cmd, char *local, char *remote) const
int fputSocket(int s, char *buffer, int len)
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
char reply_string[BUFSIZ]
_Check_return_opt_ _CRTIMP int __cdecl fseek(_Inout_ FILE *_File, _In_ long _Offset, _In_ int _Origin)
void reset(int argc, const char *argv[])
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
char * hookup(const char *host, int port)
_Check_return_opt_ _CRTIMP int __cdecl putc(_In_ int _Ch, _Inout_ FILE *_File)
PHOSTENT WSAAPI gethostbyname(IN const char FAR *name)
void ptransfer(char *direction, long bytes, struct timeval *t0, struct timeval *t1) const
INT WSAAPI WSAGetLastError(VOID)
_Check_return_ _CRTIMP int __cdecl fileno(_In_ FILE *_File)
static const struct update_accum a2
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
_Check_return_ _CRTIMP int __cdecl chmod(_In_z_ const char *_Filename, _In_ int _AccessMode)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean flag
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
GLuint GLint GLboolean GLint GLenum access
int __cdecl vsprintf(char *_Dest, const char *_Format, va_list _Args)
void domacro(int argc, const char *argv[])
void settenex(int argc, const char *argv[])
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
void sendrequest(const char *cmd, const char *local, const char *remote, int printnames)
int command(const char *fmt,...)
void int int ULONGLONG int va_list * ap
_CRTIMP int __cdecl fstat(int _Desc, struct stat *_Stat)
char * strcpy(char *DstString, const char *SrcString)
int strcmp(const char *String1, const char *String2)
static const struct update_accum a1
GLuint GLuint GLsizei GLenum type
struct sockaddr_in myctladdr
GLboolean GLboolean GLboolean GLboolean a
const char * fprintfSocket(int s, const char *format,...)
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
static struct msdos_boot_sector bs
int dataconn(const char *mode)
void user(int argc, const char *argv[])
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
INT WSAAPI getsockname(IN SOCKET s, OUT LPSOCKADDR name, IN OUT INT FAR *namelen)
static int empty(struct fd_set *mask, int sec)
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *