23#define L_INCR SEEK_CUR
27static char sccsid[] =
"@(#)ftp.c 5.28 (Berkeley) 4/20/89";
31#define MAXHOSTNAMELEN 64
35#define vfprintf(a,b,c) _doprnt(b,c,a)
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");
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;
int strcmp(const char *String1, const char *String2)
ACPI_SIZE strlen(const char *String)
CHAR FAR *WSAAPI inet_ntoa(IN IN_ADDR in)
ULONG WSAAPI inet_addr(IN CONST CHAR FAR *cp)
#define gettimeofday(tv, tz)
static unsigned char bytes[4]
void setascii(int argc, const char *argv[])
void user(int argc, const char *argv[])
void settenex(int argc, const char *argv[])
void setbinary(int argc, const char *argv[])
static void cmdabort(int sig)
char * hookup(const char *host, int port)
struct sockaddr_in hisctladdr
void sendrequest(const char *cmd, const char *local, const char *remote, int printnames)
void proxtrans(char *cmd, char *local, char *remote) const
void tvsub(struct timeval *tdiff, struct timeval *t1, struct timeval *t0)
int login(const char *host)
struct sockaddr_in myctladdr
int getreply(int expecteof)
void recvrequest(const char *cmd, const char *local, const char *remote, const char *mode, int printnames)
struct sockaddr_in data_addr
void ptransfer(char *direction, long bytes, struct timeval *t0, struct timeval *t1) const
int dataconn(const char *mode)
char reply_string[BUFSIZ]
static const WCHAR empty[]
static const WCHAR *const ext[]
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
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)
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
void domacro(int argc, const char *argv[])
int fputSocket(int s, char *buffer, int len)
char * getpass(const char *prompt)
const char * fprintfSocket(int s, const char *format,...)
PHOSTENT WSAAPI gethostbyname(IN const char FAR *name)
GLuint GLuint GLsizei count
GLuint GLuint GLsizei GLenum type
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLdouble GLdouble GLdouble r
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint GLint GLboolean GLint GLenum access
GLenum GLuint GLsizei bufsize
GLboolean GLboolean GLboolean GLboolean a
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
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_ _CRTIMP int __cdecl ferror(_In_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl _pclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP int __cdecl getc(_Inout_ FILE *_File)
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl putc(_In_ int _Ch, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fseek(_Inout_ FILE *_File, _In_ long _Offset, _In_ int _Origin)
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
int __cdecl vsprintf(char *_Dest, const char *_Format, va_list _Args)
_Check_return_ _CRTIMP FILE *__cdecl _popen(_In_z_ const char *_Command, _In_z_ const char *_Mode)
static struct msdos_boot_sector bs
static const struct update_accum a1
static const struct update_accum a2
static const struct update_accum a3
int ruserpass(const char *host, char **aname, char **apass, char **aacct)
_Check_return_ _CRTIMP int __cdecl chmod(_In_z_ const char *_Filename, _In_ int _AccessMode)
INT WSAAPI getsockname(IN SOCKET s, OUT LPSOCKADDR name, IN OUT INT FAR *namelen)
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
void int int ULONGLONG int va_list * ap
#define FD_ISSET(fd, set)
int PASCAL FAR WSAGetLastError(void)