- {
- int res;
- if (i > bufsize - 1)
- *line = (char *)xrealloc (*line, (bufsize <<= 1));
- res = RBUF_READCHAR (rbuf, *line + i);
- /* RES is number of bytes read. */
- if (res == 1)
- {
- if ((*line)[i] == '\n')
- {
- (*line)[i] = '\0';
- /* Get rid of \r. */
- if (i > 0 && (*line)[i - 1] == '\r')
- (*line)[i - 1] = '\0';
- break;
- }
- }
- else
- return FTPRERR;
- }
+ {
+ int res;
+ if (i > bufsize - 1)
+ *line = (char *)xrealloc (*line, (bufsize <<= 1));
+ res = RBUF_READCHAR (rbuf, *line + i);
+ /* RES is number of bytes read. */
+ if (res == 1)
+ {
+ if ((*line)[i] == '\n')
+ {
+ (*line)[i] = '\0';
+ /* Get rid of \r. */
+ if (i > 0 && (*line)[i - 1] == '\r')
+ (*line)[i - 1] = '\0';
+ break;
+ }
+ }
+ else
+ return FTPRERR;
+ }
strncpy (ftp_last_respline, *line, sizeof (ftp_last_respline));
ftp_last_respline[sizeof (ftp_last_respline) - 1] = '\0';
return FTPOK;
strncpy (ftp_last_respline, *line, sizeof (ftp_last_respline));
ftp_last_respline[sizeof (ftp_last_respline) - 1] = '\0';
return FTPOK;
ftp_request (const char *command, const char *value)
{
char *res = (char *)xmalloc (strlen (command)
ftp_request (const char *command, const char *value)
{
char *res = (char *)xmalloc (strlen (command)
sprintf (res, "%s%s%s\r\n", command, value ? " " : "", value ? value : "");
if (opt.server_response)
{
/* Hack: don't print out password. */
if (strncmp (res, "PASS", 4) != 0)
sprintf (res, "%s%s%s\r\n", command, value ? " " : "", value ? value : "");
if (opt.server_response)
{
/* Hack: don't print out password. */
if (strncmp (res, "PASS", 4) != 0)
- const char *cp;
- int skey_sequence = 0;
-
- for (cp = respline + strlen (skey_head[i]);
- '0' <= *cp && *cp <= '9';
- cp++)
- {
- skey_sequence = skey_sequence * 10 + *cp - '0';
- }
- if (*cp == ' ')
- cp++;
- else
- {
- bad:
- xfree (respline);
- return FTPLOGREFUSED;
- }
- if ((cp = calculate_skey_response (skey_sequence, cp, pass)) == 0)
- goto bad;
- pass = cp;
+ const char *cp;
+ int skey_sequence = 0;
+
+ for (cp = respline + strlen (skey_head[i]);
+ '0' <= *cp && *cp <= '9';
+ cp++)
+ {
+ skey_sequence = skey_sequence * 10 + *cp - '0';
+ }
+ if (*cp == ' ')
+ cp++;
+ else
+ {
+ bad:
+ xfree (respline);
+ return FTPLOGREFUSED;
+ }
+ if ((cp = calculate_skey_response (skey_sequence, cp, pass)) == 0)
+ goto bad;
+ pass = cp;
/* Construct the argument of PORT (of the form a,b,c,d,e,f). */
bytes = (char *)alloca (6 * 4 + 1);
sprintf (bytes, "%d,%d,%d,%d,%d,%d", in_addr[0], in_addr[1],
/* Construct the argument of PORT (of the form a,b,c,d,e,f). */
bytes = (char *)alloca (6 * 4 + 1);
sprintf (bytes, "%d,%d,%d,%d,%d,%d", in_addr[0], in_addr[1],
- in_addr[2], in_addr[3], (unsigned) (port & 0xff00) >> 8,
- port & 0xff);
+ in_addr[2], in_addr[3], (unsigned) (port & 0xff00) >> 8,
+ port & 0xff);
/* Send PORT request. */
request = ftp_request ("PORT", bytes);
nwritten = iwrite (RBUF_FD (rbuf), request, strlen (request));
/* Send PORT request. */
request = ftp_request ("PORT", bytes);
nwritten = iwrite (RBUF_FD (rbuf), request, strlen (request));
- *server_type = ST_OTHER;
+ if (!strcasecmp (request, "MACOS"))
+ *server_type = ST_MACOS;
+ else
+ *server_type = ST_OTHER;