ReactOS  0.4.12-dev-18-gf469aca
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.

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

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
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
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
static char ** argv
Definition: ServiceArgs.c:11
char * getpass(const char *prompt)
Definition: fake.c:231
int command(const char *fmt,...)
Definition: ftp.c:266
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32

◆ blkfree()

void blkfree ( char **  av0)

Definition at line 28 of file fake.c.

Referenced by globulize(), and mput().

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

◆ 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 }
static int argc
Definition: ServiceArgs.c:12
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
_CRTIMP char *__cdecl gets(char *_Buffer)
Definition: file.c:3643
#define ERROR(err)
Definition: vbo_exec_api.c:413
static char ** argv
Definition: ServiceArgs.c:11
FILE * stdout
#define verbose
Definition: rosglue.h:36
Definition: parser.c:48
void makeargv(void)
Definition: main.c:384
const char * margv[20]
Definition: main.c:102
int margc
Definition: main.c:101
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
int command(const char *fmt,...)
Definition: ftp.c:266
#define printf
Definition: config.h:203

◆ 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 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
#define ERROR(err)
Definition: vbo_exec_api.c:413
FILE * stdout
#define verbose
Definition: rosglue.h:36
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
int command(const char *fmt,...)
Definition: ftp.c:266
#define printf
Definition: config.h:203

◆ cmdscanner()

void cmdscanner ( int  top)

Definition at line 302 of file main.c.

Referenced by main().

303 {
304  register struct cmd *c;
305 
306  if (!top)
307  (void) putchar('\n');
308  for (;;) {
309  (void) fflush(stdout);
310  if (fromatty) {
311  printf("ftp> ");
312  (void) fflush(stdout);
313  }
314  if (gets(line) == 0) {
315  if (feof(stdin) || ferror(stdin))
316  quit(0, NULL);
317  break;
318  }
319  if (line[0] == 0)
320  break;
321  makeargv();
322  if (margc == 0) {
323  continue;
324  }
325  c = getcmd(margv[0]);
326  if (c == (struct cmd *)-1) {
327  printf("?Ambiguous command\n");
328  continue;
329  }
330  if (c == 0) {
331  printf("?Invalid command\n");
332  continue;
333  }
334  if (c->c_conn && !connected) {
335  printf ("Not connected.\n");
336  continue;
337  }
338  (*c->c_handler)(margc, margv);
339  if (bell && c->c_bell)
340  (void) putchar('\007');
341  if (c->c_handler != help)
342  break;
343  }
344  (void) fflush(stdout);
345 // (void) signal(SIGINT, intr);
346 // (void) signal(SIGPIPE, lostpeer);
347 }
_Check_return_ _CRTIMP int __cdecl ferror(_In_ FILE *_File)
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
int bell
Definition: main.c:65
Definition: ftp_var.h:139
_CRTIMP char *__cdecl gets(char *_Buffer)
Definition: file.c:3643
void quit(int argc, const char *argv[])
Definition: cmds.c:1606
FILE * stdin
FILE * stdout
int fromatty
Definition: main.c:62
int putchar(int c)
Definition: crtsupp.c:12
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
void makeargv(void)
Definition: main.c:384
int margc
Definition: main.c:101
_Check_return_ _CRTIMP int __cdecl feof(_In_ FILE *_File)
char c_conn
Definition: ftp_var.h:143
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
int connected
Definition: main.c:61
char c_bell
Definition: ftp_var.h:142
#define c
Definition: ke_i.h:80
const char * margv[20]
Definition: main.c:102
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
struct cmd * getcmd(const char *name)
Definition: main.c:350
void help(int argc, const char *argv[])
Definition: main.c:526
void(* c_handler)(int argc, const char *argv[])
Definition: ftp_var.h:145
#define printf
Definition: config.h:203

◆ command()

int command ( const char fmt,
  ... 
)

Definition at line 266 of file ftp.c.

Referenced by account(), AtaCommand48(), AtapiStartIo__(), cd(), cdup(), dde_connect(), dde_execute(), delete(), disconnect(), do_chmod(), do_umask(), getit(), CQueryAssociations::GetString(), IdeSendCommand(), idle(), init_parser(), initconn(), InternetCheckConnectionW(), login(), makedir(), mdelete(), MiniportHandleInterrupt(), modtime(), MSI_ParseSQL(), on_commandstate_change(), CInternetToolbar::OnContextMenu(), POP3Transport_CallbackProcessUSERResp(), POP3Transport_CallbackSendUSERCmd(), POP3Transport_CommandDELE(), POP3Transport_CommandLIST(), POP3Transport_CommandPASS(), POP3Transport_CommandRETR(), POP3Transport_CommandTOP(), POP3Transport_CommandUIDL(), POP3Transport_CommandUSER(), processRegLines(), proxtrans(), pwd(), quote(), recvrequest(), register_verb(), removedir(), renamefile(), rmthelp(), rmtstatus(), SendCommand(), sendrequest(), setpeer(), settype(), site(), sizecmd(), syst(), test_notification_dbg(), UniataAhciSetupFIS_H2D(), UniataAhciSetupFIS_H2D_Direct(), and user().

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);
276  vfprintf(stdout, fmt, ap);
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);
291  vsprintf(buffer, fmt, ap);
292  va_end(ap);
293 //DLJ: to work through firewalls - send the command as a single message
294  strcat(buffer,"\r\n");
295  fprintfSocket(cout, buffer);
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 getreply(int expecteof)
Definition: ftp.c:314
int abrtflag
Definition: ftp.c:71
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint buffer
Definition: glext.h:5915
static void cmdabort(int sig)
Definition: ftp.c:254
#define SIGINT
Definition: signal.h:23
FILE * stdout
#define va_end(ap)
Definition: acmsvcex.h:90
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
char * va_list
Definition: acmsvcex.h:78
int signal
Definition: xcptfil.c:12
SOCKET cout
Definition: ftp.c:83
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
int __cdecl vsprintf(char *_Dest, const char *_Format, va_list _Args)
Definition: sprintf.c:733
#define va_start(ap, A)
Definition: acmsvcex.h:91
int cpend
Definition: main.c:103
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define debug(msg)
Definition: key_call.c:71
const char * fprintfSocket(int s, const char *format,...)
Definition: fake.c:114
#define SIG_IGN
Definition: signal.h:48
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
Definition: dsound.c:943
#define printf
Definition: config.h:203
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29

◆ confirm()

int confirm ( const char cmd,
const char file 
)

Definition at line 1636 of file cmds.c.

Referenced by getit(), ls(), mdelete(), mget(), mls(), mput(), and CZipExtract::CConfirmReplace::ShowDlg().

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 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
Definition: ftp_var.h:139
_CRTIMP char *__cdecl gets(char *_Buffer)
Definition: file.c:3643
#define BUFSIZ
Definition: nsplookup.c:26
#define interactive
Definition: rosglue.h:34
FILE * stdout
Definition: parser.c:48
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
#define printf
Definition: config.h:203
Definition: fci.c:126

◆ 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 }
static int argc
Definition: ServiceArgs.c:12
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
_CRTIMP char *__cdecl gets(char *_Buffer)
Definition: file.c:3643
static char ** argv
Definition: ServiceArgs.c:11
FILE * stdout
Definition: parser.c:48
void makeargv(void)
Definition: main.c:384
const char * margv[20]
Definition: main.c:102
int margc
Definition: main.c:101
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
int command(const char *fmt,...)
Definition: ftp.c:266
#define printf
Definition: config.h:203

◆ disconnect()

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

Definition at line 1620 of file cmds.c.

Referenced by quit().

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
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
#define cout
Definition: iostream.cpp:38
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
int connected
Definition: main.c:61
int command(const char *fmt,...)
Definition: ftp.c:266
int macnum
Definition: main.c:108
UINT_PTR SOCKET
Definition: winsock.h:47

◆ 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 }
static int argc
Definition: ServiceArgs.c:12
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
_CRTIMP char *__cdecl gets(char *_Buffer)
Definition: file.c:3643
static char ** argv
Definition: ServiceArgs.c:11
FILE * stdout
Definition: parser.c:48
void makeargv(void)
Definition: main.c:384
const char * margv[20]
Definition: main.c:102
int margc
Definition: main.c:101
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
int command(const char *fmt,...)
Definition: ftp.c:266
#define printf
Definition: config.h:203

◆ 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 }
static int argc
Definition: ServiceArgs.c:12
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
static char ** argv
Definition: ServiceArgs.c:11
#define verbose
Definition: rosglue.h:36
int command(const char *fmt,...)
Definition: ftp.c:266

◆ domacro()

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

Definition at line 26 of file domacro.c.

Referenced by login().

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) ");
38  (void) fflush(stdout);
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]);
46  (void) fflush(stdout);
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]);
57  (void) fflush(stdout);
58  code = -1;
59  return;
60  }
61  (void) strcpy(line2, line);
62 TOP:
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 }
static int argc
Definition: ServiceArgs.c:12
#define isspace(c)
Definition: acclib.h:69
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint 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 GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
Definition: ftp_var.h:139
_CRTIMP char *__cdecl gets(char *_Buffer)
Definition: file.c:3643
GLuint GLuint GLsizei count
Definition: gl.h:1545
static char ** argv
Definition: ServiceArgs.c:11
FILE * stdout
#define verbose
Definition: rosglue.h:36
GLenum GLclampf GLint i
Definition: glfuncs.h:14
int putchar(int c)
Definition: crtsupp.c:12
Definition: parser.c:48
#define isdigit(c)
Definition: acclib.h:68
void makeargv(void)
Definition: main.c:384
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
const char * margv[20]
Definition: main.c:102
int margc
Definition: main.c:101
char line[200]
Definition: main.c:97
int connected
Definition: main.c:61
char c_conn
Definition: ftp_var.h:143
int bell
Definition: main.c:65
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
struct macel macros[16]
Definition: main.c:109
int macnum
Definition: main.c:108
char c_bell
Definition: ftp_var.h:142
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define c
Definition: ke_i.h:80
struct cmd * getcmd(const char *name)
Definition: main.c:350
void(* c_handler)(int argc, const char *argv[])
Definition: ftp_var.h:145
#define printf
Definition: config.h:203

◆ 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 }
static int argc
Definition: ServiceArgs.c:12
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
Definition: ftp_var.h:139
_CRTIMP char *__cdecl gets(char *_Buffer)
Definition: file.c:3643
static char ** argv
Definition: ServiceArgs.c:11
FILE * stdout
char c_proxy
Definition: ftp_var.h:144
Definition: parser.c:48
void makeargv(void)
Definition: main.c:384
int proxflag
Definition: main.c:69
jmp_buf abortprox
Definition: cmds.c:1712
const char * margv[20]
Definition: main.c:102
int margc
Definition: main.c:101
int connected
Definition: main.c:61
char c_conn
Definition: ftp_var.h:143
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
#define setjmp
Definition: setjmp.h:183
void pswitch(int flag)
Definition: ftp.c:1310
#define c
Definition: ke_i.h:80
long jmp_buf[100]
Definition: of.h:11
struct cmd * getcmd(const char *name)
Definition: main.c:350
void(* c_handler)(int argc, const char *argv[])
Definition: ftp_var.h:145
#define printf
Definition: config.h:203

◆ fgetcSocket()

int fgetcSocket ( int  s)

Definition at line 89 of file fake.c.

Referenced by getreply(), herror(), and recvrequest().

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 }
#define SOCKET_ERROR
Definition: winsock.h:333
GLuint buffer
Definition: glext.h:5915
#define ERROR(err)
Definition: vbo_exec_api.c:413
GLuint index
Definition: glext.h:6031
GLdouble s
Definition: gl.h:2039
#define EOF
Definition: stdio.h:24
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23

◆ 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 SOCKET_ERROR
Definition: winsock.h:333
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define MAX_ASCII
Definition: fake.c:5
int checkRecv(SOCKET s)
Definition: fake.c:9
smooth NULL
Definition: ftsmooth.c:416
GLdouble s
Definition: gl.h:2039
char string[160]
Definition: util.h:11
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23
#define printf
Definition: config.h:203

◆ fprintfSocket()

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

Definition at line 114 of file fake.c.

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

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 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLuint buffer
Definition: glext.h:5915
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define va_end(ap)
Definition: acmsvcex.h:90
smooth NULL
Definition: ftsmooth.c:416
char * va_list
Definition: acmsvcex.h:78
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
GLdouble s
Definition: gl.h:2039
int __cdecl vsprintf(char *_Dest, const char *_Format, va_list _Args)
Definition: sprintf.c:733
#define va_start(ap, A)
Definition: acmsvcex.h:91

◆ 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 }
#define SOCKET_ERROR
Definition: winsock.h:333
GLuint buffer
Definition: glext.h:5915
FILE * stdout
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
GLdouble s
Definition: gl.h:2039

◆ fputSocket()

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

Definition at line 151 of file fake.c.

Referenced by sendrequest().

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 }
#define SOCKET_ERROR
Definition: winsock.h:333
GLuint buffer
Definition: glext.h:5915
FILE * stdout
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039

◆ 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 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
smooth NULL
Definition: ftsmooth.c:416
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
GLdouble s
Definition: gl.h:2039

◆ 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 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
FILE * stdout
char modename[32]
Definition: main.c:90
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
#define printf
Definition: config.h:203

◆ 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 }
static int argc
Definition: ServiceArgs.c:12
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
off_t restart_point
Definition: ftp.c:81
static char ** argv
Definition: ServiceArgs.c:11
int getit(int argc, const char *argv[], int restartit, const char *mode)
Definition: cmds.c:488

◆ getcmd()

struct cmd* getcmd ( const char name)

Definition at line 350 of file main.c.

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

351 {
352  extern struct cmd cmdtab[];
353  const char *p, *q;
354  struct cmd *c, *found;
355  int nmatches, longest;
356 
357  longest = 0;
358  nmatches = 0;
359  found = 0;
360  for (c = cmdtab; (p = c->c_name); c++) {
361  for (q = name; *q == *p++; q++)
362  if (*q == 0) /* exact match? */
363  return (c);
364  if (!*q) { /* the name was a prefix */
365  if (q - name > longest) {
366  longest = q - name;
367  nmatches = 1;
368  found = c;
369  } else if (q - name == longest)
370  nmatches++;
371  }
372  }
373  if (nmatches > 1)
374  return ((struct cmd *)-1);
375  return (found);
376 }
Definition: ftp_var.h:139
const char * name
Definition: main.c:224
struct cmd cmdtab[]
Definition: cmdtab.c:95
const char * c_name
Definition: ftp_var.h:140
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
Definition: name.c:36
#define c
Definition: ke_i.h:80
GLfloat GLfloat p
Definition: glext.h:8902

◆ getit()

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

Definition at line 488 of file cmds.c.

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

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) {
508 usage:
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 }
static int argc
Definition: ServiceArgs.c:12
int tm_min
Definition: time.h:78
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
int ntflag
Definition: main.c:73
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
off_t restart_point
Definition: ftp.c:81
void recvrequest(const char *cmd, const char *local, const char *remote, const char *mode, int printnames)
Definition: ftp.c:717
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
_CRTIMP char *__cdecl gets(char *_Buffer)
Definition: file.c:3643
static DOUBLE day(DOUBLE time)
Definition: date.c:115
int tm_mday
Definition: time.h:80
#define COMPLETE
Definition: main.h:128
_In_ UINT64 _In_ UINT64 _In_ UINT64 _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2630
int tm_year
Definition: time.h:82
static char ** argv
Definition: ServiceArgs.c:11
FILE * stdout
#define verbose
Definition: rosglue.h:36
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
const char * dotrans(const char *name)
Definition: cmds.c:1838
const char * domap(const char *name)
Definition: cmds.c:1914
Definition: parser.c:48
int mcase
Definition: main.c:72
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
int tm_mon
Definition: time.h:81
void makeargv(void)
Definition: main.c:384
#define isupper(c)
Definition: acclib.h:71
const char * margv[20]
Definition: main.c:102
int margc
Definition: main.c:101
int ret
int globulize(const char **cpp)
Definition: cmds.c:1663
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
Definition: stat.h:55
#define MAXPATHLEN
Definition: ftp_var.h:35
Definition: time.h:76
#define islower(c)
Definition: acclib.h:72
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
char reply_string[]
Definition: ftp.c:309
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
#define min(a, b)
Definition: monoChain.cc:55
int mapflag
Definition: main.c:74
int tm_sec
Definition: time.h:77
int command(const char *fmt,...)
Definition: ftp.c:266
int tm_hour
Definition: time.h:79
#define debug(msg)
Definition: key_call.c:71
_CRTIMP struct tm *__cdecl gmtime(const time_t *_Time)
Definition: time.h:425
#define printf
Definition: config.h:203

◆ getpass()

char* getpass ( const char prompt)

Definition at line 231 of file fake.c.

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

232 {
233  static char input[256];
234  HANDLE in;
235  HANDLE err;
236  DWORD count;
237 
240 
241  if (in == INVALID_HANDLE_VALUE || err == INVALID_HANDLE_VALUE)
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 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLuint GLuint GLsizei count
Definition: gl.h:1545
BOOL WINAPI GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode)
Definition: console.c:1571
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
DWORD WINAPI GetFileType(HANDLE hFile)
Definition: fileinfo.c:419
#define FILE_TYPE_CHAR
Definition: winbase.h:257
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode)
Definition: console.c:1608
smooth NULL
Definition: ftsmooth.c:416
#define STD_INPUT_HANDLE
Definition: winbase.h:264
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define STD_ERROR_HANDLE
Definition: winbase.h:266
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ENABLE_LINE_INPUT
Definition: wincon.h:76
#define err(...)
GLfloat CONST GLvector4f * in
Definition: m_xform.h:122
#define ENABLE_PROCESSED_INPUT
Definition: wincon.h:75
GLenum GLenum GLenum input
Definition: glext.h:9031
unsigned char dummy
Definition: maze.c:118
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123

◆ getreply()

int getreply ( int  expecteof)

Definition at line 314 of file ftp.c.

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

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;
328  cp = reply_string;
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 }
int abrtflag
Definition: ftp.c:71
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
sig_t lostpeer()
Definition: main.c:254
#define pt(x, y)
Definition: drawing.c:79
#define DONT
Definition: ftp_var.h:14
#define WILL
Definition: ftp_var.h:17
static void cmdabort(int sig)
Definition: ftp.c:254
#define SIGINT
Definition: signal.h:23
FILE * stdout
#define DO
Definition: ftp_var.h:15
#define verbose
Definition: rosglue.h:36
GLuint n
Definition: s_context.h:57
int putchar(int c)
Definition: crtsupp.c:12
char reply_string[BUFSIZ]
Definition: ftp.c:309
char pasv[64]
Definition: main.c:77
#define isdigit(c)
Definition: acclib.h:68
int proxflag
Definition: main.c:69
SOCKET cin
Definition: ftp.c:83
int fgetcSocket(int s)
Definition: fake.c:89
int signal
Definition: xcptfil.c:12
int code
Definition: i386-dis.c:3591
SOCKET cout
Definition: ftp.c:83
char * hostname
Definition: ftp.c:88
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
int cpend
Definition: main.c:103
#define IAC
Definition: ftp_var.h:13
#define EOF
Definition: stdio.h:24
POINT cp
Definition: magnifier.c:60
#define c
Definition: ke_i.h:80
#define WONT
Definition: ftp_var.h:16
const char * fprintfSocket(int s, const char *format,...)
Definition: fake.c:114
#define SIG_IGN
Definition: signal.h:48
#define printf
Definition: config.h:203
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29

◆ glob()

◆ globulize()

int globulize ( const char **  cpp)

Definition at line 1663 of file cmds.c.

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

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 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
int doglob
Definition: main.c:66
#define free
Definition: debug_ros.c:5
void blkfree(char **av0)
Definition: fake.c:28
char * globerr
Definition: main.c:48
FILE * stdout
smooth NULL
Definition: ftsmooth.c:416
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
char ** glob(const char *v)
Definition: fake.c:36
#define printf
Definition: config.h:203

◆ help()

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

Definition at line 526 of file main.c.

Referenced by cmdscanner().

527 {
528  extern struct cmd cmdtab[];
529  struct cmd *c;
530 
531  if (argc == 1) {
532  register int i, j, w, k;
533  int columns, width = 0, lines;
534  extern int NCMDS;
535 
536  printf("Commands may be abbreviated. Commands are:\n\n");
537  for (c = cmdtab; c < &cmdtab[NCMDS]; c++) {
538  int len = strlen(c->c_name);
539 
540  if (len > width)
541  width = len;
542  }
543  width = (width + 8) &~ 7;
544  columns = 80 / width;
545  if (columns == 0)
546  columns = 1;
547  lines = (NCMDS + columns - 1) / columns;
548  for (i = 0; i < lines; i++) {
549  for (j = 0; j < columns; j++) {
550  c = cmdtab + j * lines + i;
551  if (c->c_name && (!proxy || c->c_proxy)) {
552  printf("%s", c->c_name);
553  }
554  else if (c->c_name) {
555  for (k=0; k < (int) strlen(c->c_name); k++) {
556  (void) putchar(' ');
557  }
558  }
559  if (c + lines >= &cmdtab[NCMDS]) {
560  printf("\n");
561  break;
562  }
563  w = strlen(c->c_name);
564  while (w < width) {
565  w = (w + 8) &~ 7;
566  (void) putchar('\t');
567  }
568  }
569  }
570  (void) fflush(stdout);
571  return;
572  }
573  while (--argc > 0) {
574  const char *arg;
575  arg = *++argv;
576  c = getcmd(arg);
577  if (c == (struct cmd *)-1)
578  printf("?Ambiguous help command %s\n", arg);
579  else if (c == (struct cmd *)0)
580  printf("?Invalid help command %s\n", arg);
581  else
582  printf("%-*s\t%s\n", (int)HELPINDENT,
583  c->c_name, c->c_help);
584  }
585  (void) fflush(stdout);
586 }
static int argc
Definition: ServiceArgs.c:12
GLint GLint GLsizei width
Definition: gl.h:1546
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint 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 GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
Definition: ftp_var.h:139
void * arg
Definition: msvc.h:12
struct cmd cmdtab[]
Definition: cmdtab.c:95
static char ** argv
Definition: ServiceArgs.c:11
FILE * stdout
char c_proxy
Definition: ftp_var.h:144
GLenum GLclampf GLint i
Definition: glfuncs.h:14
int NCMDS
Definition: cmdtab.c:171
int putchar(int c)
Definition: crtsupp.c:12
const char * c_name
Definition: ftp_var.h:140
GLenum GLsizei len
Definition: glext.h:6722
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
const char * c_help
Definition: ftp_var.h:141
#define c
Definition: ke_i.h:80
#define HELPINDENT
Definition: main.c:520
struct cmd * getcmd(const char *name)
Definition: main.c:350
int proxy
Definition: main.c:67
int k
Definition: mpi.c:3369
#define printf
Definition: config.h:203
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29

◆ herror()

int herror ( char s)

Definition at line 46 of file fake.c.

Referenced by hookup().

47 {
48  return 0;
49 }

◆ hookup()

char* hookup ( const char host,
int  port 
)

Definition at line 96 of file ftp.c.

Referenced by setpeer().

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 */
168  closesocket(cin);
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);
184 bad:
185  (void) close(s);
186  return ((char *)0);
187 }
int getreply(int expecteof)
Definition: ftp.c:314
char ** h_addr_list
Definition: winsock.h:138
struct sockaddr_in hisctladdr
Definition: ftp.c:68
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
#define inet_addr(cp)
Definition: inet.h:98
char * h_name
Definition: winsock.h:134
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
#define SO_OOBINLINE
Definition: winsock.h:186
char * host
Definition: whois.c:55
int errno
#define SOL_SOCKET
Definition: winsock.h:398
char * caddr_t
Definition: rosdhcp.h:36
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
FILE * stdout
#define verbose
Definition: rosglue.h:36
#define closesocket
Definition: main.c:39
_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,...)
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
Definition: sockctrl.c:421
short h_length
Definition: winsock.h:137
smooth NULL
Definition: ftsmooth.c:416
#define inet_ntoa(addr)
Definition: inet.h:100
PHOSTENT WSAAPI gethostbyname(IN const char FAR *name)
Definition: getxbyxx.c:221
#define INVALID_SOCKET
Definition: winsock.h:332
SOCKET cin
Definition: ftp.c:83
#define bcopy(s1, s2, n)
Definition: various.h:25
int herror(char *string)
Definition: fake.c:46
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039
#define close
Definition: acwin.h:74
SOCKET cout
Definition: ftp.c:83
short h_addrtype
Definition: winsock.h:136
char * hostname
Definition: ftp.c:88
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
#define bzero(s, n)
Definition: various.h:27
FILE * stderr
#define AF_INET
Definition: tcpip.h:117
#define debug(msg)
Definition: key_call.c:71
UINT_PTR SOCKET
Definition: winsock.h:47
struct sockaddr_in myctladdr
Definition: ftp.c:74
#define SOCK_STREAM
Definition: tcpip.h:118
USHORT port
Definition: uri.c:227
INT WSAAPI getsockname(IN SOCKET s, OUT LPSOCKADDR name, IN OUT INT FAR *namelen)
Definition: sockctrl.c:213
#define printf
Definition: config.h:203

◆ 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 }
static int argc
Definition: ServiceArgs.c:12
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
static char ** argv
Definition: ServiceArgs.c:11
#define verbose
Definition: rosglue.h:36
int command(const char *fmt,...)
Definition: ftp.c:266

◆ initconn()

int initconn ( void  )

Definition at line 1125 of file ftp.c.

Referenced by recvrequest(), and sendrequest().

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) {
1134  data = socket(AF_INET, SOCK_STREAM, 0);
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 
1182 noport:
1183  data_addr = myctladdr;
1184  if (sendport)
1185  data_addr.sin_port = 0; /* let system pick one */
1186  if (data != -1)
1187  (void) close (data);
1188  data = socket(AF_INET, SOCK_STREAM, 0);
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);
1232 bad:
1233  (void) fflush(stdout);
1234  (void) close(data), data = -1;
1235  if (tmpno)
1236  sendport = 1;
1237  return (1);
1238 }
static const struct update_accum a3
Definition: msg.c:600
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: socklife.c:36
#define COMPLETE
Definition: main.h:128
#define ERROR(err)
Definition: vbo_exec_api.c:413
#define SOL_SOCKET
Definition: winsock.h:398
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
FILE * stdout
struct sockaddr_in data_addr
Definition: ftp.c:69
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
#define a
Definition: ke_i.h:78
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
Definition: sockctrl.c:421
const GLfloat * p0
Definition: s_aatritemp.h:42
#define SO_REUSEADDR
Definition: winsock.h:180
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
char pasv[64]
Definition: main.c:77
static const struct update_accum a2
Definition: msg.c:586
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum GLsizei len
Definition: glext.h:6722
int sendport
Definition: main.c:117
#define close
Definition: acwin.h:74
int passivemode
Definition: main.c:68
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
Definition: sockctrl.c:123
int command(const char *fmt,...)
Definition: ftp.c:266
#define UC(b)
#define bzero(s, n)
Definition: various.h:27
#define AF_INET
Definition: tcpip.h:117
static const struct update_accum a1
Definition: msg.c:578
struct sockaddr_in myctladdr
Definition: ftp.c:74
#define SOCK_STREAM
Definition: tcpip.h:118
GLfloat GLfloat p
Definition: glext.h:8902
const GLfloat * p1
Definition: s_aatritemp.h:43
GLuint64EXT * result
Definition: glext.h:11304
INT WSAAPI getsockname(IN SOCKET s, OUT LPSOCKADDR name, IN OUT INT FAR *namelen)
Definition: sockctrl.c:213
#define printf
Definition: config.h:203
#define SO_DEBUG
Definition: winsock.h:178

◆ 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 }
static int argc
Definition: ServiceArgs.c:12
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static char ** argv
Definition: ServiceArgs.c:11
FILE * stdout
#define chdir
Definition: syshdrs.h:69
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
char home[]
Definition: main.c:47
int globulize(const char **cpp)
Definition: cmds.c:1663
#define MAXPATHLEN
Definition: ftp_var.h:35
_Check_return_ _Ret_opt_z_ _CRTIMP char *__cdecl getcwd(_Out_writes_opt_(_SizeInBytes) char *_DstBuf, _In_ int _SizeInBytes)
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
#define printf
Definition: config.h:203

◆ login()

int login ( const char host)

Definition at line 189 of file ftp.c.

Referenced by setpeer().

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();
246  domacro(margc, margv);
247  break;
248  }
249  }
250  return (1);
251 }
int proxy
Definition: main.c:67
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * host
Definition: whois.c:55
FILE * stdin
#define COMPLETE
Definition: main.h:128
int ruserpass(const char *host, char **aname, char **apass, char **aacct)
Definition: ruserpass.c:58
FILE * stdout
GLuint n
Definition: s_context.h:57
pass
Definition: typegen.h:24
char * getpass(const char *prompt)
Definition: fake.c:231
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
void makeargv(void)
Definition: main.c:384
const char * margv[20]
Definition: main.c:102
int margc
Definition: main.c:101
#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)
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
struct macel macros[16]
Definition: main.c:109
void domacro(int argc, const char *argv[])
Definition: domacro.c:26
int command(const char *fmt,...)
Definition: ftp.c:266
int macnum
Definition: main.c:108
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
FILE * stderr
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
void user(int argc, const char *argv[])
Definition: cmds.c:1350
#define printf
Definition: config.h:203

◆ ls()

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

Definition at line 1136 of file cmds.c.

Referenced by create_file_with_version(), GSUB_apply_LigatureSubst(), init_test(), ME_GetParaLineSpace(), and msi_compare_file_versions().

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 }
static int argc
Definition: ServiceArgs.c:12
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
void recvrequest(const char *cmd, const char *local, const char *remote, const char *mode, int printnames)
Definition: ftp.c:717
char * cmd
Definition: vfdcmd.c:85
static char ** argv
Definition: ServiceArgs.c:11
FILE * stdout
smooth NULL
Definition: ftsmooth.c:416
int globulize(const char **cpp)
Definition: cmds.c:1663
int confirm(const char *cmd, const char *file)
Definition: cmds.c:1636
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define printf
Definition: config.h:203

◆ 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 }
static int argc
Definition: ServiceArgs.c:12
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
_CRTIMP char *__cdecl gets(char *_Buffer)
Definition: file.c:3643
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
#define interactive
Definition: rosglue.h:34
static char ** argv
Definition: ServiceArgs.c:11
FILE * stdout
Definition: parser.c:48
void makeargv(void)
Definition: main.c:384
const char * margv[20]
Definition: main.c:102
int margc
Definition: main.c:101
_Check_return_ _CRTIMP int __cdecl getchar(void)
Definition: file.c:3627
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
struct macel macros[16]
Definition: main.c:109
#define EOF
Definition: stdio.h:24
int macnum
Definition: main.c:108
#define c
Definition: ke_i.h:80
char macbuf[4096]
Definition: main.c:110
#define printf
Definition: config.h:203

◆ makeargv()

void makeargv ( void  )

Definition at line 384 of file main.c.

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().

385 {
386  const char **argp;
387 
388  margc = 0;
389  argp = margv;
390  stringbase = line; /* scan from first of buffer */
391  argbase = argbuf; /* store from first of buffer */
392  slrflag = 0;
393  while ((*argp++ = slurpstring()))
394  margc++;
395 }
char argbuf[200]
Definition: main.c:99
static const char * slurpstring()
Definition: main.c:403
char * stringbase
Definition: main.c:98
char * argbase
Definition: main.c:100
char line[200]
Definition: main.c:97
int margc
Definition: main.c:101
int slrflag
Definition: main.c:382
const char * margv[20]
Definition: main.c:102

◆ 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 }
static int argc
Definition: ServiceArgs.c:12
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
_CRTIMP char *__cdecl gets(char *_Buffer)
Definition: file.c:3643
#define ERROR(err)
Definition: vbo_exec_api.c:413
static char ** argv
Definition: ServiceArgs.c:11
FILE * stdout
#define verbose
Definition: rosglue.h:36
Definition: parser.c:48
void makeargv(void)
Definition: main.c:384
const char * margv[20]
Definition: main.c:102
int margc
Definition: main.c:101
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
int command(const char *fmt,...)
Definition: ftp.c:266
#define printf
Definition: config.h:203

◆ 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 }
static int argc
Definition: ServiceArgs.c:12
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
_CRTIMP char *__cdecl gets(char *_Buffer)
Definition: file.c:3643
#define interactive
Definition: rosglue.h:34
int mflag
Definition: finger.c:66
static char ** argv
Definition: ServiceArgs.c:11
FILE * stdout
const char * mname
Definition: cmds.c:37
int fromatty
Definition: main.c:62
static const char * remglob(const char *argv[], int doswitch)
Definition: cmds.c:715
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
void makeargv(void)
Definition: main.c:384
jmp_buf jabort
Definition: cmds.c:38
const char * margv[20]
Definition: main.c:102
int margc
Definition: main.c:101
int confirm(const char *cmd, const char *file)
Definition: cmds.c:1636
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
#define setjmp
Definition: setjmp.h:183
int command(const char *fmt,...)
Definition: ftp.c:266
POINT cp
Definition: magnifier.c:60
long jmp_buf[100]
Definition: of.h:11
#define printf
Definition: config.h:203

◆ 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 }
static int argc
Definition: ServiceArgs.c:12
int proxy
Definition: main.c:67
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
int ntflag
Definition: main.c:73
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
void recvrequest(const char *cmd, const char *local, const char *remote, const char *mode, int printnames)
Definition: ftp.c:717
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
_CRTIMP char *__cdecl gets(char *_Buffer)
Definition: file.c:3643
#define interactive
Definition: rosglue.h:34
_In_ UINT64 _In_ UINT64 _In_ UINT64 _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2630
int mflag
Definition: finger.c:66
static char ** argv
Definition: ServiceArgs.c:11
FILE * stdout
const char * mname
Definition: cmds.c:37
int fromatty
Definition: main.c:62
static const char * remglob(const char *argv[], int doswitch)
Definition: cmds.c:715
const char * dotrans(const char *name)
Definition: cmds.c:1838
smooth NULL
Definition: ftsmooth.c:416
const char * domap(const char *name)
Definition: cmds.c:1914
Definition: parser.c:48
int mcase
Definition: main.c:72
void makeargv(void)
Definition: main.c:384
jmp_buf jabort
Definition: cmds.c:38
#define isupper(c)
Definition: acclib.h:71
const char * margv[20]
Definition: main.c:102
int margc
Definition: main.c:101
#define MAXPATHLEN
Definition: ftp_var.h:35
#define islower(c)
Definition: acclib.h:72
int confirm(const char *cmd, const char *file)
Definition: cmds.c:1636
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
#define setjmp
Definition: setjmp.h:183
int mapflag
Definition: main.c:74
POINT cp
Definition: magnifier.c:60
long jmp_buf[100]
Definition: of.h:11
#define printf
Definition: config.h:203

◆ 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 int argc
Definition: ServiceArgs.c:12
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
void recvrequest(const char *cmd, const char *local, const char *remote, const char *mode, int printnames)
Definition: ftp.c:717
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
_CRTIMP char *__cdecl gets(char *_Buffer)
Definition: file.c:3643
char * cmd
Definition: vfdcmd.c:85
#define interactive
Definition: rosglue.h:34
int mflag
Definition: finger.c:66
static char ** argv
Definition: ServiceArgs.c:11
FILE * stdout
const char * mname
Definition: cmds.c:37
GLenum GLclampf GLint i
Definition: glfuncs.h:14
int fromatty
Definition: main.c:62
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
void makeargv(void)
Definition: main.c:384
jmp_buf jabort
Definition: cmds.c:38
GLfloat CONST GLvector4f CONST GLfloat GLvector4f * dest
Definition: m_xform.h:122
const char * margv[20]
Definition: main.c:102
int margc
Definition: main.c:101
int globulize(const char **cpp)
Definition: cmds.c:1663
int confirm(const char *cmd, const char *file)
Definition: cmds.c:1636
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
#define setjmp
Definition: setjmp.h:183
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
long jmp_buf[100]
Definition: of.h:11
#define printf
Definition: config.h:203

◆ modtime()

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

Definition at line 2232 of file cmds.c.

Referenced by FTPUtime().

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 }
static int argc
Definition: ServiceArgs.c:12
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
_CRTIMP char *__cdecl gets(char *_Buffer)
Definition: file.c:3643
static DOUBLE day(DOUBLE time)
Definition: date.c:115
#define COMPLETE
Definition: main.h:128
static char ** argv
Definition: ServiceArgs.c:11
FILE * stdout
#define verbose
Definition: rosglue.h:36
Definition: parser.c:48
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
void makeargv(void)
Definition: main.c:384
const char * margv[20]
Definition: main.c:102
int margc
Definition: main.c:101
char reply_string[]
Definition: ftp.c:309
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
#define min(a, b)
Definition: monoChain.cc:55
int command(const char *fmt,...)
Definition: ftp.c:266
#define debug(msg)
Definition: key_call.c:71
#define printf
Definition: config.h:203

◆ 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 }
static int argc
Definition: ServiceArgs.c:12
int sunique
Definition: main.c:70
int proxy
Definition: main.c:67
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
int ntflag
Definition: main.c:73
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
int doglob
Definition: main.c:66
_CRTIMP char *__cdecl gets(char *_Buffer)
Definition: file.c:3643
#define free
Definition: debug_ros.c:5
void blkfree(char **av0)
Definition: fake.c:28
char * globerr
Definition: main.c:48
#define interactive
Definition: rosglue.h:34
_In_ UINT64 _In_ UINT64 _In_ UINT64 _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2630
int mflag
Definition: finger.c:66
static char ** argv
Definition: ServiceArgs.c:11
FILE * stdout
const char * mname
Definition: cmds.c:37
GLenum GLclampf GLint i
Definition: glfuncs.h:14
int fromatty
Definition: main.c:62
static const char * remglob(const char *argv[], int doswitch)
Definition: cmds.c:715
const char * dotrans(const char *name)
Definition: cmds.c:1838
smooth NULL
Definition: ftsmooth.c:416
const char * domap(const char *name)
Definition: cmds.c:1914
Definition: parser.c:48
int mcase
Definition: main.c:72
void makeargv(void)
Definition: main.c:384
jmp_buf jabort
Definition: cmds.c:38
#define isupper(c)
Definition: acclib.h:71
const char * margv[20]
Definition: main.c:102
int margc
Definition: main.c:101
#define MAXPATHLEN
Definition: ftp_var.h:35
#define islower(c)
Definition: acclib.h:72
int confirm(const char *cmd, const char *file)
Definition: cmds.c:1636
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
char ** glob(const char *v)
Definition: fake.c:36
#define setjmp
Definition: setjmp.h:183
int mapflag
Definition: main.c:74
void sendrequest(const char *cmd, const char *local, const char *remote, int printnames)
Definition: ftp.c:443
POINT cp
Definition: magnifier.c:60
long jmp_buf[100]
Definition: of.h:11
#define printf
Definition: config.h:203

◆ newer()

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

Definition at line 2278 of file cmds.c.

Referenced by CertAddCRLContextToStore(), and CertAddCTLContextToStore().

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 }
static int argc
Definition: ServiceArgs.c:12
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
static char ** argv
Definition: ServiceArgs.c:11
FILE * stdout
int getit(int argc, const char *argv[], int restartit, const char *mode)
Definition: cmds.c:488
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
#define printf
Definition: config.h:203

◆ null()

int null ( void  )

Definition at line 1794 of file ftp.c.

Referenced by ImageAddCertificate(), main(), proxtrans(), recvrequest(), sendrequest(), SetupLogErrorA(), test_basics(), test_null_device(), and test_PropVariantCompare().

1795 {
1796  return 0;
1797 }

◆ 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.

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

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 }
int sunique
Definition: main.c:70
struct sockaddr_in hisctladdr
Definition: ftp.c:68
int proxy
Definition: main.c:67
int abrtflag
Definition: ftp.c:71
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
int ntflag
Definition: main.c:73
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static MONITORINFO mi
Definition: win.c:7331
void(* Sig_t)(int)
Definition: ftp.c:90
#define SIGINT
Definition: signal.h:23
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
UINT op
Definition: effect.c:223
int ip[4]
Definition: rtl.c:1176
int mcase
Definition: main.c:72
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint 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 GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean flag
Definition: glfuncs.h:72
SOCKET cin
Definition: ftp.c:83
static FILE * out
Definition: regtests2xml.c:44
int runique
Definition: main.c:71
void psabort(int sig)
Definition: ftp.c:1303
int signal
Definition: xcptfil.c:12
#define MAXPATHLEN
Definition: ftp_var.h:35
SOCKET cout
Definition: ftp.c:83
GLfloat CONST GLvector4f * in
Definition: m_xform.h:122
char * hostname
Definition: ftp.c:88
int connected
Definition: main.c:61
char ntin[17]
Definition: main.c:79
#define MAXHOSTNAMELEN
Definition: ftp.c:31
int cpend
Definition: main.c:103
int mapflag
Definition: main.c:74
Definition: name.c:36
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
char mapin[MAXPATHLEN]
Definition: main.c:82
UINT_PTR SOCKET
Definition: winsock.h:47
struct sockaddr_in myctladdr
Definition: ftp.c:74
char mapout[MAXPATHLEN]
Definition: main.c:83
char ntout[17]
Definition: main.c:80

◆ 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) {
300 usage:
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 }
static int argc
Definition: ServiceArgs.c:12
int sunique
Definition: main.c:70
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
int ntflag
Definition: main.c:73
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
_CRTIMP char *__cdecl gets(char *_Buffer)
Definition: file.c:3643
char * cmd
Definition: vfdcmd.c:85
static char ** argv
Definition: ServiceArgs.c:11
FILE * stdout
const char * dotrans(const char *name)
Definition: cmds.c:1838
const char * domap(const char *name)
Definition: cmds.c:1914
Definition: parser.c:48
void makeargv(void)
Definition: main.c:384
const char * margv[20]
Definition: main.c:102
int margc
Definition: main.c:101
int globulize(const char **cpp)
Definition: cmds.c:1663
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
int mapflag
Definition: main.c:74
void sendrequest(const char *cmd, const char *local, const char *remote, int printnames)
Definition: ftp.c:443
#define printf
Definition: config.h:203

◆ pwd()

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

Definition at line 1401 of file cmds.c.

Referenced by FTPChdir3(), GetContentsOfDialog(), GetContentsOfMenu(), InternetCrackUrlW_test(), mbedtls_pk_get_len(), MenuFill(), MenuScan(), netname2user(), and StrangeMenuFill().

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 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
#define ERROR(err)
Definition: vbo_exec_api.c:413
FILE * stdout
#define verbose
Definition: rosglue.h:36
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
int command(const char *fmt,...)
Definition: ftp.c:266
#define printf
Definition: config.h:203

◆ quit()

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

Definition at line 1606 of file cmds.c.

Referenced by cmdscanner(), FsRtlAddBaseMcbEntry(), FsRtlGetNextBaseMcbEntry(), FsRtlLookupBaseMcbEntry(), FsRtlRemoveBaseMcbEntry(), get_subtests(), main(), RestoreAllConnections(), and START_TEST().

1607 {
1608  if (connected)
1609  disconnect(0, NULL);
1610  pswitch(1);
1611  if (connected) {
1612  disconnect(0, NULL);
1613  }
1614  exit(0);
1615 }
smooth NULL
Definition: ftsmooth.c:416
int connected
Definition: main.c:61
void disconnect(int argc, const char *argv[])
Definition: cmds.c:1620
void pswitch(int flag)
Definition: ftp.c:1310
void exit(int exitcode)
Definition: _exit.c:33

◆ 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 }
static int argc
Definition: ServiceArgs.c:12
int getreply(int expecteof)
Definition: ftp.c:314
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
_CRTIMP char *__cdecl gets(char *_Buffer)
Definition: file.c:3643
#define BUFSIZ
Definition: nsplookup.c:26
static char ** argv
Definition: ServiceArgs.c:11
FILE * stdout
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define PRELIM
Definition: ftp_var.h:41
Definition: parser.c:48
void makeargv(void)
Definition: main.c:384
const char * margv[20]
Definition: main.c:102
int margc
Definition: main.c:101
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
int command(const char *fmt,...)
Definition: ftp.c:266
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define printf
Definition: config.h:203

◆ 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.

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

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)
761 null();// (void) signal(SIGINT, oldintr);
762  code = -1;
763  return;
764  }
765 null();// 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()) {
812 null();// (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) {
833 null();// (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) {
854 null();// (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 == '|') {
880 null();// 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;
948  n = restart_point;
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) {
957 done:
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  }
990 break2:
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);
1013 null();// (void) signal(SIGINT, oldintr);
1014  if (oldintp)
1015 null();// (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;
1043 abort:
1044 
1045 /* abort using RFC959 recommended IP,SYNC sequence */
1046 
1047  (void) gettimeofday(&stop, (struct timezone *)0);
1048  if (oldintp)
1049 null();// (void) signal(SIGPIPE, oldintr);
1050 null();// (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;
1069 null();// (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);
1121 null();// (void) signal(SIGINT,oldintr);
1122 }
Definition: winsock.h:66
void setbinary(int argc, const char *argv[])
Definition: cmds.c:202
int getreply(int expecteof)
Definition: ftp.c:314
_Check_return_ _CRTIMP int __cdecl ferror(_In_ FILE *_File)
int proxy
Definition: main.c:67
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
sig_t lostpeer()
Definition: main.c:254
Definition: netstat.c:29
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
Definition: ftp_var.h:139
int crflag
Definition: main.c:76
#define TYPE_E
Definition: ftp_var.h:38
void setascii(int argc, const char *argv[])
Definition: cmds.c:212
_Check_return_opt_ _CRTIMP int __cdecl _pclose(_Inout_ FILE *_File)
#define TYPE_L
Definition: ftp_var.h:39
_Check_return_ _CRTIMP FILE *__cdecl _popen(_In_z_ const char *_Command, _In_z_ const char *_Mode)
_Check_return_ _CRTIMP int __cdecl getc(_Inout_ FILE *_File)
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
_Check_return_opt_ _CRTIMP long __cdecl lseek(_In_ int _FileHandle, _In_ long _Offset, _In_ int _Origin)
#define SIGINT
Definition: signal.h:23
int errno
#define ERROR(err)
Definition: vbo_exec_api.c:413
#define FD_ZERO(set)
Definition: winsock.h:96
GLenum GLuint GLsizei bufsize
Definition: glext.h:7473
#define FD_SET(fd, set)
Definition: winsock.h:89
GLuint const GLubyte mask[]
Definition: s_context.h:57
#define L_INCR
Definition: ftp.c:23
FILE * stdout
void setebcdic()
Definition: cmds.c:232
#define HASHBYTES
Definition: ftp.c:441
#define verbose
Definition: rosglue.h:36
GLuint n
Definition: s_context.h:57
#define write
Definition: acwin.h:73
#define gettimeofday(tv, tz)
Definition: adns_win32.h:159
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define rindex(s, c)
Definition: various.h:30
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
#define closesocket
Definition: main.c:39
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
#define MSG_OOB
Definition: winsock.h:221
#define PRELIM
Definition: ftp_var.h:41
#define FD_ISSET(fd, set)
Definition: winsock.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
int allbinary
Definition: ftp.c:73
void proxtrans(char *cmd, char *local, char *remote) const
Definition: ftp.c:1418
int putchar(int c)
Definition: crtsupp.c:12
smooth NULL
Definition: ftsmooth.c:416
_Check_return_opt_ _CRTIMP int __cdecl fseek(_Inout_ FILE *_File, _In_ long _Offset, _In_ int _Origin)
unsigned char
Definition: typeof.h:27
unsigned int dir
Definition: maze.c:112
_Check_return_opt_ _CRTIMP int __cdecl putc(_In_ int _Ch, _Inout_ FILE *_File)
void ptransfer(char *direction, long bytes, struct timeval *t0, struct timeval *t1) const
Definition: ftp.c:1264
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
#define d
Definition: ke_i.h:81
SOCKET cin
Definition: ftp.c:83
_Check_return_ _CRTIMP int __cdecl fileno(_In_ FILE *_File)
int fgetcSocket(int s)
Definition: fake.c:89
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
_Check_return_ _CRTIMP int __cdecl chmod(_In_z_ const char *_Filename, _In_ int _AccessMode)
int runique
Definition: main.c:71
int null(void)
Definition: ftp.c:1794
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
Definition: arc.h:34
int signal
Definition: xcptfil.c:12
static const WCHAR L[]
Definition: oid.c:1087
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
#define close
Definition: acwin.h:74
SOCKET cout
Definition: ftp.c:83
#define CONTINUE
Definition: ftp_var.h:43
#define local
Definition: zutil.h:30
#define TYPE_I
Definition: ftp_var.h:37
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
GLuint start
Definition: gl.h:1545
#define abort()
Definition: i386-dis.c:35
Definition: arc.h:46
int cpend
Definition: main.c:103
#define setjmp
Definition: setjmp.h:183
jmp_buf recvabort
Definition: ftp.c:703
#define IAC
Definition: ftp_var.h:13
void settenex(int argc, const char *argv[])
Definition: