ReactOS 0.4.16-dev-106-g10b08aa
prototypes.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int fgetcSocket (int s)
 
const charfputsSocket (const char *format, int s)
 
const charfprintfSocket (int s, const char *format,...)
 
int fputcSocket (int s, char putChar)
 
int fputSocket (int s, char *putChar, int len)
 
charfgetsSocket (int s, char *string)
 
charhookup (const char *host, int port)
 
char ** glob (const char *s)
 
int herror (char *s)
 
int getreply (int expecteof)
 
int ruserpass (const char *host, char **aname, char **apass, char **aacct)
 
chargetpass (const char *prompt)
 
void makeargv (void)
 
void domacro (int argc, const char *argv[])
 
void proxtrans (const char *cmd, const char *local, const char *remote)
 
int null (void)
 
int initconn (void)
 
void disconnect (int argc, const char *argv[])
 
void ptransfer (const char *direction, long bytes, struct timeval *t0, struct timeval *t1)
 
void setascii (int argc, const char *argv[])
 
void setbinary (int argc, const char *argv[])
 
void setebcdic (void)
 
void settenex (int argc, const char *argv[])
 
void tvsub (struct timeval *tdiff, struct timeval *t1, struct timeval *t0)
 
void setpassive (int argc, const char *argv[])
 
void setpeer (int argc, const char *argv[])
 
void cmdscanner (int top)
 
void pswitch (int flag)
 
void quit (int argc, const char *argv[])
 
int login (const char *host)
 
int command (const char *fmt,...)
 
int globulize (const char **cpp)
 
void sendrequest (const char *cmd, const char *local, const char *remote, int printnames)
 
void recvrequest (const char *cmd, const char *local, const char *remote, const char *mode, int printnames)
 
int confirm (const char *cmd, const char *file)
 
void blkfree (char **av0)
 
int getit (int argc, const char *argv[], int restartit, const char *mode)
 
int sleep (int time)
 
chartail (void)
 
void setbell (int argc, const char *argv[])
 
void setdebug (int argc, const char *argv[])
 
void setglob (int argc, const char *argv[])
 
void sethash (int argc, const char *argv[])
 
void setport (int argc, const char *argv[])
 
void setprompt (int argc, const char *argv[])
 
void settrace (int argc, const char *argv[])
 
void setverbose (int argc, const char *argv[])
 
void settype (int argc, const char *argv[])
 
void setform (int argc, const char *argv[])
 
void setstruct (int argc, const char *argv[])
 
void restart (int argc, const char *argv[])
 
void syst (int argc, const char *argv[])
 
void cd (int argc, const char *argv[])
 
void lcd (int argc, const char *argv[])
 
void delete (int argc, const char *argv[])
 
void mdelete (int argc, const char *argv[])
 
void ls (int argc, const char *argv[])
 
void mls (int argc, const char *argv[])
 
void get (int argc, const char *argv[])
 
void mget (int argc, const char *argv[])
 
void help (int argc, const char *argv[])
 
void put (int argc, const char *argv[])
 
void mput (int argc, const char *argv[])
 
void reget (int argc, const char *argv[])
 
void status (int argc, const char *argv[])
 
void renamefile (int argc, const char *argv[])
 
void quote (int argc, const char *argv[])
 
void rmthelp (int argc, const char *argv[])
 
void site (int argc, const char *argv[])
 
void pwd (int argc, const char *argv[])
 
void makedir (int argc, const char *argv[])
 
void removedir (int argc, const char *argv[])
 
void setcr (int argc, const char *argv[])
 
void account (int argc, const char *argv[])
 
void doproxy (int argc, const char *argv[])
 
void reset (int argc, const char *argv[])
 
void setcase (int argc, const char *argv[])
 
void setntrans (int argc, const char *argv[])
 
void setnmap (int argc, const char *argv[])
 
void setsunique (int argc, const char *argv[])
 
void setrunique (int argc, const char *argv[])
 
void cdup (int argc, const char *argv[])
 
void macdef (int argc, const char *argv[])
 
void sizecmd (int argc, const char *argv[])
 
void modtime (int argc, const char *argv[])
 
void newer (int argc, const char *argv[])
 
void rmtstatus (int argc, const char *argv[])
 
void do_chmod (int argc, const char *argv[])
 
void do_umask (int argc, const char *argv[])
 
void idle (int argc, const char *argv[])
 
void shell (int argc, const char *argv[])
 
void user (int argc, const char *argv[])
 
void fsetmode (int argc, const char *argv[])
 
struct cmdgetcmd (const char *name)
 

Function Documentation

◆ account()

void account ( int  argc,
const char argv[] 
)

Definition at line 1690 of file cmds.c.

1691{
1692 char acct[50], *getpass(), *ap;
1693
1694 if (argc > 1) {
1695 ++argv;
1696 --argc;
1697 (void) strncpy(acct,*argv,49);
1698 acct[49] = '\0';
1699 while (argc > 1) {
1700 --argc;
1701 ++argv;
1702 (void) strncat(acct,*argv, 49-strlen(acct));
1703 }
1704 ap = acct;
1705 }
1706 else {
1707 ap = getpass("Account:");
1708 }
1709 (void) command("ACCT %s", ap);
1710}
static int argc
Definition: ServiceArgs.c:12
char * strncat(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:605
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
char * getpass(const char *prompt)
Definition: fake.c:231
#define argv
Definition: mplay32.c:18
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36

Referenced by check_wellknown_name(), get_sid_info(), test_create_delete_svc(), test_LookupAccountName(), test_LsaLookupNames2(), test_process_security(), and test_sid_str().

◆ blkfree()

void blkfree ( char **  av0)

Definition at line 28 of file fake.c.

29{
30 register char **av = av0;
31
32 while (*av)
33 free(*av++);
34}
#define free
Definition: debug_ros.c:5

Referenced by globulize(), and mput().

◆ cd()

void cd ( int  argc,
const char argv[] 
)

Definition at line 965 of file cmds.c.

966{
967
968 if (argc < 2) {
969 (void) strcat(line, " ");
970 printf("(remote-directory) ");
971 (void) fflush(stdout);
972 (void) gets(&line[strlen(line)]);
973 makeargv();
974 argc = margc;
975 argv = margv;
976 }
977 if (argc < 2) {
978 printf("usage:%s remote-directory\n", argv[0]);
979 (void) fflush(stdout);
980 code = -1;
981 return;
982 }
983 if (command("CWD %s", argv[1]) == ERROR && code == 500) {
984 if (verbose) {
985 printf("CWD command not recognized, trying XCWD\n");
986 (void) fflush(stdout);
987 }
988 (void) command("XCWD %s", argv[1]);
989 }
990}
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
void makeargv(void)
Definition: main.c:393
#define ERROR(name)
Definition: error_private.h:53
#define printf
Definition: freeldr.h:97
const char * margv[20]
Definition: main.c:102
int margc
Definition: main.c:101
#define stdout
Definition: stdio.h:99
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
_CRTIMP char *__cdecl gets(char *_Buffer)
Definition: file.c:3645
#define verbose
Definition: rosglue.h:36
Definition: inflate.c:139
Definition: parser.c:49

◆ cdup()

void cdup ( int  argc,
const char argv[] 
)

Definition at line 2103 of file cmds.c.

2104{
2105 if (command("CDUP") == ERROR && code == 500) {
2106 if (verbose) {
2107 printf("CDUP command not recognized, trying XCUP\n");
2108 (void) fflush(stdout);
2109 }
2110 (void) command("XCUP");
2111 }
2112}

◆ cmdscanner()

void cmdscanner ( int  top)

Definition at line 311 of file main.c.

312{
313 register struct cmd *c;
314
315 if (!top)
316 (void) putchar('\n');
317 for (;;) {
318 (void) fflush(stdout);
319 if (fromatty) {
320 printf("ftp> ");
321 (void) fflush(stdout);
322 }
323 if (gets(line) == 0) {
324 if (feof(stdin) || ferror(stdin))
325 quit(0, NULL);
326 break;
327 }
328 if (line[0] == 0)
329 break;
330 makeargv();
331 if (margc == 0) {
332 continue;
333 }
334 c = getcmd(margv[0]);
335 if (c == (struct cmd *)-1) {
336 printf("?Ambiguous command\n");
337 continue;
338 }
339 if (c == 0) {
340 printf("?Invalid command\n");
341 continue;
342 }
343 if (c->c_conn && !connected) {
344 printf ("Not connected.\n");
345 continue;
346 }
347 (*c->c_handler)(margc, margv);
348 if (bell && c->c_bell)
349 (void) putchar('\007');
350 if (c->c_handler != help)
351 break;
352 }
353 (void) fflush(stdout);
354// (void) signal(SIGINT, intr);
355// (void) signal(SIGPIPE, lostpeer);
356}
int help
Definition: sort.c:20
void quit(int argc, const char *argv[])
Definition: cmds.c:1606
const char * margv[20]
Definition: main.c:102
int bell
Definition: main.c:65
struct cmd * getcmd(const char *name)
Definition: main.c:359
int connected
Definition: main.c:61
int fromatty
Definition: main.c:62
int margc
Definition: main.c:101
int putchar(int c)
Definition: crtsupp.c:12
#define NULL
Definition: types.h:112
const GLubyte * c
Definition: glext.h:8905
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
_Check_return_ _CRTIMP int __cdecl ferror(_In_ FILE *_File)
_Check_return_ _CRTIMP int __cdecl feof(_In_ FILE *_File)
#define stdin
Definition: stdio.h:98
#define c
Definition: ke_i.h:80
Definition: ftp_var.h:139

Referenced by main().

◆ command()

int command ( const char fmt,
  ... 
)

Definition at line 266 of file ftp.c.

267{
268 va_list ap;
269 int r;
270 void (*oldintr)(int);
271
272 abrtflag = 0;
273 if (debug) {
274 printf("---> ");
275 va_start(ap, fmt);
277 va_end(ap);
278 printf("\n");
279 (void) fflush(stdout);
280 }
281 if (cout == 0) {
282 perror ("No control connection for command");
283 code = -1;
284 return (0);
285 }
286 oldintr = signal(SIGINT,cmdabort);
287 {
288 char buffer[1024];
289
290 va_start(ap, fmt);
292 va_end(ap);
293//DLJ: to work through firewalls - send the command as a single message
294 strcat(buffer,"\r\n");
296 }
297//DLJ: the following two lines are replaced by the strcat above - seems to
298// make it work through firewalls.
299// fprintfSocket(cout, "\r\n");
300// (void) fflush(cout);
301 cpend = 1;
302 r = getreply(!strcmp(fmt, "QUIT"));
303 if (abrtflag && oldintr != SIG_IGN)
304 (*oldintr)(SIGINT);
305// (void) signal(SIGINT, oldintr);
306 return(r);
307}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
static void cmdabort(int sig)
Definition: ftp.c:254
int abrtflag
Definition: ftp.c:71
SOCKET cout
Definition: ftp.c:83
int getreply(int expecteof)
Definition: ftp.c:314
#define SIGINT
Definition: signal.h:23
#define SIG_IGN
Definition: signal.h:48
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
const char * fprintfSocket(int s, const char *format,...)
Definition: fake.c:114
int cpend
Definition: main.c:103
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint buffer
Definition: glext.h:5915
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
int __cdecl vsprintf(char *_Dest, const char *_Format, va_list _Args)
Definition: sprintf.c:733
#define debug(msg)
Definition: key_call.c:71
int signal
Definition: except.c:82
Definition: dsound.c:943

◆ confirm()

int confirm ( const char cmd,
const char file 
)

Definition at line 1636 of file cmds.c.

1637{
1638 char line[BUFSIZ];
1639
1640 if (!interactive)
1641 return (1);
1642 printf("%s %s? ", cmd, file);
1643 (void) fflush(stdout);
1644 (void) gets(line);
1645 return (*line != 'n' && *line != 'N');
1646}
#define BUFSIZ
Definition: nsplookup.c:25
#define interactive
Definition: rosglue.h:34
Definition: fci.c:127

Referenced by _CZipAskReplace(), ls(), mdelete(), mget(), mls(), and mput().

◆ delete()

void delete ( int  argc,
const char argv[] 
)

Definition at line 1025 of file cmds.c.

1026{
1027
1028 if (argc < 2) {
1029 (void) strcat(line, " ");
1030 printf("(remote-file) ");
1031 (void) fflush(stdout);
1032 (void) gets(&line[strlen(line)]);
1033 makeargv();
1034 argc = margc;
1035 argv = margv;
1036 }
1037 if (argc < 2) {
1038 printf("usage:%s remote-file\n", argv[0]);
1039 (void) fflush(stdout);
1040 code = -1;
1041 return;
1042 }
1043 (void) command("DELE %s", argv[1]);
1044}

◆ disconnect()

void disconnect ( int  argc,
const char argv[] 
)

Definition at line 1620 of file cmds.c.

1621{
1622 extern SOCKET cout;
1623 extern int data;
1624
1625 if (!connected)
1626 return;
1627 (void) command("QUIT");
1628 cout = 0;
1629 connected = 0;
1630 data = -1;
1631 if (!proxy) {
1632 macnum = 0;
1633 }
1634}
int proxy
Definition: main.c:67
int macnum
Definition: main.c:108
int connected
Definition: main.c:61
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define cout
Definition: iostream.cpp:38
UINT_PTR SOCKET
Definition: winsock.h:47

Referenced by quit().

◆ do_chmod()

void do_chmod ( int  argc,
const char argv[] 
)

Definition at line 1546 of file cmds.c.

1547{
1548 if (argc == 2) {
1549 printf("usage: %s mode file-name\n", argv[0]);
1550 (void) fflush(stdout);
1551 code = -1;
1552 return;
1553 }
1554 if (argc < 3) {
1555 (void) strcat(line, " ");
1556 printf("(mode and file-name) ");
1557 (void) fflush(stdout);
1558 (void) gets(&line[strlen(line)]);
1559 makeargv();
1560 argc = margc;
1561 argv = margv;
1562 }
1563 if (argc != 3) {
1564 printf("usage: %s mode file-name\n", argv[0]);
1565 (void) fflush(stdout);
1566 code = -1;
1567 return;
1568 }
1569 (void)command("SITE CHMOD %s %s", argv[1], argv[2]);
1570}

◆ do_umask()

void do_umask ( int  argc,
const char argv[] 
)

Definition at line 1572 of file cmds.c.

1573{
1574 int oldverbose = verbose;
1575
1576 verbose = 1;
1577 (void) command(argc == 1 ? "SITE UMASK" : "SITE UMASK %s", argv[1]);
1578 verbose = oldverbose;
1579}

◆ domacro()

void domacro ( int  argc,
const char argv[] 
)

Definition at line 26 of file domacro.c.

27{
28 int i, j;
29 const char *cp1;
30 char *cp2;
31 int count = 2, loopflg = 0;
32 char line2[200];
33 struct cmd *getcmd(), *c;
34
35 if (argc < 2) {
36 (void) strcat(line, " ");
37 printf("(macro name) ");
39 (void) gets(&line[strlen(line)]);
40 makeargv();
41 argc = margc;
42 argv = margv;
43 }
44 if (argc < 2) {
45 printf("Usage: %s macro_name.\n", argv[0]);
47 code = -1;
48 return;
49 }
50 for (i = 0; i < macnum; ++i) {
51 if (!strncmp(argv[1], macros[i].mac_name, 9)) {
52 break;
53 }
54 }
55 if (i == macnum) {
56 printf("'%s' macro not found.\n", argv[1]);
58 code = -1;
59 return;
60 }
61 (void) strcpy(line2, line);
62TOP:
63 cp1 = macros[i].mac_start;
64 while (cp1 != macros[i].mac_end) {
65 while (isspace(*cp1)) {
66 cp1++;
67 }
68 cp2 = line;
69 while (*cp1 != '\0') {
70 switch(*cp1) {
71 case '\\':
72 *cp2++ = *++cp1;
73 break;
74 case '$':
75 if (isdigit(*(cp1+1))) {
76 j = 0;
77 while (isdigit(*++cp1)) {
78 j = 10*j + *cp1 - '0';
79 }
80 cp1--;
81 if (argc - 2 >= j) {
82 (void) strcpy(cp2, argv[j+1]);
83 cp2 += strlen(argv[j+1]);
84 }
85 break;
86 }
87 if (*(cp1+1) == 'i') {
88 loopflg = 1;
89 cp1++;
90 if (count < argc) {
91 (void) strcpy(cp2, argv[count]);
92 cp2 += strlen(argv[count]);
93 }
94 break;
95 }
96 /* intentional drop through */
97 default:
98 *cp2++ = *cp1;
99 break;
100 }
101 if (*cp1 != '\0') {
102 cp1++;
103 }
104 }
105 *cp2 = '\0';
106 makeargv();
107 c = getcmd(margv[0]);
108 if (c == (struct cmd *)-1) {
109 printf("?Ambiguous command\n");
110 code = -1;
111 }
112 else if (c == 0) {
113 printf("?Invalid command\n");
114 code = -1;
115 }
116 else if (c->c_conn && !connected) {
117 printf("Not connected.\n");
118 code = -1;
119 }
120 else {
121 if (verbose) {
122 printf("%s\n",line);
123 }
124 (*c->c_handler)(margc, margv);
125 if (bell && c->c_bell) {
126 (void) putchar('\007');
127 }
128 (void) strcpy(line, line2);
129 makeargv();
130 argc = margc;
131 argv = margv;
132 }
133 if (cp1 != macros[i].mac_end) {
134 cp1++;
135 }
136 (void) fflush(stdout);
137 }
138 if (loopflg && ++count < argc) {
139 goto TOP;
140 }
141}
#define isspace(c)
Definition: acclib.h:69
#define isdigit(c)
Definition: acclib.h:68
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
char line[200]
Definition: main.c:97
int bell
Definition: main.c:65
struct macel macros[16]
Definition: main.c:109
GLuint GLuint GLsizei count
Definition: gl.h:1545
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
Definition: glfuncs.h:248
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 GLint GLint j
Definition: glfuncs.h:250

Referenced by login().

◆ doproxy()

void doproxy ( int  argc,
const char argv[] 
)

Definition at line 1734 of file cmds.c.

1735{
1736 register struct cmd *c;
1737 struct cmd *getcmd();
1738// extern struct cmd cmdtab[];
1739 extern jmp_buf abortprox;
1740
1741 if (argc < 2) {
1742 (void) strcat(line, " ");
1743 printf("(command) ");
1744 (void) fflush(stdout);
1745 (void) gets(&line[strlen(line)]);
1746 makeargv();
1747 argc = margc;
1748 argv = margv;
1749 }
1750 if (argc < 2) {
1751 printf("usage:%s command\n", argv[0]);
1752 (void) fflush(stdout);
1753 code = -1;
1754 return;
1755 }
1756 c = getcmd(argv[1]);
1757 if (c == (struct cmd *) -1) {
1758 printf("?Ambiguous command\n");
1759 (void) fflush(stdout);
1760 code = -1;
1761 return;
1762 }
1763 if (c == 0) {
1764 printf("?Invalid command\n");
1765 (void) fflush(stdout);
1766 code = -1;
1767 return;
1768 }
1769 if (!c->c_proxy) {
1770 printf("?Invalid proxy command\n");
1771 (void) fflush(stdout);
1772 code = -1;
1773 return;
1774 }
1775 if (setjmp(abortprox)) {
1776 code = -1;
1777 return;
1778 }
1779// oldintr = signal(SIGINT, proxabort);
1780 pswitch(1);
1781 if (c->c_conn && !connected) {
1782 printf("Not connected\n");
1783 (void) fflush(stdout);
1784 pswitch(0);
1785// (void) signal(SIGINT, oldintr);
1786 code = -1;
1787 return;
1788 }
1789 (*c->c_handler)(argc-1, argv+1);
1790 if (connected) {
1791 proxflag = 1;
1792 }
1793 else {
1794 proxflag = 0;
1795 }
1796 pswitch(0);
1797// (void) signal(SIGINT, oldintr);
1798}
jmp_buf abortprox
Definition: cmds.c:1712
void pswitch(int flag)
Definition: ftp.c:1310
#define setjmp
Definition: setjmp.h:209
_JBTYPE jmp_buf[_JBLEN]
Definition: setjmp.h:186
int proxflag
Definition: main.c:69

◆ fgetcSocket()

int fgetcSocket ( int  s)

Definition at line 89 of file fake.c.

90{
91 static int index = 0;
92 static int total = 0;
93 static char buffer[4096];
94
95 if (index == total)
96 {
97 index = 0;
98 total = recv(s, buffer, sizeof(buffer), 0);
99
100 if (total == SOCKET_ERROR)
101 {
102 total = 0;
103 return ERROR;
104 }
105
106 if (total == 0)
107 return EOF;
108 }
109 return buffer[index++];
110}
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23
size_t total
GLdouble s
Definition: gl.h:2039
GLuint index
Definition: glext.h:6031
#define EOF
Definition: stdio.h:24
#define SOCKET_ERROR
Definition: winsock.h:333

Referenced by getreply(), and recvrequest().

◆ fgetsSocket()

char * fgetsSocket ( int  s,
char string 
)

Definition at line 168 of file fake.c.

169{
170 char buffer[2] = {0};
171 int i, count;
172
173 for (i = 0, count = 1; count != 0 && buffer[0] != '\n'; i++)
174 {
175 checkRecv(s);
176
177 count = recv(s, buffer, 1, 0);
178
179 if (count == SOCKET_ERROR)
180 {
181 printf("Error in fgetssocket");
182 return NULL;
183 }
184
185 if (count == 1)
186 {
187 string[i] = buffer[0];
188
189 if (i == MAX_ASCII - 3)
190 {
191 count = 0;
192 string[++i] = '\n';
193 string[++i] = '\0';
194 }
195 }
196 else
197 {
198 if (i == 0)
199 return NULL;
200 else
201 {
202 string[i] = '\n';
203 string[i + 1] = '\0'; // This is risky
204 return string;
205 }
206
207 }
208
209 }
210 string[i] = '\0';
211
212#ifdef DEBUG_IN
213 printf("%s", string);
214#endif
215 return string;
216}
#define MAX_ASCII
Definition: fake.c:5
int checkRecv(SOCKET s)
Definition: fake.c:9
char string[160]
Definition: util.h:11

◆ fprintfSocket()

const char * fprintfSocket ( int  s,
const char format,
  ... 
)

Definition at line 114 of file fake.c.

115{
116 va_list argptr;
117 char buffer[10009];
118
119 va_start(argptr, format);
120 vsprintf(buffer, format, argptr);
121 va_end(argptr);
122
123 send(s, buffer, strlen(buffer), 0);
124
125 return NULL;
126}
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
Definition: format.c:58

Referenced by command(), getreply(), proxtrans(), and recvrequest().

◆ fputcSocket()

int fputcSocket ( int  s,
char  putChar 
)

Definition at line 135 of file fake.c.

136{
137 char buffer[2];
138
139 buffer[0] = putChar;
140 buffer[1] = '\0';
141
142 if(SOCKET_ERROR==send(s, buffer, 1, 0)) {
143 int iret=WSAGetLastError ();
144 fprintf(stdout,"fputcSocket: %d\n",iret);
145 return 0;
146 }
147 else {
148 return putChar;
149 }
150}
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
int PASCAL FAR WSAGetLastError(void)
Definition: dllmain.c:112

◆ fputSocket()

int fputSocket ( int  s,
char putChar,
int  len 
)

Definition at line 151 of file fake.c.

152{
153 int iret;
154 while(len) {
155 if(SOCKET_ERROR==(iret=send(s, buffer, len, 0)))
156 {
157 iret=WSAGetLastError ();
158 fprintf(stdout,"fputcSocket: %d\n",iret);
159 return 0;
160 }
161 else {
162 return len-=iret;
163 }
164 }
165 return 0;
166}
GLenum GLsizei len
Definition: glext.h:6722

Referenced by sendrequest().

◆ fputsSocket()

const char * fputsSocket ( const char format,
int  s 
)

Definition at line 128 of file fake.c.

129{
130 send(s, format, strlen(format), 0);
131
132 return NULL;
133}

◆ fsetmode()

void fsetmode ( int  argc,
const char argv[] 
)

Definition at line 243 of file cmds.c.

244{
245
246 printf("We only support %s mode, sorry.\n", modename);
247 (void) fflush(stdout);
248 code = -1;
249}
char modename[32]
Definition: main.c:90

◆ get()

void get ( int  argc,
const char argv[] 
)

Definition at line 480 of file cmds.c.

481{
482 (void) getit(argc, argv, 0, restart_point ? "r+w" : "w" );
483}
off_t restart_point
Definition: ftp.c:81
int getit(int argc, const char *argv[], int restartit, const char *mode)
Definition: cmds.c:488

Referenced by __get_num(), strstreambuf::_M_setup(), gz_load(), _Locale_impl::insert_time_facets(), strstreambuf::strstreambuf(), test_flushed_getdata(), test_getdatahere(), test_nonole_clipboard(), test_secure_connection(), and TestMessageHandler().

◆ getcmd()

struct cmd * getcmd ( const char name)

Definition at line 359 of file main.c.

360{
361 extern struct cmd cmdtab[];
362 const char *p, *q;
363 struct cmd *c, *found;
364 int nmatches, longest;
365
366 longest = 0;
367 nmatches = 0;
368 found = 0;
369 for (c = cmdtab; (p = c->c_name); c++) {
370 for (q = name; *q == *p++; q++)
371 if (*q == 0) /* exact match? */
372 return (c);
373 if (!*q) { /* the name was a prefix */
374 if (q - name > longest) {
375 longest = q - name;
376 nmatches = 1;
377 found = c;
378 } else if (q - name == longest)
379 nmatches++;
380 }
381 }
382 if (nmatches > 1)
383 return ((struct cmd *)-1);
384 return (found);
385}
struct cmd cmdtab[]
Definition: cmdtab.c:95
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLfloat GLfloat p
Definition: glext.h:8902
Definition: name.c:39

Referenced by cmdscanner(), domacro(), doproxy(), and help().

◆ getit()

int getit ( int  argc,
const char argv[],
int  restartit,
const char mode 
)

Definition at line 488 of file cmds.c.

489{
490 int loc = 0;
491 const char *oldargv1, *oldargv2;
492
493 if (argc == 2) {
494 argc++;
495 argv[2] = argv[1];
496 loc++;
497 }
498 if (argc < 2) {
499 (void) strcat(line, " ");
500 printf("(remote-file) ");
501 (void) fflush(stdout);
502 (void) gets(&line[strlen(line)]);
503 makeargv();
504 argc = margc;
505 argv = margv;
506 }
507 if (argc < 2) {
508usage:
509 printf("usage: %s remote-file [ local-file ]\n", argv[0]);
510 (void) fflush(stdout);
511 code = -1;
512 return (0);
513 }
514 if (argc < 3) {
515 (void) strcat(line, " ");
516 printf("(local-file) ");
517 (void) fflush(stdout);
518 (void) gets(&line[strlen(line)]);
519 makeargv();
520 argc = margc;
521 argv = margv;
522 }
523 if (argc < 3)
524 goto usage;
525 oldargv1 = argv[1];
526 oldargv2 = argv[2];
527 if (!globulize(&argv[2])) {
528 code = -1;
529 return (0);
530 }
531 if (loc && mcase) {
532 const char *tp = argv[1];
533 char *tp2, tmpbuf[MAXPATHLEN];
534
535 while (*tp && !islower(*tp)) {
536 tp++;
537 }
538 if (!*tp) {
539 tp = argv[2];
540 tp2 = tmpbuf;
541 while ((*tp2 = *tp)) {
542 if (isupper(*tp2)) {
543 *tp2 = 'a' + *tp2 - 'A';
544 }
545 tp++;
546 tp2++;
547 }
548 argv[2] = tmpbuf;
549 }
550 }
551 if (loc && ntflag)
552 argv[2] = dotrans(argv[2]);
553 if (loc && mapflag)
554 argv[2] = domap(argv[2]);
555 if (restartit) {
556 struct stat stbuf;
557 int ret;
558
559 ret = stat(argv[2], &stbuf);
560 if (restartit == 1) {
561 if (ret < 0) {
562 perror(argv[2]);
563 return (0);
564 }
565 restart_point = stbuf.st_size;
566 } else {
567 if (ret == 0) {
568 int overbose;
569
570 overbose = verbose;
571 if (debug == 0)
572 verbose = -1;
573 if (command("MDTM %s", argv[1]) == COMPLETE) {
574 int yy, mo, day, hour, min, sec;
575 struct tm *tm;
576 verbose = overbose;
578 "%*s %04d%02d%02d%02d%02d%02d",
579 &yy, &mo, &day, &hour, &min, &sec);
580 tm = gmtime(&stbuf.st_mtime);
581 tm->tm_mon++;
582 if (tm->tm_year > yy%100)
583 return (1);
584 else if (tm->tm_year == yy%100) {
585 if (tm->tm_mon > mo)
586 return (1);
587 } else if (tm->tm_mon == mo) {
588 if (tm->tm_mday > day)
589 return (1);
590 } else if (tm->tm_mday == day) {
591 if (tm->tm_hour > hour)
592 return (1);
593 } else if (tm->tm_hour == hour) {
594 if (tm->tm_min > min)
595 return (1);
596 } else if (tm->tm_min == min) {
597 if (tm->tm_sec > sec)
598 return (1);
599 }
600 } else {
601 printf("%s\n", reply_string);
602 (void) fflush(stdout);
603 verbose = overbose;
604 return (0);
605 }
606 }
607 }
608 }
609
610 recvrequest("RETR", argv[2], argv[1], mode,
611 argv[1] != oldargv1 || argv[2] != oldargv2);
612 restart_point = 0;
613 return (0);
614}
#define islower(c)
Definition: acclib.h:72
#define isupper(c)
Definition: acclib.h:71
#define stat
Definition: acwin.h:99
#define COMPLETE
Definition: main.h:131
char reply_string[]
Definition: ftp.c:309
int globulize(const char **cpp)
Definition: cmds.c:1663
const char * dotrans(const char *name)
Definition: cmds.c:1838
const char * domap(const char *name)
Definition: cmds.c:1914
void recvrequest(const char *cmd, const char *local, const char *remote, const char *mode, int printnames)
Definition: ftp.c:717
static DOUBLE day(DOUBLE time)
Definition: date.c:117
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2996
int mcase
Definition: main.c:72
int mapflag
Definition: main.c:74
int ntflag
Definition: main.c:73
#define MAXPATHLEN
Definition: ftp_var.h:35
GLenum mode
Definition: glext.h:6217
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
#define min(a, b)
Definition: monoChain.cc:55
_CRTIMP struct tm *__cdecl gmtime(const time_t *_Time)
Definition: time.h:415
Definition: stat.h:55
Definition: time.h:68
int tm_mon
Definition: time.h:73
int tm_year
Definition: time.h:74
int tm_hour
Definition: time.h:71
int tm_sec
Definition: time.h:69
int tm_mday
Definition: time.h:72
int tm_min
Definition: time.h:70
int ret

Referenced by get(), newer(), and reget().

◆ getpass()

char * getpass ( const char prompt)

Definition at line 231 of file fake.c.

232{
233 static char input[256];
234 HANDLE in;
235 HANDLE err;
236 DWORD count;
237
240
242 return NULL;
243
244 if (WriteFile (err, prompt, strlen (prompt), &count, NULL))
245 {
246 int istty = (GetFileType (in) == FILE_TYPE_CHAR);
247 DWORD old_flags;
248 int rc;
249
250 if (istty)
251 {
252 if (GetConsoleMode (in, &old_flags))
254 else
255 istty = 0;
256 }
257 /* Need to read line one byte at time to avoid blocking, if not a
258 tty, so always do it this way. */
259 count = 0;
260 while (1)
261 {
262 DWORD dummy;
263 char one_char;
264
265 rc = ReadFile (in, &one_char, 1, &dummy, NULL);
266 if (rc == 0)
267 break;
268 if (one_char == '\r')
269 {
270 /* CR is always followed by LF if reading from tty. */
271 if (istty)
272 continue;
273 else
274 break;
275 }
276 if (one_char == '\n')
277 break;
278 /* Silently truncate password string if overly long. */
279 if (count < sizeof (input) - 1)
280 input[count++] = one_char;
281 }
282 input[count] = '\0';
283
284 WriteFile (err, "\r\n", 2, &count, NULL);
285 if (istty)
286 SetConsoleMode (in, old_flags);
287 if (rc)
288 return input;
289 }
290
291 return NULL;
292}
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:203
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
BOOL WINAPI GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode)
Definition: console.c:1569
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode)
Definition: console.c:1606
DWORD WINAPI GetFileType(HANDLE hFile)
Definition: fileinfo.c:269
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint in
Definition: glext.h:9616
GLenum GLenum GLenum input
Definition: glext.h:9031
#define err(...)
#define STD_INPUT_HANDLE
Definition: winbase.h:267
#define STD_ERROR_HANDLE
Definition: winbase.h:269
#define FILE_TYPE_CHAR
Definition: winbase.h:260
#define ENABLE_LINE_INPUT
Definition: wincon.h:79
#define ENABLE_PROCESSED_INPUT
Definition: wincon.h:78

Referenced by account(), GetPass(), login(), and user().

◆ getreply()

int getreply ( int  expecteof)

Definition at line 314 of file ftp.c.

316{
317 register int c, n;
318 register int dig;
319 register char *cp;
320 int originalcode = 0, continuation = 0;
321 void (*oldintr)(int);
322 int pflag = 0;
323 char *pt = pasv;
324
325 oldintr = signal(SIGINT,cmdabort);
326 for (;;) {
327 dig = n = code = 0;
329 while ((c = fgetcSocket(cin)) != '\n') {
330 if (c == IAC) { /* handle telnet commands */
331 switch (fgetcSocket(cin)) {
332 case WILL:
333 case WONT:
334 c = fgetcSocket(cin);
335 fprintfSocket(cout, "%c%c%c",IAC,DONT,c);
336 break;
337 case DO:
338 case DONT:
339 c = fgetcSocket(cin);
340 fprintfSocket(cout, "%c%c%c",IAC,WONT,c);
341 break;
342 default:
343 break;
344 }
345 continue;
346 }
347 dig++;
348 if (c == EOF) {
349 if (expecteof) {
350// (void) signal(SIGINT,oldintr);
351 code = 221;
352 return (0);
353 }
354 lostpeer();
355 if (verbose) {
356 printf("421 Service not available, remote server has closed connection\n");
357 (void) fflush(stdout);
358 }
359 code = 421;
360 return(4);
361 }
362 if (c != '\r' && (verbose > 0 ||
363 (verbose > -1 && n == '5' && dig > 4))) {
364 if (proxflag &&
365 ((dig == 1 || dig == 5) && verbose == 0))
366 printf("%s:",hostname);
367 (void) putchar(c);
368 (void) fflush(stdout);
369 }
370 if (dig < 4 && isdigit(c))
371 code = code * 10 + (c - '0');
372 if (!pflag && code == 227)
373 pflag = 1;
374 if (dig > 4 && pflag == 1 && isdigit(c))
375 pflag = 2;
376 if (pflag == 2) {
377 if (c != '\r' && c != ')')
378 *pt++ = c;
379 else {
380 *pt = '\0';
381 pflag = 3;
382 }
383 }
384 if (dig == 4 && c == '-') {
385 if (continuation)
386 code = 0;
387 continuation++;
388 }
389 if (n == 0)
390 n = c;
391 if (cp < &reply_string[sizeof(reply_string) - 1])
392 *cp++ = c;
393 }
394 if (verbose > 0 || (verbose > -1 && n == '5')) {
395 (void) putchar(c);
396 (void) fflush (stdout);
397 }
398 if (continuation && code != originalcode) {
399 if (originalcode == 0)
400 originalcode = code;
401 continue;
402 }
403 *cp = '\0';
404 if (n != '1')
405 cpend = 0;
406 (void) signal(SIGINT,oldintr);
407 if (code == 421 || originalcode == 421)
408 lostpeer();
409 if (abrtflag && oldintr != cmdabort && oldintr != SIG_IGN)
410 (*oldintr)(SIGINT);
411 return (n - '0');
412 }
413}
sig_t lostpeer()
Definition: main.c:263
SOCKET cin
Definition: ftp.c:83
char * hostname
Definition: ftp.c:88
char reply_string[BUFSIZ]
Definition: ftp.c:309
#define pt(x, y)
Definition: drawing.c:79
int fgetcSocket(int s)
Definition: fake.c:89
char pasv[64]
Definition: main.c:77
#define WONT
Definition: ftp_var.h:16
#define WILL
Definition: ftp_var.h:17
#define DO
Definition: ftp_var.h:15
#define DONT
Definition: ftp_var.h:14
#define IAC
Definition: ftp_var.h:13
GLdouble n
Definition: glext.h:7729
POINT cp
Definition: magnifier.c:59

Referenced by command(), hookup(), proxtrans(), quote(), recvrequest(), reset(), sendrequest(), and site().

◆ glob()

char ** glob ( const char s)

Definition at line 36 of file fake.c.

37{
38 return NULL;
39}

Referenced by EnumColorProfilesA(), EnumColorProfilesW(), extract_one(), fill_datafile(), fill_directory(), globulize(), have_profile(), and mput().

◆ globulize()

int globulize ( const char **  cpp)

Definition at line 1663 of file cmds.c.

1664{
1665 char **globbed;
1666
1667 if (!doglob)
1668 return (1);
1669 globbed = glob(*cpp);
1670 if (globerr != NULL) {
1671 printf("%s: %s\n", *cpp, globerr);
1672 (void) fflush(stdout);
1673 if (globbed) {
1674 blkfree(globbed);
1675 free((char *)globbed);
1676 }
1677 return (0);
1678 }
1679 if (globbed) {
1680 *cpp = *globbed++;
1681 /* don't waste too much memory */
1682 if (*globbed) {
1683 blkfree(globbed);
1684 free((char *)globbed);
1685 }
1686 }
1687 return (1);
1688}
char * globerr
Definition: main.c:48
void blkfree(char **av0)
Definition: fake.c:28
char ** glob(const char *v)
Definition: fake.c:36
int doglob
Definition: main.c:66

Referenced by getit(), lcd(), ls(), mls(), and put().

◆ help()

void help ( int  argc,
const char argv[] 
)

Definition at line 535 of file main.c.

536{
537 extern struct cmd cmdtab[];
538 struct cmd *c;
539
540 if (argc == 1) {
541 register int i, j, w, k;
542 int columns, width = 0, lines;
543 extern int NCMDS;
544
545 printf("Commands may be abbreviated. Commands are:\n\n");
546 for (c = cmdtab; c < &cmdtab[NCMDS]; c++) {
547 int len = strlen(c->c_name);
548
549 if (len > width)
550 width = len;
551 }
552 width = (width + 8) &~ 7;
553 columns = 80 / width;
554 if (columns == 0)
555 columns = 1;
556 lines = (NCMDS + columns - 1) / columns;
557 for (i = 0; i < lines; i++) {
558 for (j = 0; j < columns; j++) {
559 c = cmdtab + j * lines + i;
560 if (c->c_name && (!proxy || c->c_proxy)) {
561 printf("%s", c->c_name);
562 }
563 else if (c->c_name) {
564 for (k=0; k < (int) strlen(c->c_name); k++) {
565 (void) putchar(' ');
566 }
567 }
568 if (c + lines >= &cmdtab[NCMDS]) {
569 printf("\n");
570 break;
571 }
572 w = strlen(c->c_name);
573 while (w < width) {
574 w = (w + 8) &~ 7;
575 (void) putchar('\t');
576 }
577 }
578 }
579 (void) fflush(stdout);
580 return;
581 }
582 while (--argc > 0) {
583 const char *arg;
584 arg = *++argv;
585 c = getcmd(arg);
586 if (c == (struct cmd *)-1)
587 printf("?Ambiguous help command %s\n", arg);
588 else if (c == (struct cmd *)0)
589 printf("?Invalid help command %s\n", arg);
590 else
591 printf("%-*s\t%s\n", (int)HELPINDENT,
592 c->c_name, c->c_help);
593 }
594 (void) fflush(stdout);
595}
int proxy
Definition: main.c:67
#define HELPINDENT
Definition: main.c:529
int NCMDS
Definition: cmdtab.c:171
GLint GLint GLsizei width
Definition: gl.h:1546
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
int k
Definition: mpi.c:3369
eMaj lines
Definition: tritemp.h:206
void * arg
Definition: msvc.h:10

◆ herror()

int herror ( char s)

Definition at line 46 of file fake.c.

47{
48 return 0;
49}

Referenced by hookup().

◆ hookup()

char * hookup ( const char host,
int  port 
)

Definition at line 96 of file ftp.c.

97{
98 register struct hostent *hp = 0;
99 int len;
100 SOCKET s;
101 static char hostnamebuf[80];
102
103 bzero((char *)&hisctladdr, sizeof (hisctladdr));
104 hisctladdr.sin_addr.s_addr = inet_addr(host);
105 if (hisctladdr.sin_addr.s_addr != (unsigned long)-1) {
106 hisctladdr.sin_family = AF_INET;
107 (void) strncpy(hostnamebuf, host, sizeof(hostnamebuf));
108 } else {
109 hp = gethostbyname(host);
110 if (hp == NULL) {
111 fprintf(stderr, "ftp: %s: ", host);
112 herror((char *)NULL);
113 code = -1;
114 return((char *) 0);
115 }
116 hisctladdr.sin_family = hp->h_addrtype;
117 bcopy(hp->h_addr_list[0],
118 (caddr_t)&hisctladdr.sin_addr, hp->h_length);
119 (void) strncpy(hostnamebuf, hp->h_name, sizeof(hostnamebuf));
120 }
121 hostname = hostnamebuf;
122 s = socket(hisctladdr.sin_family, SOCK_STREAM, 0);
123 if (s == INVALID_SOCKET) {
124 perror("ftp: socket");
125 code = -1;
126 return (0);
127 }
128 hisctladdr.sin_port = port;
129 while (connect(s, (struct sockaddr *)&hisctladdr, sizeof (hisctladdr)) < 0) {
130 if (hp && hp->h_addr_list[1]) {
131 int oerrno = errno;
132
133 fprintf(stderr, "ftp: connect to address %s: ",
134 inet_ntoa(hisctladdr.sin_addr));
135 errno = oerrno;
136 perror((char *) 0);
137 hp->h_addr_list++;
138 bcopy(hp->h_addr_list[0],
139 (caddr_t)&hisctladdr.sin_addr, hp->h_length);
140 fprintf(stdout, "Trying %s...\n",
141 inet_ntoa(hisctladdr.sin_addr));
142 (void) fflush(stdout);
143 (void) close(s);
144 s = socket(hisctladdr.sin_family, SOCK_STREAM, 0);
145 if (s == INVALID_SOCKET) {
146 perror("ftp: socket");
147 code = -1;
148 return (0);
149 }
150 continue;
151 }
152 perror("ftp: connect");
153 code = -1;
154 goto bad;
155 }
156 len = sizeof (myctladdr);
157 if (getsockname(s, (struct sockaddr *)&myctladdr, &len) < 0) {
158 perror("ftp: getsockname");
159 code = -1;
160 goto bad;
161 }
162 cin = cout = s;
163 if (verbose) {
164 printf("Connected to %s.\n", hostname);
165 (void) fflush(stdout);
166 }
167 if (getreply(0) > 2) { /* read startup message from server */
169 code = -1;
170 goto bad;
171 }
172#ifdef SO_OOBINLINE
173 {
174 int on = 1;
175
176 if (setsockopt(s, SOL_SOCKET, SO_OOBINLINE, (const char *) &on, sizeof(on))
177 < 0 && debug) {
178 perror("ftp: setsockopt");
179 }
180 }
181#endif //SO_OOBINLINE
182
183 return (hostname);
184bad:
185 (void) close(s);
186 return ((char *)0);
187}
#define close
Definition: acwin.h:98
#define bcopy(s1, s2, n)
Definition: various.h:25
#define bzero(s, n)
Definition: various.h:27
struct sockaddr_in hisctladdr
Definition: ftp.c:68
struct sockaddr_in myctladdr
Definition: ftp.c:74
USHORT port
Definition: uri.c:228
#define SOCK_STREAM
Definition: tcpip.h:118
#define AF_INET
Definition: tcpip.h:117
int herror(char *string)
Definition: fake.c:46
PHOSTENT WSAAPI gethostbyname(IN const char FAR *name)
Definition: getxbyxx.c:221
#define stderr
Definition: stdio.h:100
#define inet_addr(cp)
Definition: inet.h:98
#define inet_ntoa(addr)
Definition: inet.h:100
#define closesocket
Definition: ncftp.h:477
char * caddr_t
Definition: rosdhcp.h:36
#define errno
Definition: errno.h:18
INT WSAAPI getsockname(IN SOCKET s, OUT LPSOCKADDR name, IN OUT INT FAR *namelen)
Definition: sockctrl.c:213
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
Definition: sockctrl.c:421
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
char * h_name
Definition: winsock.h:134
short h_length
Definition: winsock.h:137
short h_addrtype
Definition: winsock.h:136
char ** h_addr_list
Definition: winsock.h:138
char * host
Definition: whois.c:55
#define SO_OOBINLINE
Definition: winsock.h:186
#define INVALID_SOCKET
Definition: winsock.h:332
#define SOL_SOCKET
Definition: winsock.h:398

Referenced by setpeer().

◆ idle()

void idle ( int  argc,
const char argv[] 
)

Definition at line 1581 of file cmds.c.

1582{
1583 int oldverbose = verbose;
1584
1585 verbose = 1;
1586 (void) command(argc == 1 ? "SITE IDLE" : "SITE IDLE %s", argv[1]);
1587 verbose = oldverbose;
1588}

◆ initconn()

int initconn ( void  )

Definition at line 1125 of file ftp.c.

1126{
1127 register char *p, *a;
1128 int result, len, tmpno = 0;
1129 int on = 1;
1130 int a0, a1, a2, a3, p0, p1;
1131
1132
1133 if (passivemode) {
1135 if (data < 0) {
1136 perror("ftp: socket");
1137 return(1);
1138 }
1139 if ((options & SO_DEBUG) &&
1140 setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on,
1141 sizeof (on)) < 0)
1142 perror("ftp: setsockopt (ignored)");
1143 if (command("PASV") != COMPLETE) {
1144 printf("Passive mode refused.\n");
1145 goto bad;
1146 }
1147
1148 /*
1149 * What we've got at this point is a string of comma
1150 * separated one-byte unsigned integer values.
1151 * The first four are the an IP address. The fifth is
1152 * the MSB of the port number, the sixth is the LSB.
1153 * From that we'll prepare a sockaddr_in.
1154 */
1155
1156 if (sscanf(pasv,"%d,%d,%d,%d,%d,%d",
1157 &a0, &a1, &a2, &a3, &p0, &p1) != 6) {
1158 printf("Passive mode address scan failure. Shouldn't happen!\n");
1159 goto bad;
1160 }
1161
1162 bzero(&data_addr, sizeof(data_addr));
1163 data_addr.sin_family = AF_INET;
1164 a = (char *)&data_addr.sin_addr.s_addr;
1165 a[0] = a0 & 0xff;
1166 a[1] = a1 & 0xff;
1167 a[2] = a2 & 0xff;
1168 a[3] = a3 & 0xff;
1169 p = (char *)&data_addr.sin_port;
1170 p[0] = p0 & 0xff;
1171 p[1] = p1 & 0xff;
1172
1173 if (connect(data, (struct sockaddr *)&data_addr,
1174 sizeof(data_addr)) < 0) {
1175 perror("ftp: connect");
1176 goto bad;
1177 }
1178 return(0);
1179 }
1180
1181
1182noport:
1184 if (sendport)
1185 data_addr.sin_port = 0; /* let system pick one */
1186 if (data != -1)
1187 (void) close (data);
1189 if (data < 0) {
1190 perror("ftp: socket");
1191 if (tmpno)
1192 sendport = 1;
1193 return (1);
1194 }
1195 if (!sendport)
1196 if (setsockopt(data, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof (on)) < 0) {
1197 perror("ftp: setsockopt (reuse address)");
1198 goto bad;
1199 }
1200 if (bind(data, (struct sockaddr *)&data_addr, sizeof (data_addr)) < 0) {
1201 perror("ftp: bind");
1202 goto bad;
1203 }
1204 if (options & SO_DEBUG &&
1205 setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on, sizeof (on)) < 0)
1206 perror("ftp: setsockopt (ignored)");
1207 len = sizeof (data_addr);
1208 if (getsockname(data, (struct sockaddr *)&data_addr, &len) < 0) {
1209 perror("ftp: getsockname");
1210 goto bad;
1211 }
1212 if (listen(data, 1) < 0)
1213 perror("ftp: listen");
1214 if (sendport) {
1215 a = (char *)&data_addr.sin_addr;
1216 p = (char *)&data_addr.sin_port;
1217#define UC(b) (((int)b)&0xff)
1218 result =
1219 command("PORT %d,%d,%d,%d,%d,%d",
1220 UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]),
1221 UC(p[0]), UC(p[1]));
1222 if (result == ERROR && sendport == -1) {
1223 sendport = 0;
1224 tmpno = 1;
1225 goto noport;
1226 }
1227 return (result != COMPLETE);
1228 }
1229 if (tmpno)
1230 sendport = 1;
1231 return (0);
1232bad:
1233 (void) fflush(stdout);
1234 (void) close(data), data = -1;
1235 if (tmpno)
1236 sendport = 1;
1237 return (1);
1238}
#define UC(b)
struct sockaddr_in data_addr
Definition: ftp.c:69
int passivemode
Definition: main.c:68
int sendport
Definition: main.c:117
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
GLuint64EXT * result
Definition: glext.h:11304
#define a
Definition: ke_i.h:78
static const struct update_accum a1
Definition: msg.c:578
static const struct update_accum a2
Definition: msg.c:586
static const struct update_accum a3
Definition: msg.c:600
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
Definition: sockctrl.c:123
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: socklife.c:36
#define SO_REUSEADDR
Definition: winsock.h:180
#define SO_DEBUG
Definition: winsock.h:178

Referenced by recvrequest(), and sendrequest().

◆ lcd()

void lcd ( int  argc,
const char argv[] 
)

Definition at line 996 of file cmds.c.

997{
998 char buf[MAXPATHLEN];
999
1000 if (argc < 2)
1001 argc++, argv[1] = home;
1002 if (argc != 2) {
1003 printf("usage:%s local-directory\n", argv[0]);
1004 (void) fflush(stdout);
1005 code = -1;
1006 return;
1007 }
1008 if (!globulize(&argv[1])) {
1009 code = -1;
1010 return;
1011 }
1012 if (chdir(argv[1]) < 0) {
1013 perror(argv[1]);
1014 code = -1;
1015 return;
1016 }
1017 printf("Local directory now %s\n", getcwd(buf,sizeof(buf)));
1018 (void) fflush(stdout);
1019 code = 0;
1020}
char home[]
Definition: main.c:47
_Check_return_ _Ret_opt_z_ _CRTIMP char *__cdecl getcwd(_Out_writes_opt_(_SizeInBytes) char *_DstBuf, _In_ int _SizeInBytes)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define chdir
Definition: syshdrs.h:69

◆ login()

int login ( const char host)

Definition at line 189 of file ftp.c.

190{
191 char tmp[80];
192 char *puser, *ppass, *pacct;
193 const char *user, *pass, *acct;
194 int n, aflag = 0;
195
196 user = pass = acct = 0;
197 n = ruserpass(host, &puser, &ppass, &pacct);
198 if (n < 0) {
199 code = -1;
200 return(0);
201 }
202 if (0 != n) {
203 user = puser;
204 pass = ppass;
205 acct = pacct;
206 }
207 while (user == NULL) {
208 const char *myname = "none"; // This needs to become the username env
209
210 if (myname)
211 printf("Name (%s:%s): ", host, myname);
212 else
213 printf("Name (%s): ", host);
214 (void) fflush(stdout);
215 (void) fgets(tmp, sizeof(tmp) - 1, stdin);
216 tmp[strlen(tmp) - 1] = '\0';
217 if (*tmp == '\0')
218 user = myname;
219 else
220 user = tmp;
221 }
222 n = command("USER %s", user);
223 if (n == CONTINUE) {
224 if (pass == NULL)
225 pass = getpass("Password:");
226 n = command("PASS %s", pass);
227 fflush(stdin);
228 }
229 if (n == CONTINUE) {
230 aflag++;
231 acct = getpass("Account:");
232 n = command("ACCT %s", acct);
233 }
234 if (n != COMPLETE) {
235 fprintf(stderr, "Login failed.\n");
236 return (0);
237 }
238 if (!aflag && acct != NULL)
239 (void) command("ACCT %s", acct);
240 if (proxy)
241 return(1);
242 for (n = 0; n < macnum; ++n) {
243 if (!strcmp("init", macros[n].mac_name)) {
244 (void) strcpy(line, "$init");
245 makeargv();
247 break;
248 }
249 }
250 return (1);
251}
void user(int argc, const char *argv[])
Definition: cmds.c:1350
void domacro(int argc, const char *argv[])
Definition: domacro.c:26
#define CONTINUE
Definition: ftp_var.h:43
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
int ruserpass(const char *host, char **aname, char **apass, char **aacct)
Definition: ruserpass.c:58
pass
Definition: typegen.h:25

Referenced by setpeer().

◆ ls()

void ls ( int  argc,
const char argv[] 
)

Definition at line 1136 of file cmds.c.

1137{
1138 const char *cmd;
1139
1140 if (argc < 2)
1141 argc++, argv[1] = NULL;
1142 if (argc < 3)
1143 argc++, argv[2] = "-";
1144 if (argc > 3) {
1145 printf("usage: %s remote-directory local-file\n", argv[0]);
1146 (void) fflush(stdout);
1147 code = -1;
1148 return;
1149 }
1150 cmd = argv[0][0] == 'n' ? "NLST" : "LIST";
1151// cmd = argv[0][0] == 'n' ? "NLST -CF" : "NLST -CF";
1152 if (strcmp(argv[2], "-") && !globulize(&argv[2])) {
1153 code = -1;
1154 return;
1155 }
1156 if (strcmp(argv[2], "-") && *argv[2] != '|')
1157 if (!globulize(&argv[2]) || !confirm("output to local-file:", argv[2])) {
1158 code = -1;
1159 return;
1160 }
1161 recvrequest(cmd, argv[2], argv[1], "w", 0);
1162}
int confirm(const char *cmd, const char *file)
Definition: cmds.c:1636

Referenced by create_file_with_version(), GSUB_apply_LigatureSubst(), init_test(), ME_GetParaLineSpace(), msi_compare_file_versions(), msi_parse_version_string(), test_enumdisplaydevices_adapter(), ZSTD_compress_insertDictionary(), and ZSTD_loadDictionaryContent().

◆ macdef()

void macdef ( int  argc,
const char argv[] 
)

Definition at line 2133 of file cmds.c.

2134{
2135 char *tmp;
2136 int c;
2137
2138 if (macnum == 16) {
2139 printf("Limit of 16 macros have already been defined\n");
2140 (void) fflush(stdout);
2141 code = -1;
2142 return;
2143 }
2144 if (argc < 2) {
2145 (void) strcat(line, " ");
2146 printf("(macro name) ");
2147 (void) fflush(stdout);
2148 (void) gets(&line[strlen(line)]);
2149 makeargv();
2150 argc = margc;
2151 argv = margv;
2152 }
2153 if (argc != 2) {
2154 printf("Usage: %s macro_name\n",argv[0]);
2155 (void) fflush(stdout);
2156 code = -1;
2157 return;
2158 }
2159 if (interactive) {
2160 printf("Enter macro line by line, terminating it with a null line\n");
2161 (void) fflush(stdout);
2162 }
2163 (void) strncpy(macros[macnum].mac_name, argv[1], 8);
2164 if (macnum == 0) {
2165 macros[macnum].mac_start = macbuf;
2166 }
2167 else {
2168 macros[macnum].mac_start = macros[macnum - 1].mac_end + 1;
2169 }
2170 tmp = macros[macnum].mac_start;
2171 while (tmp != macbuf+4096) {
2172 if ((c = getchar()) == EOF) {
2173 printf("macdef:end of file encountered\n");
2174 (void) fflush(stdout);
2175 code = -1;
2176 return;
2177 }
2178 if ((*tmp = c) == '\n') {
2179 if (tmp == macros[macnum].mac_start) {
2180 macros[macnum++].mac_end = tmp;
2181 code = 0;
2182 return;
2183 }
2184 if (*(tmp-1) == '\0') {
2185 macros[macnum++].mac_end = tmp - 1;
2186 code = 0;
2187 return;
2188 }
2189 *tmp = '\0';
2190 }
2191 tmp++;
2192 }
2193 while (1) {
2194 while ((c = getchar()) != '\n' && c != EOF)
2195 /* LOOP */;
2196 if (c == EOF || getchar() == '\n') {
2197 printf("Macro not defined - 4k buffer exceeded\n");
2198 (void) fflush(stdout);
2199 code = -1;
2200 return;
2201 }
2202 }
2203}
char macbuf[4096]
Definition: main.c:110
_Check_return_ _CRTIMP int __cdecl getchar(void)
Definition: file.c:3629

◆ makeargv()

void makeargv ( void  )

Definition at line 393 of file main.c.

394{
395 const char **argp;
396
397 margc = 0;
398 argp = margv;
399 stringbase = line; /* scan from first of buffer */
400 argbase = argbuf; /* store from first of buffer */
401 slrflag = 0;
402 while ((*argp++ = slurpstring()))
403 margc++;
404}
char argbuf[200]
Definition: main.c:99
char line[200]
Definition: main.c:97
char * argbase
Definition: main.c:100
static const char * slurpstring()
Definition: main.c:412
char * stringbase
Definition: main.c:98
int slrflag
Definition: main.c:391

Referenced by cd(), cmdscanner(), delete(), do_chmod(), domacro(), doproxy(), getit(), login(), macdef(), makedir(), mdelete(), mget(), mls(), modtime(), mput(), put(), quote(), removedir(), renamefile(), setnmap(), setpeer(), site(), sizecmd(), and user().

◆ makedir()

void makedir ( int  argc,
const char argv[] 
)

Definition at line 1420 of file cmds.c.

1421{
1422
1423 if (argc < 2) {
1424 (void) strcat(line, " ");
1425 printf("(directory-name) ");
1426 (void) fflush(stdout);
1427 (void) gets(&line[strlen(line)]);
1428 makeargv();
1429 argc = margc;
1430 argv = margv;
1431 }
1432 if (argc < 2) {
1433 printf("usage: %s directory-name\n", argv[0]);
1434 (void) fflush(stdout);
1435 code = -1;
1436 return;
1437 }
1438 if (command("MKD %s", argv[1]) == ERROR && code == 500) {
1439 if (verbose) {
1440 printf("MKD command not recognized, trying XMKD\n");
1441 (void) fflush(stdout);
1442 }
1443 (void) command("XMKD %s", argv[1]);
1444 }
1445}

◆ mdelete()

void mdelete ( int  argc,
const char argv[] 
)

Definition at line 1049 of file cmds.c.

1050{
1051 const char *cp;
1052 int ointer;
1053 extern jmp_buf jabort;
1054
1055 if (argc < 2) {
1056 (void) strcat(line, " ");
1057 printf("(remote-files) ");
1058 (void) fflush(stdout);
1059 (void) gets(&line[strlen(line)]);
1060 makeargv();
1061 argc = margc;
1062 argv = margv;
1063 }
1064 if (argc < 2) {
1065 printf("usage:%s remote-files\n", argv[0]);
1066 (void) fflush(stdout);
1067 code = -1;
1068 return;
1069 }
1070 mname = argv[0];
1071 mflag = 1;
1072// oldintr = signal(SIGINT, mabort);
1073 (void) setjmp(jabort);
1074 while ((cp = remglob(argv,0)) != NULL) {
1075 if (*cp == '\0') {
1076 mflag = 0;
1077 continue;
1078 }
1079 if (mflag && confirm(argv[0], cp)) {
1080 (void) command("DELE %s", cp);
1081 if (!mflag && fromatty) {
1082 ointer = interactive;
1083 interactive = 1;
1084 if (confirm("Continue with", "mdelete")) {
1085 mflag++;
1086 }
1087 interactive = ointer;
1088 }
1089 }
1090 }
1091// (void) signal(SIGINT, oldintr);
1092 mflag = 0;
1093}
jmp_buf jabort
Definition: cmds.c:38
const char * mname
Definition: cmds.c:37
static const char * remglob(const char *argv[], int doswitch)
Definition: cmds.c:715
int mflag
Definition: finger.c:66
int fromatty
Definition: main.c:62

◆ mget()

void mget ( int  argc,
const char argv[] 
)

Definition at line 642 of file cmds.c.

643{
644 const char *cp, *tp;
645 char *tp2, tmpbuf[MAXPATHLEN];
646 int ointer;
647 extern jmp_buf jabort;
648
649 if (argc < 2) {
650 (void) strcat(line, " ");
651 printf("(remote-files) ");
652 (void) fflush(stdout);
653 (void) gets(&line[strlen(line)]);
654 makeargv();
655 argc = margc;
656 argv = margv;
657 }
658 if (argc < 2) {
659 printf("usage:%s remote-files\n", argv[0]);
660 (void) fflush(stdout);
661 code = -1;
662 return;
663 }
664 mname = argv[0];
665 mflag = 1;
666// oldintr = signal(SIGINT,mabort);
667 (void) setjmp(jabort);
668 while ((cp = remglob(argv,proxy)) != NULL) {
669 if (*cp == '\0') {
670 mflag = 0;
671 continue;
672 }
673 if (mflag && confirm(argv[0], cp)) {
674 tp = cp;
675 if (mcase) {
676 while (*tp && !islower(*tp)) {
677 tp++;
678 }
679 if (!*tp) {
680 tp = cp;
681 tp2 = tmpbuf;
682 while ((*tp2 = *tp)) {
683 if (isupper(*tp2)) {
684 *tp2 = 'a' + *tp2 - 'A';
685 }
686 tp++;
687 tp2++;
688 }
689 }
690 tp = tmpbuf;
691 }
692 if (ntflag) {
693 tp = dotrans(tp);
694 }
695 if (mapflag) {
696 tp = domap(tp);
697 }
698 recvrequest("RETR", tp, cp, "w",
699 tp != cp || !interactive);
700 if (!mflag && fromatty) {
701 ointer = interactive;
702 interactive = 1;
703 if (confirm("Continue with","mget")) {
704 mflag++;
705 }
706 interactive = ointer;
707 }
708 }
709 }
710// (void) signal(SIGINT,oldintr);
711 mflag = 0;
712}

◆ mls()

void mls ( int  argc,
const char argv[] 
)

Definition at line 1168 of file cmds.c.

1169{
1170 const char *cmd, *dest;
1171 char mode[1];
1172 int ointer, i;
1173 extern jmp_buf jabort;
1174
1175 if (argc < 2) {
1176 (void) strcat(line, " ");
1177 printf("(remote-files) ");
1178 (void) fflush(stdout);
1179 (void) gets(&line[strlen(line)]);
1180 makeargv();
1181 argc = margc;
1182 argv = margv;
1183 }
1184 if (argc < 3) {
1185 (void) strcat(line, " ");
1186 printf("(local-file) ");
1187 (void) fflush(stdout);
1188 (void) gets(&line[strlen(line)]);
1189 makeargv();
1190 argc = margc;
1191 argv = margv;
1192 }
1193 if (argc < 3) {
1194 printf("usage:%s remote-files local-file\n", argv[0]);
1195 (void) fflush(stdout);
1196 code = -1;
1197 return;
1198 }
1199 dest = argv[argc - 1];
1200 argv[argc - 1] = NULL;
1201 if (strcmp(dest, "-") && *dest != '|')
1202 if (!globulize(&dest) || !confirm("output to local-file:", dest)) {
1203 code = -1;
1204 return;
1205 }
1206 cmd = argv[0][1] == 'l' ? "NLST" : "LIST";
1207 mname = argv[0];
1208 mflag = 1;
1209// oldintr = signal(SIGINT, mabort);
1210 (void) setjmp(jabort);
1211 for (i = 1; mflag && i < argc-1; ++i) {
1212 *mode = (i == 1) ? 'w' : 'a';
1213 recvrequest(cmd, dest, argv[i], mode, 0);
1214 if (!mflag && fromatty) {
1215 ointer = interactive;
1216 interactive = 1;
1217 if (confirm("Continue with", argv[0])) {
1218 mflag ++;
1219 }
1220 interactive = ointer;
1221 }
1222 }
1223// (void) signal(SIGINT, oldintr);
1224 mflag = 0;
1225}
static char * dest
Definition: rtl.c:135

Referenced by ZSTD_BtFindBestMatch(), ZSTD_compressBlock_doubleFast(), ZSTD_compressBlock_doubleFast_dictMatchState(), ZSTD_compressBlock_doubleFast_extDict(), ZSTD_compressBlock_doubleFast_extDict_generic(), ZSTD_compressBlock_doubleFast_generic(), ZSTD_compressBlock_fast(), ZSTD_compressBlock_fast_dictMatchState(), ZSTD_compressBlock_fast_dictMatchState_generic(), ZSTD_compressBlock_fast_extDict(), ZSTD_compressBlock_fast_extDict_generic(), ZSTD_compressBlock_fast_generic(), ZSTD_DUBT_findBestMatch(), ZSTD_DUBT_findBetterDictMatch(), ZSTD_fillDoubleHashTable(), ZSTD_fillHashTable(), ZSTD_HcFindBestMatch_generic(), ZSTD_insertAndFindFirstIndex_internal(), ZSTD_insertBt1(), ZSTD_insertBtAndGetAllMatches(), ZSTD_updateDUBT(), and ZSTD_updateTree_internal().

◆ modtime()

void modtime ( int  argc,
const char argv[] 
)

Definition at line 2232 of file cmds.c.

2233{
2234 int overbose;
2235
2236 if (argc < 2) {
2237 (void) strcat(line, " ");
2238 printf("(filename) ");
2239 (void) fflush(stdout);
2240 (void) gets(&line[strlen(line)]);
2241 makeargv();
2242 argc = margc;
2243 argv = margv;
2244 }
2245 if (argc < 2) {
2246 printf("usage:%s filename\n", argv[0]);
2247 (void) fflush(stdout);
2248 code = -1;
2249 return;
2250 }
2251 overbose = verbose;
2252 if (debug == 0)
2253 verbose = -1;
2254 if (command("MDTM %s", argv[1]) == COMPLETE) {
2255 int yy, mo, day, hour, min, sec;
2256 sscanf(reply_string, "%*s %04d%02d%02d%02d%02d%02d", &yy, &mo,
2257 &day, &hour, &min, &sec);
2258 /* might want to print this in local time */
2259 printf("%s\t%02d/%02d/%04d %02d:%02d:%02d GMT\n", argv[1],
2260 mo, day, yy, hour, min, sec);
2261 } else
2262 printf("%s\n", reply_string);
2263 verbose = overbose;
2264 (void) fflush(stdout);
2265}

Referenced by MSVCRT__wfinddata64_t::DECLSPEC_ALIGN(), and FTPUtime().

◆ mput()

void mput ( int  argc,
const char argv[] 
)

Definition at line 344 of file cmds.c.

345{
346 register int i;
347 int ointer;
348 extern jmp_buf jabort;
349 const char *tp;
350
351 if (argc < 2) {
352 (void) strcat(line, " ");
353 printf("(local-files) ");
354 (void) fflush(stdout);
355 (void) gets(&line[strlen(line)]);
356 makeargv();
357 argc = margc;
358 argv = margv;
359 }
360 if (argc < 2) {
361 printf("usage:%s local-files\n", argv[0]);
362 (void) fflush(stdout);
363 code = -1;
364 return;
365 }
366 mname = argv[0];
367 mflag = 1;
368// oldintr = signal(SIGINT, mabort);
369 (void) setjmp(jabort);
370 if (proxy) {
371 const char *cp;
372 char *tp2, tmpbuf[MAXPATHLEN];
373
374 while ((cp = remglob(argv,0)) != NULL) {
375 if (*cp == 0) {
376 mflag = 0;
377 continue;
378 }
379 if (mflag && confirm(argv[0], cp)) {
380 tp = cp;
381 if (mcase) {
382 while (*tp && !islower(*tp)) {
383 tp++;
384 }
385 if (!*tp) {
386 tp = cp;
387 tp2 = tmpbuf;
388 while ((*tp2 = *tp)) {
389 if (isupper(*tp2)) {
390 *tp2 = 'a' + *tp2 - 'A';
391 }
392 tp++;
393 tp2++;
394 }
395 }
396 tp = tmpbuf;
397 }
398 if (ntflag) {
399 tp = dotrans(tp);
400 }
401 if (mapflag) {
402 tp = domap(tp);
403 }
404 sendrequest((sunique) ? "STOU" : "STOR",
405 cp, tp, cp != tp || !interactive);
406 if (!mflag && fromatty) {
407 ointer = interactive;
408 interactive = 1;
409 if (confirm("Continue with","mput")) {
410 mflag++;
411 }
412 interactive = ointer;
413 }
414 }
415 }
416// (void) signal(SIGINT, oldintr);
417 mflag = 0;
418 return;
419 }
420 for (i = 1; i < argc; i++) {
421 register char **cpp, **gargs;
422
423 if (!doglob) {
424 if (mflag && confirm(argv[0], argv[i])) {
425 tp = (ntflag) ? dotrans(argv[i]) : argv[i];
426 tp = (mapflag) ? domap(tp) : tp;
427 sendrequest((sunique) ? "STOU" : "STOR",
428 argv[i], tp, tp != argv[i] || !interactive);
429 if (!mflag && fromatty) {
430 ointer = interactive;
431 interactive = 1;
432 if (confirm("Continue with","mput")) {
433 mflag++;
434 }
435 interactive = ointer;
436 }
437 }
438 continue;
439 }
440 gargs = glob(argv[i]);
441 if (globerr != NULL) {
442 printf("%s\n", globerr);
443 (void) fflush(stdout);
444 if (gargs) {
445 blkfree(gargs);
446 free((char *)gargs);
447 }
448 continue;
449 }
450 for (cpp = gargs; cpp && *cpp != NULL; cpp++) {
451 if (mflag && confirm(argv[0], *cpp)) {
452 tp = (ntflag) ? dotrans(*cpp) : *cpp;
453 tp = (mapflag) ? domap(tp) : tp;
454 sendrequest((sunique) ? "STOU" : "STOR",
455 *cpp, tp, *cpp != tp || !interactive);
456 if (!mflag && fromatty) {
457 ointer = interactive;
458 interactive = 1;
459 if (confirm("Continue with","mput")) {
460 mflag++;
461 }
462 interactive = ointer;
463 }
464 }
465 }
466 if (gargs != NULL) {
467 blkfree(gargs);
468 free((char *)gargs);
469 }
470 }
471// (void) signal(SIGINT, oldintr);
472 mflag = 0;
473}
void sendrequest(const char *cmd, const char *local, const char *remote, int printnames)
Definition: ftp.c:443
int sunique
Definition: main.c:70

◆ newer()

void newer ( int  argc,
const char argv[] 
)

Definition at line 2278 of file cmds.c.

2279{
2280 if (getit(argc, argv, -1, "w")) {
2281 printf("Local file \"%s\" is newer than remote file \"%s\"\n",
2282 argv[1], argv[2]);
2283 (void) fflush(stdout);
2284 }
2285}

Referenced by CertAddCRLContextToStore(), and CertAddCTLContextToStore().

◆ null()

◆ proxtrans()

void proxtrans ( const char cmd,
const char local,
const char remote 
)

◆ pswitch()

void pswitch ( int  flag)

Definition at line 1310 of file ftp.c.

1311{
1312 extern int proxy, abrtflag;
1313 Sig_t oldintr;
1314 static struct comvars {
1315 int connect;
1316 char name[MAXHOSTNAMELEN];
1317 struct sockaddr_in mctl;
1318 struct sockaddr_in hctl;
1319 SOCKET in;
1320 SOCKET out;
1321 int tpe;
1322 int cpnd;
1323 int sunqe;
1324 int runqe;
1325 int mcse;
1326 int ntflg;
1327 char nti[17];
1328 char nto[17];
1329 int mapflg;
1330 char mi[MAXPATHLEN];
1331 char mo[MAXPATHLEN];
1332 } proxstruct, tmpstruct;
1333 struct comvars *ip, *op;
1334
1335 abrtflag = 0;
1336 oldintr = signal(SIGINT, psabort);
1337 if (flag) {
1338 if (proxy)
1339 return;
1340 ip = &tmpstruct;
1341 op = &proxstruct;
1342 proxy++;
1343 }
1344 else {
1345 if (!proxy)
1346 return;
1347 ip = &proxstruct;
1348 op = &tmpstruct;
1349 proxy = 0;
1350 }
1351 ip->connect = connected;
1352 connected = op->connect;
1353 if (hostname) {
1354 (void) strncpy(ip->name, hostname, sizeof(ip->name) - 1);
1355 ip->name[strlen(ip->name)] = '\0';
1356 } else
1357 ip->name[0] = 0;
1358 hostname = op->name;
1359 ip->hctl = hisctladdr;
1360 hisctladdr = op->hctl;
1361 ip->mctl = myctladdr;
1362 myctladdr = op->mctl;
1363 ip->in = cin;
1364 cin = op->in;
1365 ip->out = cout;
1366 cout = op->out;
1367 ip->tpe = type;
1368 type = op->tpe;
1369 if (!type)
1370 type = 1;
1371 ip->cpnd = cpend;
1372 cpend = op->cpnd;
1373 ip->sunqe = sunique;
1374 sunique = op->sunqe;
1375 ip->runqe = runique;
1376 runique = op->runqe;
1377 ip->mcse = mcase;
1378 mcase = op->mcse;
1379 ip->ntflg = ntflag;
1380 ntflag = op->ntflg;
1381 (void) strncpy(ip->nti, ntin, 16);
1382 (ip->nti)[strlen(ip->nti)] = '\0';
1383 (void) strcpy(ntin, op->nti);
1384 (void) strncpy(ip->nto, ntout, 16);
1385 (ip->nto)[strlen(ip->nto)] = '\0';
1386 (void) strcpy(ntout, op->nto);
1387 ip->mapflg = mapflag;
1388 mapflag = op->mapflg;
1389 (void) strncpy(ip->mi, mapin, MAXPATHLEN - 1);
1390 (ip->mi)[strlen(ip->mi)] = '\0';
1391 (void) strcpy(mapin, op->mi);
1392 (void) strncpy(ip->mo, mapout, MAXPATHLEN - 1);
1393 (ip->mo)[strlen(ip->mo)] = '\0';
1394 (void) strcpy(mapout, op->mo);
1395// (void) signal(SIGINT, oldintr);
1396 if (abrtflag) {
1397 abrtflag = 0;
1398 (*oldintr)(1);
1399 }
1400}
void psabort(int sig)
Definition: ftp.c:1303
#define MAXHOSTNAMELEN
Definition: ftp.c:31
void(* Sig_t)(int)
Definition: ftp.c:90
UINT op
Definition: effect.c:236
char mapin[MAXPATHLEN]
Definition: main.c:82
char ntin[17]
Definition: main.c:79
char ntout[17]
Definition: main.c:80
int runique
Definition: main.c:71
char mapout[MAXPATHLEN]
Definition: main.c:83
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
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
Definition: glfuncs.h:52
static FILE * out
Definition: regtests2xml.c:44
Definition: dhcpd.h:62
static MONITORINFO mi
Definition: win.c:7338

Referenced by doproxy(), lostpeer(), proxtrans(), quit(), remglob(), and status().

◆ ptransfer()

void ptransfer ( const char direction,
long  bytes,
struct timeval t0,
struct timeval t1 
)

◆ put()

void put ( int  argc,
const char argv[] 
)

Definition at line 279 of file cmds.c.

280{
281 const char *cmd;
282 int loc = 0;
283 const char *oldargv1, *oldargv2;
284
285 if (argc == 2) {
286 argc++;
287 argv[2] = argv[1];
288 loc++;
289 }
290 if (argc < 2) {
291 (void) strcat(line, " ");
292 printf("(local-file) ");
293 (void) fflush(stdout);
294 (void) gets(&line[strlen(line)]);
295 makeargv();
296 argc = margc;
297 argv = margv;
298 }
299 if (argc < 2) {
300usage:
301 printf("usage:%s local-file remote-file\n", argv[0]);
302 (void) fflush(stdout);
303 code = -1;
304 return;
305 }
306 if (argc < 3) {
307 (void) strcat(line, " ");
308 printf("(remote-file) ");
309 (void) fflush(stdout);
310 (void) gets(&line[strlen(line)]);
311 makeargv();
312 argc = margc;
313 argv = margv;
314 }
315 if (argc < 3)
316 goto usage;
317 oldargv1 = argv[1];
318 oldargv2 = argv[2];
319 if (!globulize(&argv[1])) {
320 code = -1;
321 return;
322 }
323 /*
324 * If "globulize" modifies argv[1], and argv[2] is a copy of
325 * the old argv[1], make it a copy of the new argv[1].
326 */
327 if (argv[1] != oldargv1 && argv[2] == oldargv1) {
328 argv[2] = argv[1];
329 }
330 cmd = (argv[0][0] == 'a') ? "APPE" : ((sunique) ? "STOU" : "STOR");
331 if (loc && ntflag) {
332 argv[2] = dotrans(argv[2]);
333 }
334 if (loc && mapflag) {
335 argv[2] = domap(argv[2]);
336 }
337 sendrequest(cmd, argv[1], argv[2],
338 argv[1] != oldargv1 || argv[2] != oldargv2);
339}

◆ pwd()

void pwd ( int  argc,
const char argv[] 
)

Definition at line 1401 of file cmds.c.

1402{
1403 int oldverbose = verbose;
1404
1405 /*
1406 * If we aren't verbose, this doesn't do anything!
1407 */
1408 verbose = 1;
1409 if (command("PWD") == ERROR && code == 500) {
1410 printf("PWD command not recognized, trying XPWD\n");
1411 (void) fflush(stdout);
1412 (void) command("XPWD");
1413 }
1414 verbose = oldverbose;
1415}

Referenced by CRYPT_LMhash(), FTPChdir3(), GetContentsOfDialog(), GetContentsOfMenu(), InternetCrackUrlW_test(), ldap_bind_sW(), ldap_bindW(), ldap_simple_bind_sW(), ldap_simple_bindW(), MenuFill(), MenuScan(), netname2user(), and StrangeMenuFill().

◆ quit()

void quit ( int  argc,
const char argv[] 
)

Definition at line 1606 of file cmds.c.

1607{
1608 if (connected)
1609 disconnect(0, NULL);
1610 pswitch(1);
1611 if (connected) {
1612 disconnect(0, NULL);
1613 }
1614 exit(0);
1615}
void disconnect(int argc, const char *argv[])
Definition: cmds.c:1620
#define exit(n)
Definition: config.h:202

Referenced by CcFlushCache(), CcRosFlushVacb(), cmdscanner(), FileCompareBothWild(), FsRtlAddBaseMcbEntry(), FsRtlGetNextBaseMcbEntry(), FsRtlLookupBaseMcbEntry(), FsRtlRemoveBaseMcbEntry(), get_subtests(), main(), RestoreAllConnections(), service_main(), START_TEST(), TextCompare(), wmain(), and wWinMain().

◆ quote()

void quote ( int  argc,
const char argv[] 
)

Definition at line 1480 of file cmds.c.

1481{
1482 int i;
1483 char buf[BUFSIZ];
1484
1485 if (argc < 2) {
1486 (void) strcat(line, " ");
1487 printf("(command line to send) ");
1488 (void) fflush(stdout);
1489 (void) gets(&line[strlen(line)]);
1490 makeargv();
1491 argc = margc;
1492 argv = margv;
1493 }
1494 if (argc < 2) {
1495 printf("usage: %s line-to-send\n", argv[0]);
1496 (void) fflush(stdout);
1497 code = -1;
1498 return;
1499 }
1500 (void) strcpy(buf, argv[1]);
1501 for (i = 2; i < argc; i++) {
1502 (void) strcat(buf, " ");
1503 (void) strcat(buf, argv[i]);
1504 }
1505 if (command(buf) == PRELIM) {
1506 while (getreply(0) == PRELIM);
1507 }
1508}
#define PRELIM
Definition: ftp_var.h:41

◆ recvrequest()

void recvrequest ( const char cmd,
const char local,
const char remote,
const char mode,
int  printnames 
)

Definition at line 717 of file ftp.c.

719{
720 FILE *fout = stdout;
721 int din = 0;
722 int (*closefunc)();
723 void (*oldintr)(int), (*oldintp)(int);
724 int oldverbose = 0, oldtype = 0, is_retr, tcrflag, nfnd, bare_lfs = 0;
725 char msg;
726// static char *buf; // Szurgot: Shouldn't this go SOMEWHERE?
727 char buf[1024];
728 static int bufsize = 1024;
729 long bytes = 0, hashbytes = HASHBYTES;
730// struct
731 fd_set mask;
732 register int c;
733 struct timeval start, stop;
734// struct stat st;
735
736 is_retr = strcmp(cmd, "RETR") == 0;
737 if (is_retr && verbose && printnames) {
738 if (local && *local != '-')
739 printf("local: %s ", local);
740 if (remote)
741 printf("remote: %s\n", remote);
742 (void) fflush(stdout);
743 }
744 if (proxy && is_retr) {
745 proxtrans(cmd, local, remote);
746 return;
747 }
748 closefunc = NULL;
749 oldintr = NULL;
750 oldintp = NULL;
751 tcrflag = !crflag && is_retr;
752 if (setjmp(recvabort)) {
753 while (cpend) {
754 (void) getreply(0);
755 }
756 if (data >= 0) {
757 (void) close(data);
758 data = -1;
759 }
760 if (oldintr)
761null();// (void) signal(SIGINT, oldintr);
762 code = -1;
763 return;
764 }
765null();// oldintr = signal(SIGINT, abortrecv);
766 if (strcmp(local, "-") && *local != '|') {
767#ifndef _WIN32
768 register int d;
769// This whole thing is a problem... access Won't work on non-existent files
770 if (access(local, 2) < 0) {
771 char *dir = rindex(local, '/');
772
773 if (errno != ENOENT && errno != EACCES) {
774 perror(local);
775 (void) signal(SIGINT, oldintr);
776 code = -1;
777 return;
778 }
779 if (dir != NULL)
780 *dir = 0;
781 d = access(dir ? local : ".", 2);
782 if (dir != NULL)
783 *dir = '/';
784 if (d < 0) {
785 perror(local);
786 (void) signal(SIGINT, oldintr);
787 code = -1;
788 return;
789 }
790 if (!runique && errno == EACCES &&
791 chmod(local, 0600) < 0) {
792 perror(local);
793 (void) signal(SIGINT, oldintr);
794 code = -1;
795 return;
796 }
797 if (runique && errno == EACCES &&
798 (local = gunique(local)) == NULL) {
799 (void) signal(SIGINT, oldintr);
800 code = -1;
801 return;
802 }
803 }
804 else if (runique && (local = gunique(local)) == NULL) {
805 (void) signal(SIGINT, oldintr);
806 code = -1;
807 return;
808 }
809#endif
810 }
811 if (initconn()) {
812null();// (void) signal(SIGINT, oldintr);
813 code = -1;
814 return;
815 }
816 if (setjmp(recvabort))
817 goto abort;
818 if (!is_retr) {
819 if (type != TYPE_A && (allbinary == 0 || type != TYPE_I)) {
820 oldtype = type;
821 oldverbose = verbose;
822 if (!debug)
823 verbose = 0;
824 setascii(0, NULL);
825 verbose = oldverbose;
826 }
827 } else if (restart_point) {
828 if (command("REST %ld", (long) restart_point) != CONTINUE)
829 return;
830 }
831 if (remote) {
832 if (command("%s %s", cmd, remote) != PRELIM) {
833null();// (void) signal(SIGINT, oldintr);
834 if (oldtype) {
835 if (!debug)
836 verbose = 0;
837 switch (oldtype) {
838 case TYPE_I:
839 setbinary(0, NULL);
840 break;
841 case TYPE_E:
842 setebcdic();
843 break;
844 case TYPE_L:
845 settenex(0, NULL);
846 break;
847 }
848 verbose = oldverbose;
849 }
850 return;
851 }
852 } else {
853 if (command("%s", cmd) != PRELIM) {
854null();// (void) signal(SIGINT, oldintr);
855 if (oldtype) {
856 if (!debug)
857 verbose = 0;
858 switch (oldtype) {
859 case TYPE_I:
860 setbinary(0, NULL);
861 break;
862 case TYPE_E:
863 setebcdic();
864 break;
865 case TYPE_L:
866 settenex(0, NULL);
867 break;
868 }
869 verbose = oldverbose;
870 }
871 return;
872 }
873 }
874 din = dataconn("r");
875 if (!din)
876 goto abort;
877 if (strcmp(local, "-") == 0)
878 fout = stdout;
879 else if (*local == '|') {
880null();// oldintp = signal(SIGPIPE, SIG_IGN);
881 fout = _popen(local + 1, "w");
882 if (fout == NULL) {
883 perror(local+1);
884 goto abort;
885 }
886 closefunc = _pclose;
887 } else {
888 fout = fopen(local, mode);
889 if (fout == NULL) {
890 perror(local);
891 goto abort;
892 }
893 closefunc = fclose;
894 }
895 (void) gettimeofday(&start, (struct timezone *)0);
896 switch (type) {
897
898 case TYPE_I:
899 case TYPE_L:
900 if (restart_point &&
901 lseek(fileno(fout), (long) restart_point, L_SET) < 0) {
902 perror(local);
903 if (closefunc != NULL)
904 (*closefunc)(fout);
905 return;
906 }
907 errno = 0;
908// while ((c = recv(din, buf, bufsize, 1)) > 0) {
909// if ((d = write(fileno(fout), buf, c)) != c)
910// if ((d = write(fileno(fout), buf, c)) != c)
911// break;
912 while ((c = recv(din, buf, bufsize, 0)) > 0) {
913 write(fileno(fout), buf, c);
914 bytes += c;
915 if (hash) {
916 while (bytes >= hashbytes) {
917 (void) putchar('#');
918 hashbytes += HASHBYTES;
919 }
920 (void) fflush(stdout);
921 }
922 }
923 if (hash && bytes > 0) {
924 if (bytes < HASHBYTES)
925 (void) putchar('#');
926 (void) putchar('\n');
927 (void) fflush(stdout);
928 }
929// if (c < 0) {
930// if (errno != EPIPE)
931// perror("netin");
932// bytes = -1;
933// }
934// if (d < c) {
935// if (d < 0)
936// perror(local);
937// else
938// fprintf(stderr, "%s: short write\n", local);
939// }
940 break;
941
942 case TYPE_A:
943 if (restart_point) {
944 register int i, n, c;
945
946 if (fseek(fout, 0L, L_SET) < 0)
947 goto done;
949 i = 0;
950 while (i++ < n) {
951 if ((c=getc(fout)) == EOF)
952 goto done;
953 if (c == '\n')
954 i++;
955 }
956 if (fseek(fout, 0L, L_INCR) < 0) {
957done:
958 perror(local);
959 if (closefunc != NULL)
960 (*closefunc)(fout);
961 return;
962 }
963 }
964 while ((c = fgetcSocket(din)) != EOF) {
965 if (c == '\n')
966 bare_lfs++;
967 while (c == '\r') {
968 while (hash && (bytes >= hashbytes)) {
969 (void) putchar('#');
970 (void) fflush(stdout);
971 hashbytes += HASHBYTES;
972 }
973 bytes++;
974 if ((c = fgetcSocket(din)) != '\n' || tcrflag) {
975 if (ferror(fout))
976 goto break2;
977 (void) putc('\r', fout);
978 if (c == '\0') {
979 bytes++;
980 goto contin2;
981 }
982 if (c == EOF)
983 goto contin2;
984 }
985 }
986 (void) putc(c, fout);
987 bytes++;
988 contin2: ;
989 }
990break2:
991 if (bare_lfs) {
992 printf("WARNING! %d bare linefeeds received in ASCII mode\n", bare_lfs);
993 printf("File may not have transferred correctly.\n");
994 (void) fflush(stdout);
995 }
996 if (hash) {
997 if (bytes < hashbytes)
998 (void) putchar('#');
999 (void) putchar('\n');
1000 (void) fflush(stdout);
1001 }
1002// if (ferror(din)) {
1003// if (errno != EPIPE)
1004// perror("netin");
1005// bytes = -1;
1006// }
1007 if (ferror(fout))
1008 perror(local);
1009 break;
1010 }
1011 if (closefunc != NULL)
1012 (*closefunc)(fout);
1013null();// (void) signal(SIGINT, oldintr);
1014 if (oldintp)
1015null();// (void) signal(SIGPIPE, oldintp);
1016 (void) gettimeofday(&stop, (struct timezone *)0);
1017 if(closesocket(din)) {
1018 int iret=WSAGetLastError ();
1019 fprintf(stdout,"Error closing socket(%d)\n",iret);
1020 (void) fflush(stdout);
1021 }
1022
1023 (void) getreply(0);
1024 if (bytes > 0 && is_retr)
1025 ptransfer("received", bytes, &start, &stop);
1026 if (oldtype) {
1027 if (!debug)
1028 verbose = 0;
1029 switch (oldtype) {
1030 case TYPE_I:
1031 setbinary(0, NULL);
1032 break;
1033 case TYPE_E:
1034 setebcdic();
1035 break;
1036 case TYPE_L:
1037 settenex(0, NULL);
1038 break;
1039 }
1040 verbose = oldverbose;
1041 }
1042 return;
1043abort:
1044
1045/* abort using RFC959 recommended IP,SYNC sequence */
1046
1047 (void) gettimeofday(&stop, (struct timezone *)0);
1048 if (oldintp)
1049null();// (void) signal(SIGPIPE, oldintr);
1050null();// (void) signal(SIGINT,SIG_IGN);
1051 if (oldtype) {
1052 if (!debug)
1053 verbose = 0;
1054 switch (oldtype) {
1055 case TYPE_I:
1056 setbinary(0, NULL);
1057 break;
1058 case TYPE_E:
1059 setebcdic();
1060 break;
1061 case TYPE_L:
1062 settenex(0, NULL);
1063 break;
1064 }
1065 verbose = oldverbose;
1066 }
1067 if (!cpend) {
1068 code = -1;
1069null();// (void) signal(SIGINT,oldintr);
1070 return;
1071 }
1072
1073 fprintfSocket(cout,"%c%c",IAC,IP);
1074 msg = (char)IAC;
1075/* send IAC in urgent mode instead of DM because UNIX places oob mark */
1076/* after urgent byte rather than before as now is protocol */
1077 if (send(cout,&msg,1,MSG_OOB) != 1) {
1078 perror("abort");
1079 }
1080 fprintfSocket(cout,"%cABOR\r\n",DM);
1081 FD_ZERO(&mask);
1082 FD_SET(cin, &mask); // Need to correct this
1083 if (din) {
1084 FD_SET(din, &mask); // Need to correct this
1085 }
1086 if ((nfnd = empty(&mask,10)) <= 0) {
1087 if (nfnd < 0) {
1088 perror("abort");
1089 }
1090 code = -1;
1091 lostpeer();
1092 }
1093 if (din && FD_ISSET(din, &mask)) {
1094 while (recv(din, buf, bufsize, 0) > 0)
1095 ;
1096 }
1097 if (getreply(0) == ERROR && code == 552) { /* needed for nic style abort */
1098 if (data >= 0) {
1099 (void) close(data);
1100 data = -1;
1101 }
1102 (void) getreply(0);
1103 }
1104 (void) getreply(0);
1105 code = -1;
1106 if (data >= 0) {
1107 (void) close(data);
1108 data = -1;
1109 }
1110 if (closefunc != NULL && fout != NULL)
1111 (*closefunc)(fout);
1112 if (din)
1113 if(closesocket(din)) {
1114 int iret=WSAGetLastError ();
1115 fprintf(stdout,"Error closing socket(%d)\n",iret);
1116 (void) fflush(stdout);
1117 }
1118
1119 if (bytes > 0)
1120 ptransfer("received", bytes, &start, &stop);
1121null();// (void) signal(SIGINT,oldintr);
1122}
#define ENOENT
Definition: acclib.h:79
#define EACCES
Definition: acclib.h:85
#define fileno
Definition: acwin.h:102
#define write
Definition: acwin.h:97
#define gettimeofday(tv, tz)
Definition: adns_win32.h:159
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
unsigned int dir
Definition: maze.c:112
#define msg(x)
Definition: auth_time.c:54
#define rindex(s, c)
Definition: various.h:30
void setascii(int argc, const char *argv[])
Definition: cmds.c:212
void settenex(int argc, const char *argv[])
Definition: cmds.c:222
void setebcdic()
Definition: cmds.c:232
void setbinary(int argc, const char *argv[])
Definition: cmds.c:202
#define L_SET
Definition: ftp.c:22
void proxtrans(char *cmd, char *local, char *remote) const
Definition: ftp.c:1418
#define L_INCR
Definition: ftp.c:23
off_t restart_point
Definition: ftp.c:81
int null(void)
Definition: ftp.c:1794
jmp_buf recvabort
Definition: ftp.c:703
void ptransfer(char *direction, long bytes, struct timeval *t0, struct timeval *t1) const
Definition: ftp.c:1264
int dataconn(const char *mode)
Definition: ftp.c:1240
int allbinary
Definition: ftp.c:73
#define HASHBYTES
Definition: ftp.c:441
int initconn()
Definition: ftp.c:1125
static const WCHAR empty[]
Definition: main.c:47
unsigned char
Definition: typeof.h:29
#define local
Definition: zutil.h:30
#define TYPE_E
Definition: ftp_var.h:38
int crflag
Definition: main.c:76
#define TYPE_A
Definition: ftp_var.h:36
#define DM
Definition: ftp_var.h:26
#define TYPE_L
Definition: ftp_var.h:39
#define TYPE_I
Definition: ftp_var.h:37
#define IP
Definition: ftp_var.h:24
GLuint start
Definition: gl.h:1545
GLenum GLint GLuint mask
Definition: glext.h:6028
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
GLenum GLuint GLsizei bufsize
Definition: glext.h:7473
#define abort()
Definition: i386-dis.c:34
_Check_return_opt_ _CRTIMP int __cdecl _pclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP int __cdecl getc(_Inout_ FILE *_File)
_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 int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl _popen(_In_z_ const char *_Command, _In_z_ const char *_Mode)
#define d
Definition: ke_i.h:81
#define lseek
Definition: syshdrs.h:47
#define L(x)
Definition: ntvdm.h:50
_Check_return_ _CRTIMP int __cdecl chmod(_In_z_ const char *_Filename, _In_ int _AccessMode)
Definition: winsock.h:66
Definition: _hash_fun.h:40
Definition: fake.h:14
#define FD_ISSET(fd, set)
Definition: winsock.h:100
#define FD_ZERO(set)
Definition: winsock.h:96
#define MSG_OOB
Definition: winsock.h:221
#define FD_SET(fd, set)
Definition: winsock.h:89

Referenced by getit(), ls(), mget(), mls(), and remglob().

◆ reget()

void reget ( int  argc,
const char argv[] 
)

Definition at line 475 of file cmds.c.

476{
477 (void) getit(argc, argv, 1, "r+w");
478}

◆ removedir()

void removedir ( int  argc,
const char argv[] 
)

Definition at line 1450 of file cmds.c.

1451{
1452
1453 if (argc < 2) {
1454 (void) strcat(line, " ");
1455 printf("(directory-name) ");
1456 (void) fflush(stdout);
1457 (void) gets(&line[strlen(line)]);
1458 makeargv();
1459 argc = margc;
1460 argv = margv;
1461 }
1462 if (argc < 2) {
1463 printf("usage: %s directory-name\n", argv[0]);
1464 (void) fflush(stdout);
1465 code = -1;
1466 return;
1467 }
1468 if (command("RMD %s", argv[1]) == ERROR && code == 500) {
1469 if (verbose) {
1470 printf("RMD command not recognized, trying XRMD\n");
1471 (void) fflush(stdout);
1472 }
1473 (void) command("XRMD %s", argv[1]);
1474 }
1475}

◆ renamefile()

void renamefile ( int  argc,
const char argv[] 
)

Definition at line 1098 of file cmds.c.

1099{
1100
1101 if (argc < 2) {
1102 (void) strcat(line, " ");
1103 printf("(from-name) ");
1104 (void) fflush(stdout);
1105 (void) gets(&line[strlen(line)]);
1106 makeargv();
1107 argc = margc;
1108 argv = margv;
1109 }
1110 if (argc < 2) {
1111usage:
1112 printf("%s from-name to-name\n", argv[0]);
1113 (void) fflush(stdout);
1114 code = -1;
1115 return;
1116 }
1117 if (argc < 3) {
1118 (void) strcat(line, " ");
1119 printf("(to-name) ");
1120 (void) fflush(stdout);
1121 (void) gets(&line[strlen(line)]);
1122 makeargv();
1123 argc = margc;
1124 argv = margv;
1125 }
1126 if (argc < 3)
1127 goto usage;
1128 if (command("RNFR %s", argv[1]) == CONTINUE)
1129 (void) command("RNTO %s", argv[2]);
1130}

◆ reset()

void reset ( int  argc,
const char argv[] 
)

Definition at line 1725 of file ftp.c.

1726{
1727// struct
1728 fd_set mask;
1729 int nfnd = 1;
1730
1731 FD_ZERO(&mask);
1732 while (nfnd > 0) {
1733// FD_SET(fileno(cin), &mask); // Chris
1734 if ((nfnd = empty(&mask,0)) < 0) {
1735 perror("reset");
1736 code = -1;
1737 lostpeer();
1738 }
1739 else if (nfnd) {
1740 (void) getreply(0);
1741 }
1742 }
1743}

◆ restart()

void restart ( int  argc,
const char argv[] 
)

Definition at line 2115 of file cmds.c.

2116{
2117 if (argc != 2)
2118 printf("restart: offset not specified\n");
2119 else {
2120 restart_point = atol(argv[1]);
2121 printf("restarting at %ld. %s\n", restart_point,
2122 "execute get, put or append to initiate transfer");
2123 }
2124 (void) fflush(stdout);
2125}
_Check_return_ long __cdecl atol(_In_z_ const char *_Str)

Referenced by check_file(), DRIVER_UnloadAll(), empty_ea_error(), ext3_find_entry(), FxUsbPipeContinuousReader::FxUsbPipeRequestWorkItemHandler(), open_file_test(), ParseChar(), FxPkgPnp::PnpCheckAndIncrementRestartCount(), RtlInterlockedPopEntrySList(), TIFFFillStripPartial(), and xsltTestCompMatch().

◆ rmthelp()

void rmthelp ( int  argc,
const char argv[] 
)

Definition at line 1593 of file cmds.c.

1594{
1595 int oldverbose = verbose;
1596
1597 verbose = 1;
1598 (void) command(argc == 1 ? "HELP" : "HELP %s", argv[1]);
1599 verbose = oldverbose;
1600}

◆ rmtstatus()

void rmtstatus ( int  argc,
const char argv[] 
)

Definition at line 2270 of file cmds.c.

2271{
2272 (void) command(argc > 1 ? "STAT %s" : "STAT" , argv[1]);
2273}

◆ ruserpass()

int ruserpass ( const char host,
char **  aname,
char **  apass,
char **  aacct 
)

Definition at line 58 of file ruserpass.c.

59{
60 const char *hdir, *mydomain;
61 char buf[BUFSIZ], *tmp;
62 char myname[MAXHOSTNAMELEN];
63 int t, i, c, usedefault = 0;
64 struct stat stb;
65
66 hdir = getenv("HOME");
67 if (hdir == NULL)
68 hdir = ".";
69 (void) sprintf(buf, "%s/.netrc", hdir);
70 cfile = fopen(buf, "r");
71 if (cfile == NULL) {
72 if (errno != ENOENT)
73 perror(buf);
74 return(0);
75 }
76
77
78 if (gethostname(myname, sizeof(myname)) < 0)
79 myname[0] = '\0';
80 if ((mydomain = index(myname, '.')) == NULL)
81 mydomain = "";
82next:
83 while ((t = token())) switch(t) {
84
85 case DEFAULT:
86 usedefault = 1;
87 /* FALL THROUGH */
88
89 case MACH:
90 if (!usedefault) {
91 if (token() != ID)
92 continue;
93 /*
94 * Allow match either for user's input host name
95 * or official hostname. Also allow match of
96 * incompletely-specified host in local domain.
97 */
98 if (strcasecmp(host, tokval) == 0)
99 goto match;
100 if (strcasecmp(hostname, tokval) == 0)
101 goto match;
102 if ((tmp = index(hostname, '.')) != NULL &&
103 strcasecmp(tmp, mydomain) == 0 &&
104 strncasecmp(hostname, tokval, tmp - hostname) == 0 &&
105 tokval[tmp - hostname] == '\0')
106 goto match;
107 if ((tmp = index(host, '.')) != NULL &&
108 strcasecmp(tmp, mydomain) == 0 &&
109 strncasecmp(host, tokval, tmp - host) == 0 &&
110 tokval[tmp - host] == '\0')
111 goto match;
112 continue;
113 }
114 match:
115 while ((t = token()) && t != MACH && t != DEFAULT) switch(t) {
116
117 case LOGIN:
118 if (token()) {
119 if (*aname == 0) {
120 *aname = malloc((unsigned) strlen(tokval) + 1);
121 (void) strcpy(*aname, tokval);
122 } else {
123 if (strcmp(*aname, tokval))
124 goto next;
125 }
126 }
127 break;
128 case PASSWD:
129 if (strcmp(*aname, "anonymous") &&
130 fstat(fileno(cfile), &stb) >= 0 &&
131 (stb.st_mode & 077) != 0) {
132 fprintf(stderr, "Error - .netrc file not correct mode.\n");
133 fprintf(stderr, "Remove password or correct mode.\n");
134 goto bad;
135 }
136 if (token() && *apass == 0) {
137 *apass = malloc((unsigned) strlen(tokval) + 1);
138 (void) strcpy(*apass, tokval);
139 }
140 break;
141 case ACCOUNT:
142 if (fstat(fileno(cfile), &stb) >= 0
143 && (stb.st_mode & 077) != 0) {
144 fprintf(stderr, "Error - .netrc file not correct mode.\n");
145 fprintf(stderr, "Remove account or correct mode.\n");
146 goto bad;
147 }
148 if (token() && *aacct == 0) {
149 *aacct = malloc((unsigned) strlen(tokval) + 1);
150 (void) strcpy(*aacct, tokval);
151 }
152 break;
153 case MACDEF:
154 if (proxy) {
155 (void) fclose(cfile);
156 return(0);
157 }
158 while ((c=getc(cfile)) != EOF && (c == ' ' || c == '\t'));
159 if (c == EOF || c == '\n') {
160 printf("Missing macdef name argument.\n");
161 goto bad;
162 }
163 if (macnum == 16) {
164 printf("Limit of 16 macros have already been defined\n");
165 goto bad;
166 }
167 tmp = macros[macnum].mac_name;
168 *tmp++ = c;
169 for (i=0; i < 8 && (c=getc(cfile)) != EOF &&
170 !isspace(c); ++i) {
171 *tmp++ = c;
172 }
173 if (c == EOF) {
174 printf("Macro definition missing null line terminator.\n");
175 goto bad;
176 }
177 *tmp = '\0';
178 if (c != '\n') {
179 while ((c=getc(cfile)) != EOF && c != '\n');
180 }
181 if (c == EOF) {
182 printf("Macro definition missing null line terminator.\n");
183 goto bad;
184 }
185 if (macnum == 0) {
186 macros[macnum].mac_start = macbuf;
187 }
188 else {
189 macros[macnum].mac_start = macros[macnum-1].mac_end + 1;
190 }
191 tmp = macros[macnum].mac_start;
192 while (tmp != macbuf + 4096) {
193 if ((c=getc(cfile)) == EOF) {
194 printf("Macro definition missing null line terminator.\n");
195 goto bad;
196 }
197 *tmp = c;
198 if (*tmp == '\n') {
199 if (*(tmp-1) == '\0') {
200 macros[macnum++].mac_end = tmp - 1;
201 break;
202 }
203 *tmp = '\0';
204 }
205 tmp++;
206 }
207 if (tmp == macbuf + 4096) {
208 printf("4K macro buffer exceeded\n");
209 goto bad;
210 }
211 break;
212 default:
213 fprintf(stderr, "Unknown .netrc keyword %s\n", tokval);
214 break;
215 }
216 goto done;
217 }
218done:
219 (void) fclose(cfile);
220 return(0);
221bad:
222 (void) fclose(cfile);
223 return(-1);
224}
#define fstat
Definition: acwin.h:100
#define index(s, c)
Definition: various.h:29
#define malloc
Definition: debug_ros.c:4
#define strncasecmp
Definition: fake.h:10
#define strcasecmp
Definition: fake.h:9
INT WSAAPI gethostname(OUT char FAR *name, IN INT namelen)
Definition: getxbyxx.c:397
GLdouble GLdouble t
Definition: gl.h:2047
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static unsigned __int64 next
Definition: rand_nt.c:6
#define ACCOUNT
Definition: ruserpass.c:34
static char tokval[100]
Definition: ruserpass.c:39
#define LOGIN
Definition: ruserpass.c:32
static FILE * cfile
Definition: ruserpass.c:25
#define DEFAULT
Definition: ruserpass.c:31
#define MACDEF
Definition: ruserpass.c:35
#define ID
Definition: ruserpass.c:36
static int token(void)
Definition: ruserpass.c:226
#define MACH
Definition: ruserpass.c:37
#define PASSWD
Definition: ruserpass.c:33
char * hostname
Definition: ftp.c:88
#define MAXHOSTNAMELEN
Definition: ruserpass.c:28
Definition: match.c:28

Referenced by login().

◆ sendrequest()

void sendrequest ( const char cmd,
const char local,
const char remote,
int  printnames 
)

Definition at line 443 of file ftp.c.

444{
445 FILE *fin;
446 int dout = 0;
447 int (*closefunc)();
448 sig_t (*oldintr)(), (*oldintp)();
449 char buf[BUFSIZ], *bufp;
450 long bytes = 0, hashbytes = HASHBYTES;
451 register int c, d;
452 struct stat st;
453 struct timeval start, stop;
454 const char *mode;
455
456 if (verbose && printnames) {
457 if (local && *local != '-')
458 printf("local: %s ", local);
459 if (remote)
460 printf("remote: %s\n", remote);
461 (void) fflush(stdout);
462 }
463 if (proxy) {
464 proxtrans(cmd, local, remote);
465 return;
466 }
467 closefunc = NULL;
468 oldintr = NULL;
469 oldintp = NULL;
470 mode = "w";
471 if (setjmp(sendabort)) {
472 while (cpend) {
473 (void) getreply(0);
474 }
475 if (data >= 0) {
476 (void) close(data);
477 data = -1;
478 }
479 if (oldintr)
480null();// (void) signal(SIGINT,oldintr);
481 if (oldintp)
482null();// (void) signal(SIGPIPE,oldintp);
483 code = -1;
484 return;
485 }
486null();// oldintr = signal(SIGINT, abortsend);
487 if (strcmp(local, "-") == 0)
488 fin = stdin;
489 else if (*local == '|') {
490null();// oldintp = signal(SIGPIPE,SIG_IGN);
491 fin = _popen(local + 1, "r");
492 if (fin == NULL) {
493 perror(local + 1);
494null();// (void) signal(SIGINT, oldintr);
495null();// (void) signal(SIGPIPE, oldintp);
496 code = -1;
497 return;
498 }
499 closefunc = _pclose;
500 } else {
501 fin = fopen(local, "r");
502 if (fin == NULL) {
503 perror(local);
504null();// (void) signal(SIGINT, oldintr);
505 code = -1;
506 return;
507 }
508 closefunc = fclose;
509 if (fstat(fileno(fin), &st) < 0 ||
510 (st.st_mode&S_IFMT) != S_IFREG) {
511 fprintf(stdout, "%s: not a plain file.\n", local);
512 (void) fflush(stdout);
513null();// (void) signal(SIGINT, oldintr);
514 fclose(fin);
515 code = -1;
516 return;
517 }
518 }
519 if (initconn()) {
520null();// (void) signal(SIGINT, oldintr);
521 if (oldintp)
522null();// (void) signal(SIGPIPE, oldintp);
523 code = -1;
524 if (closefunc != NULL)
525 (*closefunc)(fin);
526 return;
527 }
528 if (setjmp(sendabort))
529 goto abort;
530
531 if (restart_point &&
532 (strcmp(cmd, "STOR") == 0 || strcmp(cmd, "APPE") == 0)) {
533 if (fseek(fin, (long) restart_point, 0) < 0) {
534 perror(local);
535 restart_point = 0;
536 if (closefunc != NULL)
537 (*closefunc)(fin);
538 return;
539 }
540 if (command("REST %ld", (long) restart_point)
541 != CONTINUE) {
542 restart_point = 0;
543 if (closefunc != NULL)
544 (*closefunc)(fin);
545 return;
546 }
547 restart_point = 0;
548 mode = "r+w";
549 }
550 if (remote) {
551 if (command("%s %s", cmd, remote) != PRELIM) {
552null();// (void) signal(SIGINT, oldintr);
553 if (oldintp)
554null();// (void) signal(SIGPIPE, oldintp);
555 if (closefunc != NULL)
556 (*closefunc)(fin);
557 return;
558 }
559 } else
560 if (command("%s", cmd) != PRELIM) {
561null();// (void) signal(SIGINT, oldintr);
562 if (oldintp)
563null();// (void) signal(SIGPIPE, oldintp);
564 if (closefunc != NULL)
565 (*closefunc)(fin);
566 return;
567 }
568 dout = dataconn(mode);
569 if (!dout)
570 goto abort;
571 (void) gettimeofday(&start, (struct timezone *)0);
572null();// oldintp = signal(SIGPIPE, SIG_IGN);
573 switch (type) {
574
575 case TYPE_I:
576 case TYPE_L:
577 errno = d = 0;
578 while ((c = read(fileno(fin), buf, sizeof (buf))) > 0) {
579 bytes += c;
580 for (bufp = buf; c > 0; c -= d, bufp += d)
581 if ((d = send(dout, bufp, c, 0)) <= 0)
582 break;
583 if (hash) {
584 while (bytes >= hashbytes) {
585 (void) putchar('#');
586 hashbytes += HASHBYTES;
587 }
588 (void) fflush(stdout);
589 }
590 }
591 if (hash && bytes > 0) {
592 if (bytes < HASHBYTES)
593 (void) putchar('#');
594 (void) putchar('\n');
595 (void) fflush(stdout);
596 }
597 if (c < 0)
598 perror(local);
599 if (d <= 0) {
600 if (d == 0)
601 fprintf(stderr, "netout: write returned 0?\n");
602 else if (errno != EPIPE)
603 perror("netout");
604 bytes = -1;
605 }
606 break;
607
608 case TYPE_A:
609 {
610 char buf[1024];
611 static int bufsize = 1024;
612 int ipos=0;
613
614 while ((c = getc(fin)) != EOF) {
615 if (c == '\n') {
616 while (hash && (bytes >= hashbytes)) {
617 (void) putchar('#');
618 (void) fflush(stdout);
619 hashbytes += HASHBYTES;
620 }
621// Szurgot: The following code is unnecessary on Win32.
622// (void) fputcSocket(dout, '\r');
623// bytes++;
624 }
625
626 if (ipos >= bufsize) {
627 fputSocket(dout,buf,ipos);
628 if(!hash) (void) putchar('.');
629 ipos=0;
630 }
631 buf[ipos]=c; ++ipos;
632 bytes++;
633 }
634 if (ipos) {
635 fputSocket(dout,buf,ipos);
636 ipos=0;
637 }
638 if (hash) {
639 if (bytes < hashbytes)
640 (void) putchar('#');
641 (void) putchar('\n');
642 (void) fflush(stdout);
643 }
644 else {
645 (void) putchar('.');
646 (void) putchar('\n');
647 (void) fflush(stdout);
648 }
649 if (ferror(fin))
650 perror(local);
651// if (ferror(dout)) {
652// if (errno != EPIPE)
653// perror("netout");
654// bytes = -1;
655// }
656 break;
657 }
658 }
659 (void) gettimeofday(&stop, (struct timezone *)0);
660 if (closefunc != NULL)
661 (*closefunc)(fin);
662 if(closesocket(dout)) {
663 int iret=WSAGetLastError ();
664 fprintf(stdout,"Error closing socket(%d)\n",iret);
665 (void) fflush(stdout);
666 }
667 (void) getreply(0);
668null();// (void) signal(SIGINT, oldintr);
669 if (oldintp)
670null();// (void) signal(SIGPIPE, oldintp);
671 if (bytes > 0)
672 ptransfer("sent", bytes, &start, &stop);
673 return;
674abort:
675 (void) gettimeofday(&stop, (struct timezone *)0);
676null();// (void) signal(SIGINT, oldintr);
677 if (oldintp)
678null();// (void) signal(SIGPIPE, oldintp);
679 if (!cpend) {
680 code = -1;
681 (*closefunc)(fin);
682 return;
683 }
684 if (data >= 0) {
685 (void) close(data);
686 data = -1;
687 }
688 if (dout)
689 if(closesocket(dout)) {
690 int iret=WSAGetLastError ();
691 fprintf(stdout,"Error closing socket(%d)\n",iret);
692 (void) fflush(stdout);
693 }
694
695 (void) getreply(0);
696 code = -1;
697 if (closefunc != NULL && fin != NULL)
698 (*closefunc)(fin);
699 if (bytes > 0)
700 ptransfer("sent", bytes, &start, &stop);
701}
#define EPIPE
Definition: acclib.h:91
#define read
Definition: acwin.h:96
jmp_buf sendabort
Definition: ftp.c:427
#define S_IFREG
Definition: ext2fs.h:361
#define S_IFMT
Definition: ext2fs.h:358
int fputSocket(int s, char *buffer, int len)
Definition: fake.c:151
int sig_t
Definition: ftp_var.h:161

Referenced by mput(), and put().

◆ setascii()

void setascii ( int  argc,
const char argv[] 
)

Definition at line 212 of file cmds.c.

213{
214 stype[1] = "ascii";
215 settype(2, stype);
216}
void settype(int argc, const char *argv[])
Definition: cmds.c:147
const char * stype[]
Definition: cmds.c:192

Referenced by proxtrans(), and recvrequest().

◆ setbell()

void setbell ( int  argc,
const char argv[] 
)

Definition at line 840 of file cmds.c.

841{
842
843 bell = !bell;
844 printf("Bell mode %s.\n", onoff(bell));
845 (void) fflush(stdout);
846 code = bell;
847}
static const char * onoff(int bool)
Definition: cmds.c:777

◆ setbinary()

void setbinary ( int  argc,
const char argv[] 
)

Definition at line 202 of file cmds.c.

203{
204 stype[1] = "binary";
205 settype(2, stype);
206}

Referenced by proxtrans(), recvrequest(), and setpeer().

◆ setcase()

void setcase ( int  argc,
const char argv[] 
)

Definition at line 1800 of file cmds.c.

1801{
1802 mcase = !mcase;
1803 printf("Case mapping %s.\n", onoff(mcase));
1804 (void) fflush(stdout);
1805 code = mcase;
1806}

◆ setcr()

void setcr ( int  argc,
const char argv[] 
)

Definition at line 1808 of file cmds.c.

1809{
1810 crflag = !crflag;
1811 printf("Carriage Return stripping %s.\n", onoff(crflag));
1812 (void) fflush(stdout);
1813 code = crflag;
1814}

◆ setdebug()

void setdebug ( int  argc,
const char argv[] 
)

Definition at line 937 of file cmds.c.

938{
939 int val;
940
941 if (argc > 1) {
942 val = atoi(argv[1]);
943 if (val < 0) {
944 printf("%s: bad debugging value.\n", argv[1]);
945 (void) fflush(stdout);
946 code = -1;
947 return;
948 }
949 } else
950 val = !debug;
951 debug = val;
952 if (debug)
953 options |= SO_DEBUG;
954 else
955 options &= ~SO_DEBUG;
956 printf("Debugging %s (debug=%d).\n", onoff(debug), debug);
957 (void) fflush(stdout);
958 code = debug > 0;
959}
GLuint GLfloat * val
Definition: glext.h:7180
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)

◆ setebcdic()

void setebcdic ( void  )

Definition at line 232 of file cmds.c.

233{
234 stype[1] = "ebcdic";
235 settype(2, stype);
236}

Referenced by proxtrans(), and recvrequest().

◆ setform()

void setform ( int  argc,
const char argv[] 
)

Definition at line 256 of file cmds.c.

257{
258
259 printf("We only support %s format, sorry.\n", formname);
260 (void) fflush(stdout);
261 code = -1;
262}
char formname[32]
Definition: main.c:88

◆ setglob()

void setglob ( int  argc,
const char argv[] 
)

Definition at line 923 of file cmds.c.

924{
925
926 doglob = !doglob;
927 printf("Globbing %s.\n", onoff(doglob));
928 (void) fflush(stdout);
929 code = doglob;
930}

◆ sethash()

void sethash ( int  argc,
const char argv[] 
)

Definition at line 866 of file cmds.c.

867{
868
869 hash = !hash;
870 printf("Hash mark printing %s", onoff(hash));
871 code = hash;
872 if (hash)
873 printf(" (%d bytes/hash mark)", 1024);
874 printf(".\n");
875 (void) fflush(stdout);
876}

◆ setnmap()

void setnmap ( int  argc,
const char argv[] 
)

Definition at line 1873 of file cmds.c.

1874{
1875 char *cp;
1876
1877 if (argc == 1) {
1878 mapflag = 0;
1879 printf("Nmap off.\n");
1880 (void) fflush(stdout);
1881 code = mapflag;
1882 return;
1883 }
1884 if (argc < 3) {
1885 (void) strcat(line, " ");
1886 printf("(mapout) ");
1887 (void) fflush(stdout);
1888 (void) gets(&line[strlen(line)]);
1889 makeargv();
1890 argc = margc;
1891 argv = margv;
1892 }
1893 if (argc < 3) {
1894 printf("Usage: %s [mapin mapout]\n",argv[0]);
1895 (void) fflush(stdout);
1896 code = -1;
1897 return;
1898 }
1899 mapflag = 1;
1900 code = 1;
1901 cp = index(altarg, ' ');
1902 if (proxy) {
1903 while(*++cp == ' ');
1904 altarg = cp;
1905 cp = index(altarg, ' ');
1906 }
1907 *cp = '\0';
1909 while (*++cp == ' ');
1910 (void) strncpy(mapout, cp, MAXPATHLEN - 1);
1911}
char * altarg
Definition: main.c:78

◆ setntrans()

void setntrans ( int  argc,
const char argv[] 
)

Definition at line 1816 of file cmds.c.

1817{
1818 if (argc == 1) {
1819 ntflag = 0;
1820 printf("Ntrans off.\n");
1821 (void) fflush(stdout);
1822 code = ntflag;
1823 return;
1824 }
1825 ntflag++;
1826 code = ntflag;
1827 (void) strncpy(ntin, argv[1], 16);
1828 ntin[16] = '\0';
1829 if (argc == 2) {
1830 ntout[0] = '\0';
1831 return;
1832 }
1833 (void) strncpy(ntout, argv[2], 16);
1834 ntout[16] = '\0';
1835}

◆ setpassive()

void setpassive ( int  argc,
const char argv[] 
)

Definition at line 1865 of file cmds.c.

1866{
1868 printf("Passive mode %s.\n", onoff(passivemode));
1869 (void) fflush(stdout);
1870 code = passivemode;
1871}

◆ setpeer()

void setpeer ( int  argc,
const char argv[] 
)

Definition at line 49 of file cmds.c.

50{
51 char *host;
52
53 if (connected) {
54 printf("Already connected to %s, use close first.\n",
55 hostname);
57 code = -1;
58 return;
59 }
60 if (argc < 2) {
61 (void) strcat(line, " ");
62 printf("(to) ");
64 (void) gets(&line[strlen(line)]);
65 makeargv();
66 argc = margc;
67 argv = margv;
68 }
69 if (argc > 3) {
70 printf("usage: %s host-name [port]\n", argv[0]);
72 code = -1;
73 return;
74 }
75 if (argc > 2) {
76 portnum = atoi(argv[2]);
77 if (portnum <= 0) {
78 printf("%s: bad port number-- %s\n", argv[1], argv[2]);
79 printf ("usage: %s host-name [port]\n", argv[0]);
81 code = -1;
82 return;
83 }
85 }
86 host = hookup(argv[1], portnum);
87 if (host) {
88 int overbose;
89 connected = 1;
90 if (autologin)
91 (void) login(argv[1]);
92
93 overbose = verbose;
94 if (debug == 0)
95 verbose = -1;
96 allbinary = 0;
97 if (command("SYST") == COMPLETE && overbose) {
98 register char *cp, c;
99 cp = index(reply_string+4, ' ');
100 if (cp == NULL)
101 cp = index(reply_string+4, '\r');
102 if (cp) {
103 if (cp[-1] == '.')
104 cp--;
105 c = *cp;
106 *cp = '\0';
107 }
108
109 printf("Remote system type is %s.\n",
110 reply_string+4);
111 if (cp)
112 *cp = c;
113 }
114 if (!strncmp(reply_string, "215 UNIX Type: L8", 17)) {
115 setbinary(0, NULL);
116 /* allbinary = 1; this violates the RFC */
117 if (overbose)
118 printf("Using %s mode to transfer files.\n",
119 typename);
120 } else if (overbose &&
121 !strncmp(reply_string, "215 TOPS20", 10)) {
122 printf(
123"Remember to set tenex mode when transfering binary files from this machine.\n");
124 }
125 verbose = overbose;
126 }
127 (void) fflush(stdout);
128}
int autologin
Definition: main.c:49
int allbinary
Definition: ftp.c:73
char * hostname
Definition: ftp.c:88
short portnum
Definition: main.c:45
char * hookup(const char *host, int port)
Definition: