27static char sccsid[] =
"@(#)cmds.c 5.18 (Berkeley) 4/20/89";
32static const char *
remglob(
const char *
argv[],
int doswitch);
54 printf(
"Already connected to %s, use close first.\n",
70 printf(
"usage: %s host-name [port]\n",
argv[0]);
79 printf (
"usage: %s host-name [port]\n",
argv[0]);
109 printf(
"Remote system type is %s.\n",
118 printf(
"Using %s mode to transfer files.\n",
120 }
else if (overbose &&
123"Remember to set tenex mode when transfering binary files from this machine.\n");
136 {
"ascii",
"A",
TYPE_A, 0 },
137 {
"binary",
"I",
TYPE_I, 0 },
138 {
"image",
"I",
TYPE_I, 0 },
139 {
"ebcdic",
"E",
TYPE_E, 0 },
158 printf(
"%s%s", sep,
p->t_name);
168 printf(
"Using %s mode to transfer files.\n",
typename);
176 if (
p->t_name == 0) {
182 if ((
p->t_arg !=
NULL) && (*(
p->t_arg) !=
'\0'))
183 comret =
command (
"TYPE %s %s",
p->t_mode,
p->t_arg);
185 comret =
command(
"TYPE %s",
p->t_mode);
283 const char *oldargv1, *oldargv2;
301 printf(
"usage:%s local-file remote-file\n",
argv[0]);
327 if (
argv[1] != oldargv1 &&
argv[2] == oldargv1) {
330 cmd = (
argv[0][0] ==
'a') ?
"APPE" : ((
sunique) ?
"STOU" :
"STOR");
338 argv[1] != oldargv1 ||
argv[2] != oldargv2);
388 while ((*tp2 = *
tp)) {
390 *tp2 =
'a' + *tp2 -
'A';
409 if (
confirm(
"Continue with",
"mput")) {
421 register char **cpp, **gargs;
432 if (
confirm(
"Continue with",
"mput")) {
450 for (cpp = gargs; cpp && *cpp !=
NULL; cpp++) {
459 if (
confirm(
"Continue with",
"mput")) {
491 const char *oldargv1, *oldargv2;
509 printf(
"usage: %s remote-file [ local-file ]\n",
argv[0]);
541 while ((*tp2 = *
tp)) {
543 *tp2 =
'a' + *tp2 -
'A';
560 if (restartit == 1) {
574 int yy, mo,
day, hour,
min, sec;
578 "%*s %04d%02d%02d%02d%02d%02d",
579 &yy, &mo, &
day, &hour, &
min, &sec);
611 argv[1] != oldargv1 ||
argv[2] != oldargv2);
651 printf(
"(remote-files) ");
682 while ((*tp2 = *
tp)) {
684 *tp2 =
'a' + *tp2 -
'A';
703 if (
confirm(
"Continue with",
"mget")) {
720 static const char **
args;
721 int oldverbose, oldhash;
762 printf(
"can't find list of remote files, oops\n");
779 return (
bool ?
"on" :
"off");
793 printf(
"Not connected.\n");
800 printf(
"No proxy connection.\n");
804 printf(
"Mode: %s; Type: %s; Form: %s; Structure: %s\n",
806 printf(
"Verbose: %s; Bell: %s; Prompting: %s; Globbing: %s\n",
824 printf(
"Hash mark printing: %s; Use of PORT cmds: %s\n",
873 printf(
" (%d bytes/hash mark)", 1024);
944 printf(
"%s: bad debugging value.\n",
argv[1]);
970 printf(
"(remote-directory) ");
978 printf(
"usage:%s remote-directory\n",
argv[0]);
985 printf(
"CWD command not recognized, trying XCWD\n");
1003 printf(
"usage:%s local-directory\n",
argv[0]);
1030 printf(
"(remote-file) ");
1057 printf(
"(remote-files) ");
1084 if (
confirm(
"Continue with",
"mdelete")) {
1145 printf(
"usage: %s remote-directory local-file\n",
argv[0]);
1150 cmd =
argv[0][0] ==
'n' ?
"NLST" :
"LIST";
1177 printf(
"(remote-files) ");
1194 printf(
"usage:%s remote-files local-file\n",
argv[0]);
1206 cmd =
argv[0][1] ==
'l' ?
"NLST" :
"LIST";
1212 *
mode = (
i == 1) ?
'w' :
'a';
1235 sig_t (*old1)(), (*old2)();
1236 char shellnam[40], *
shell, *namep;
1241 if ((
pid = fork()) == 0) {
1254 if (
strcmp(namep,
"sh") != 0)
1276 perror(
"Try again later");
1291 char ShellName[] =
"COMSPEC";
1315 StartupInfo.
cb =
sizeof( StartupInfo );
1319 StartupInfo.
dwX = 0;
1320 StartupInfo.
dwY = 0;
1337 &ProcessInformation);
1365 printf(
"usage: %s username [password] [account]\n",
argv[0]);
1381 acct[
strlen(acct) - 1] =
'\0';
1392 if (!aflag &&
argc == 4) {
1410 printf(
"PWD command not recognized, trying XPWD\n");
1425 printf(
"(directory-name) ");
1433 printf(
"usage: %s directory-name\n",
argv[0]);
1440 printf(
"MKD command not recognized, trying XMKD\n");
1455 printf(
"(directory-name) ");
1463 printf(
"usage: %s directory-name\n",
argv[0]);
1470 printf(
"RMD command not recognized, trying XRMD\n");
1487 printf(
"(command line to send) ");
1522 printf(
"(arguments to SITE command) ");
1549 printf(
"usage: %s mode file-name\n",
argv[0]);
1556 printf(
"(mode and file-name) ");
1564 printf(
"usage: %s mode file-name\n",
argv[0]);
1645 return (*
line !=
'n' && *
line !=
'N');
1669 globbed =
glob(*cpp);
1675 free((
char *)globbed);
1684 free((
char *)globbed);
1736 register struct cmd *
c;
1757 if (
c == (
struct cmd *) -1) {
1758 printf(
"?Ambiguous command\n");
1764 printf(
"?Invalid command\n");
1770 printf(
"?Invalid proxy command\n");
1782 printf(
"Not connected\n");
1843 register int i, ostop, found;
1845 for (ostop = 0; ostop < 16 && *(
ntout + ostop); ostop++);
1846 for (cp1 =
name; *cp1; cp1++) {
1848 for (
i = 0;
i < 16 && *(
ntin +
i);
i++) {
1849 if (*cp1 == *(
ntin +
i)) {
1894 printf(
"Usage: %s [mapin mapout]\n",
argv[0]);
1903 while(*++
cp ==
' ');
1909 while (*++
cp ==
' ');
1917 const char *cp1 =
name;
1918 char *cpn, *cp2 =
mapin;
1919 const char *
tp[9], *te[9];
1920 int i, toks[9], toknum = 0,
match = 1;
1922 for (
i=0;
i < 9; ++
i) {
1925 while (
match && *cp1 && *cp2) {
1928 if (*++cp2 != *cp1) {
1933 if (*(cp2+1) >=
'1' && (*cp2+1) <=
'9') {
1934 if (*cp1 != *(++cp2+1)) {
1935 toks[toknum = *cp2 -
'1']++;
1937 while (*++cp1 && *(cp2+1)
1951 if (
match && *cp1) {
1954 if (
match && *cp2) {
1976 if (*++cp2 ==
'$' &&
isdigit(*(cp2+1))) {
1977 if (*++cp2 ==
'0') {
1978 const char *cp3 =
name;
1985 else if (toks[toknum = *cp2 -
'1']) {
1986 const char *cp3 =
tp[toknum];
1988 while (cp3 != te[toknum]) {
1995 while (*cp2 && *cp2 !=
',' &&
2000 else if (*cp2 ==
'$' &&
2002 if (*++cp2 ==
'0') {
2003 const char *cp3 =
name;
2009 else if (toks[toknum =
2011 const char *cp3=
tp[toknum];
2024 printf(
"nmap: unbalanced brackets\n");
2032 while (*++cp2 && *cp2 !=
']') {
2033 if (*cp2 ==
'\\' && *(cp2 + 1)) {
2038 printf(
"nmap: unbalanced brackets\n");
2056 if (*++cp2 ==
'0') {
2057 const char *cp3 =
name;
2063 else if (toks[toknum = *cp2 -
'1']) {
2064 const char *cp3 =
tp[toknum];
2066 while (cp3 != te[toknum]) {
2107 printf(
"CDUP command not recognized, trying XCUP\n");
2118 printf(
"restart: offset not specified\n");
2122 "execute get, put or append to initiate transfer");
2139 printf(
"Limit of 16 macros have already been defined\n");
2160 printf(
"Enter macro line by line, terminating it with a null line\n");
2171 while (tmp !=
macbuf+4096) {
2173 printf(
"macdef:end of file encountered\n");
2178 if ((*tmp =
c) ==
'\n') {
2184 if (*(tmp-1) ==
'\0') {
2197 printf(
"Macro not defined - 4k buffer exceeded\n");
2255 int yy, mo,
day, hour,
min, sec;
2257 &
day, &hour, &
min, &sec);
2259 printf(
"%s\t%02d/%02d/%04d %02d:%02d:%02d GMT\n",
argv[1],
2260 mo,
day, yy, hour,
min, sec);
2281 printf(
"Local file \"%s\" is newer than remote file \"%s\"\n",
char * strcat(char *DstString, const char *SrcString)
int strcmp(const char *String1, const char *String2)
char * strncat(char *DstString, const char *SrcString, ACPI_SIZE Count)
ACPI_SIZE strlen(const char *String)
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
char * strcpy(char *DstString, const char *SrcString)
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
void shell(int argc, const char *argv[])
void syst(int argc, const char *argv[])
void rmthelp(int argc, const char *argv[])
void setsunique(int argc, const char *argv[])
void quit(int argc, const char *argv[])
void setprompt(int argc, const char *argv[])
void setpassive(int argc, const char *argv[])
void setascii(int argc, const char *argv[])
void ls(int argc, const char *argv[])
void setnmap(int argc, const char *argv[])
void account(int argc, const char *argv[])
void pwd(int argc, const char *argv[])
void makedir(int argc, const char *argv[])
void do_chmod(int argc, const char *argv[])
void setstruct(int argc, const char *argv[])
void idle(int argc, const char *argv[])
void mput(int argc, const char *argv[])
void mdelete(int argc, const char *argv[])
int confirm(const char *cmd, const char *file)
void setverbose(int argc, const char *argv[])
void setport(int argc, const char *argv[])
void setform(int argc, const char *argv[])
void sethash(int argc, const char *argv[])
void cdup(int argc, const char *argv[])
int globulize(const char **cpp)
void renamefile(int argc, const char *argv[])
void setrunique(int argc, const char *argv[])
void user(int argc, const char *argv[])
const char * dotrans(const char *name)
void get(int argc, const char *argv[])
void mls(int argc, const char *argv[])
void mget(int argc, const char *argv[])
void fsetmode(int argc, const char *argv[])
void settype(int argc, const char *argv[])
const char * domap(const char *name)
void setglob(int argc, const char *argv[])
void modtime(int argc, const char *argv[])
void newer(int argc, const char *argv[])
void doproxy(int argc, const char *argv[])
void setcr(int argc, const char *argv[])
static const char * onoff(int bool)
void setdebug(int argc, const char *argv[])
void do_umask(int argc, const char *argv[])
void settenex(int argc, const char *argv[])
void rmtstatus(int argc, const char *argv[])
void reget(int argc, const char *argv[])
void setbell(int argc, const char *argv[])
void macdef(int argc, const char *argv[])
void setbinary(int argc, const char *argv[])
void sizecmd(int argc, const char *argv[])
void removedir(int argc, const char *argv[])
void settrace(int argc, const char *argv[])
void setcase(int argc, const char *argv[])
int getit(int argc, const char *argv[], int restartit, const char *mode)
void disconnect(int argc, const char *argv[])
void restart(int argc, const char *argv[])
static const char * remglob(const char *argv[], int doswitch)
void setntrans(int argc, const char *argv[])
void setpeer(int argc, const char *argv[])
char * hookup(const char *host, int port)
void sendrequest(const char *cmd, const char *local, const char *remote, int printnames)
int login(const char *host)
int getreply(int expecteof)
void recvrequest(const char *cmd, const char *local, const char *remote, const char *mode, int printnames)
struct cmd * getcmd(const char *name)
static CHAR AppName[MAX_PATH]
_Check_return_ _Ret_opt_z_ _CRTIMP char *__cdecl getcwd(_Out_writes_opt_(_SizeInBytes) char *_DstBuf, _In_ int _SizeInBytes)
static const WCHAR quote[]
static DOUBLE day(DOUBLE time)
static const WCHAR CmdLine[]
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
char ** glob(const char *v)
char * getpass(const char *prompt)
GLuint GLuint GLsizei GLenum type
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLenum GLuint GLenum GLsizei const GLchar * buf
GLsizeiptr const GLvoid GLenum usage
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
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_ _CRTIMP int __cdecl getchar(void)
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_CRTIMP char *__cdecl gets(char *_Buffer)
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
_Check_return_ long __cdecl atol(_In_z_ const char *_Str)
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
void ShellCmd(const int argc, const char **const argv, const CommandPtr cmdp, const ArgvInfoPtr aip)
static IActiveScriptSite * site
_CRTIMP char *__cdecl mktemp(_Inout_z_ char *_TemplateName)
_CRTIMP intptr_t __cdecl execl(_In_z_ const char *_Filename, _In_z_ const char *_ArgList,...)
_CRTIMP struct tm *__cdecl gmtime(const time_t *_Time)
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
#define GetEnvironmentVariable
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
void int int ULONGLONG int va_list * ap
void fatal(const char *msg)
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO