summaryrefslogtreecommitdiff
path: root/libftpconn
diff options
context:
space:
mode:
Diffstat (limited to 'libftpconn')
-rw-r--r--libftpconn/ChangeLog19
-rw-r--r--libftpconn/addr.c25
-rw-r--r--libftpconn/cwd.c56
-rw-r--r--libftpconn/open.c93
-rw-r--r--libftpconn/rmt.c34
-rw-r--r--libftpconn/unix.c35
6 files changed, 149 insertions, 113 deletions
diff --git a/libftpconn/ChangeLog b/libftpconn/ChangeLog
index 9f896155..77a944dc 100644
--- a/libftpconn/ChangeLog
+++ b/libftpconn/ChangeLog
@@ -1,11 +1,25 @@
+1998-10-20 Roland McGrath <roland@baalperazim.frob.com>
+
+ * unix.c (ftp_conn_unix_cont_get_stats): Add braces to silence gcc
+ warning.
+ * open.c (ftp_conn_sysify): Likewise.
+ (ftp_conn_login): Likewise.
+ * cwd.c (ftp_conn_cdup): Likewise.
+ (ftp_conn_cwd): Likewise.
+ (_cache_cwd): Likewise.
+ * addr.c (ftp_conn_send_actv_addr): Likewise.
+ (ftp_conn_get_pasv_addr): Likewise.
+
1997-09-04 Miles Bader <miles@gnu.ai.mit.edu>
* ftpconn.h [!FTP_CONN_EI] (FTP_CONN_EI): New macro.
- (ftp_conn_validate_syshooks): Use FTP_CONN_EI instead of `static inline'.
+ (ftp_conn_validate_syshooks): Use FTP_CONN_EI instead of
+ `static inline'.
Protect with __OPTIMIZE__.
* ftpconn.h (struct ftp_conn): Remove ACTV_DATA_CONN_QUEUE field.
- * create.c (ftp_conn_create): Don't initialize CONN->actv_data_conn_queue.
+ * create.c (ftp_conn_create): Don't initialize
+ CONN->actv_data_conn_queue.
* open.c (ftp_conn_close): Don't cleanup CONN->actv_data_conn_queue.
* xfer.c (ftp_conn_start_open_actv_data): Always generate a new data
connection (it doesn't work to always listen on a single address).
@@ -238,4 +252,3 @@ Wed May 7 12:35:21 1997 Miles Bader <miles@gnu.ai.mit.edu>
Update comment to say they should be copied if retained.
* Makefile (installhdrsubdir): New variable.
-
diff --git a/libftpconn/addr.c b/libftpconn/addr.c
index c2ff01ac..3b668f34 100644
--- a/libftpconn/addr.c
+++ b/libftpconn/addr.c
@@ -1,6 +1,6 @@
/* Send/receive data-connection addresses
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.ai.mit.edu>
@@ -33,10 +33,13 @@ ftp_conn_get_pasv_addr (struct ftp_conn *conn, struct sockaddr **addr)
error_t err = ftp_conn_cmd_reopen (conn, "pasv", 0, &reply, &txt);
if (! err)
- if (reply == REPLY_PASV_OK)
- err = (*(conn->syshooks.pasv_addr ?: ftp_conn_unix_pasv_addr)) (conn, txt, addr);
- else
- err = unexpected_reply (conn, reply, txt, 0);
+ {
+ if (reply == REPLY_PASV_OK)
+ err = (*(conn->syshooks.pasv_addr ?: ftp_conn_unix_pasv_addr))
+ (conn, txt, addr);
+ else
+ err = unexpected_reply (conn, reply, txt, 0);
+ }
return err;
}
@@ -59,15 +62,17 @@ ftp_conn_send_actv_addr (struct ftp_conn *conn, struct sockaddr *addr)
unsigned char *p =
(unsigned char *)&((struct sockaddr_in *)addr)->sin_port;
- snprintf (buf, sizeof buf, "%d,%d,%d,%d,%d,%d",
+ snprintf (buf, sizeof buf, "%d,%d,%d,%d,%d,%d",
a[0], a[1], a[2], a[3], p[0], p[1]);
err = ftp_conn_cmd_reopen (conn, "port", buf, &reply, 0);
if (! err)
- if (reply == REPLY_OK)
- err = 0;
- else
- err = unexpected_reply (conn, reply, 0, 0);
+ {
+ if (reply == REPLY_OK)
+ err = 0;
+ else
+ err = unexpected_reply (conn, reply, 0, 0);
+ }
}
return err;
diff --git a/libftpconn/cwd.c b/libftpconn/cwd.c
index 89156a58..868150f1 100644
--- a/libftpconn/cwd.c
+++ b/libftpconn/cwd.c
@@ -1,6 +1,6 @@
/* Get/set connection current working directory
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.ai.mit.edu>
@@ -34,22 +34,24 @@ _cache_cwd (struct ftp_conn *conn, int reopen)
(reopen ? ftp_conn_cmd_reopen : ftp_conn_cmd) (conn, "pwd", 0, &reply, &txt);
if (! err)
- if (reply == REPLY_DIR_NAME)
- {
- char *cwd = malloc (strlen (txt));
- if (! cwd)
- err = ENOMEM;
- else if (sscanf (txt, "\"%[^\"]\"", cwd) != 1)
- err = EGRATUITOUS;
- else
- {
- if (conn->cwd)
- free (conn->cwd);
- conn->cwd = cwd;
- }
- }
- else
- err = unexpected_reply (conn, reply, txt, 0);
+ {
+ if (reply == REPLY_DIR_NAME)
+ {
+ char *cwd = malloc (strlen (txt));
+ if (! cwd)
+ err = ENOMEM;
+ else if (sscanf (txt, "\"%[^\"]\"", cwd) != 1)
+ err = EGRATUITOUS;
+ else
+ {
+ if (conn->cwd)
+ free (conn->cwd);
+ conn->cwd = cwd;
+ }
+ }
+ else
+ err = unexpected_reply (conn, reply, txt, 0);
+ }
return err;
}
@@ -83,10 +85,12 @@ ftp_conn_cwd (struct ftp_conn *conn, const char *cwd)
const char *txt;
err = ftp_conn_cmd_reopen (conn, "cwd", cwd, &reply, &txt);
if (! err)
- if (reply == REPLY_FCMD_OK)
- err = _cache_cwd (conn, 0);
- else
- err = unexpected_reply (conn, reply, txt, ftp_conn_poss_file_errs);
+ {
+ if (reply == REPLY_FCMD_OK)
+ err = _cache_cwd (conn, 0);
+ else
+ err = unexpected_reply (conn, reply, txt, ftp_conn_poss_file_errs);
+ }
}
return err;
}
@@ -99,9 +103,11 @@ ftp_conn_cdup (struct ftp_conn *conn)
const char *txt;
error_t err = ftp_conn_cmd_reopen (conn, "cdup", 0, &reply, &txt);
if (! err)
- if (reply == REPLY_OK)
- err = _cache_cwd (conn, 0);
- else
- err = unexpected_reply (conn, reply, txt, ftp_conn_poss_file_errs);
+ {
+ if (reply == REPLY_OK)
+ err = _cache_cwd (conn, 0);
+ else
+ err = unexpected_reply (conn, reply, txt, ftp_conn_poss_file_errs);
+ }
return err;
}
diff --git a/libftpconn/open.c b/libftpconn/open.c
index b3615b17..dc8421b7 100644
--- a/libftpconn/open.c
+++ b/libftpconn/open.c
@@ -1,6 +1,6 @@
/* Connection initiation
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.ai.mit.edu>
@@ -35,7 +35,7 @@ ftp_conn_login (struct ftp_conn *conn)
int reply;
error_t err = 0;
const struct ftp_conn_params *p = conn->params;
-
+
err = ftp_conn_cmd (conn, "user", p->user ?: "anonymous", &reply, 0);
if (!err && reply == REPLY_NEED_ACCT)
@@ -59,40 +59,44 @@ ftp_conn_login (struct ftp_conn *conn)
FTP_CONN_GET_LOGIN_PARAM_PASS,
&pass);
if (! err)
- if (pass)
- err = ftp_conn_cmd (conn, "pass", pass, &reply, 0);
- else
- {
- pass = getenv ("USER");
- if (! pass)
- pass = getenv ("LOGNAME");
- if (! pass)
- {
- struct passwd *pe = getpwuid (getuid ());
- pass = pe ? pe->pw_name : "?";
- }
-
- /* Append a '@' */
- pass = strdup (pass);
- if (pass)
- pass = realloc (pass, strlen (pass) + 1);
- if (pass)
- {
- strcat (pass, "@");
- err = ftp_conn_cmd (conn, "pass", pass, &reply, 0);
- }
- else
- err = ENOMEM;
- }
+ {
+ if (pass)
+ err = ftp_conn_cmd (conn, "pass", pass, &reply, 0);
+ else
+ {
+ pass = getenv ("USER");
+ if (! pass)
+ pass = getenv ("LOGNAME");
+ if (! pass)
+ {
+ struct passwd *pe = getpwuid (getuid ());
+ pass = pe ? pe->pw_name : "?";
+ }
+
+ /* Append a '@' */
+ pass = strdup (pass);
+ if (pass)
+ pass = realloc (pass, strlen (pass) + 1);
+ if (pass)
+ {
+ strcat (pass, "@");
+ err = ftp_conn_cmd (conn, "pass", pass, &reply, 0);
+ }
+ else
+ err = ENOMEM;
+ }
+ }
if (pass && !p->pass)
free (pass);
}
if (!err && reply != REPLY_LOGIN_OK)
- if (REPLY_IS_FAILURE (reply))
- err = EACCES;
- else
- err = unexpected_reply (conn, reply, 0, 0);
+ {
+ if (REPLY_IS_FAILURE (reply))
+ err = EACCES;
+ else
+ err = unexpected_reply (conn, reply, 0, 0);
+ }
return err;
}
@@ -141,18 +145,21 @@ ftp_conn_sysify (struct ftp_conn *conn)
error_t err = ftp_conn_cmd (conn, "syst", 0, &reply, &txt);
if (! err)
- if (reply == REPLY_SYSTYPE || reply == REPLY_BAD_CMD || reply == REPLY_UNIMP_CMD)
- {
- if (reply == REPLY_BAD_CMD || reply == REPLY_UNIMP_CMD)
- txt = 0;
- if (conn->hooks && conn->hooks->choose_syshooks)
- (*conn->hooks->choose_syshooks) (conn, txt);
- else
- ftp_conn_choose_syshooks (conn, txt);
- conn->syshooks_valid = 1;
- }
- else
- err = unexpected_reply (conn, reply, txt, 0);
+ {
+ if (reply == REPLY_SYSTYPE ||
+ reply == REPLY_BAD_CMD || reply == REPLY_UNIMP_CMD)
+ {
+ if (reply == REPLY_BAD_CMD || reply == REPLY_UNIMP_CMD)
+ txt = 0;
+ if (conn->hooks && conn->hooks->choose_syshooks)
+ (*conn->hooks->choose_syshooks) (conn, txt);
+ else
+ ftp_conn_choose_syshooks (conn, txt);
+ conn->syshooks_valid = 1;
+ }
+ else
+ err = unexpected_reply (conn, reply, txt, 0);
+ }
return err;
}
diff --git a/libftpconn/rmt.c b/libftpconn/rmt.c
index 33fdeaf7..7ada5774 100644
--- a/libftpconn/rmt.c
+++ b/libftpconn/rmt.c
@@ -1,6 +1,6 @@
/* Remote (server-to-server) transfer
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.ai.mit.edu>
@@ -50,21 +50,23 @@ ftp_conn_rmt_transfer (struct ftp_conn *src_conn,
err = ftp_conn_cmd (dst_conn, "stor", dst_name, &reply, &txt);
if (! err)
- if (REPLY_IS_PRELIM (reply))
- {
- err = ftp_conn_get_reply (src_conn, &reply, &txt);
- if (!err && !REPLY_IS_PRELIM (reply))
- err = unexpected_reply (src_conn, reply, txt, src_poss_errs);
-
- if (err)
- ftp_conn_abort (dst_conn);
- else
- err = ftp_conn_finish_transfer (dst_conn);
- }
- else
- err = unexpected_reply (dst_conn, reply, txt,
- ftp_conn_poss_file_errs);
-
+ {
+ if (REPLY_IS_PRELIM (reply))
+ {
+ err = ftp_conn_get_reply (src_conn, &reply, &txt);
+ if (!err && !REPLY_IS_PRELIM (reply))
+ err = unexpected_reply (src_conn, reply, txt,
+ src_poss_errs);
+
+ if (err)
+ ftp_conn_abort (dst_conn);
+ else
+ err = ftp_conn_finish_transfer (dst_conn);
+ }
+ else
+ err = unexpected_reply (dst_conn, reply, txt,
+ ftp_conn_poss_file_errs);
+ }
if (err)
/* Ftp servers seem to hang trying to abort at this point, so
just close the connection entirely. */
diff --git a/libftpconn/unix.c b/libftpconn/unix.c
index b7a79cab..e3277721 100644
--- a/libftpconn/unix.c
+++ b/libftpconn/unix.c
@@ -1,6 +1,6 @@
/* Unix-specific ftpconn hooks
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.ai.mit.edu>
@@ -347,7 +347,7 @@ drwxrwxrwt 7 34 archive 512 May 1 14:28 /tmp
p = e; \
u; \
})
-
+
/* Link count. */
SKIP_WS ();
stat->st_nlink = PARSE_INT ();
@@ -595,20 +595,23 @@ ftp_conn_unix_cont_get_stats (struct ftp_conn *conn, int fd, void *state,
}
if (strchr (name, '/'))
- if (s->contents)
- /* We know that the name originally request had a slash in it
- (because we added one if necessary), so if a name in the
- listing has one too, it can't be the contents of a
- directory; if this is the case and we wanted the contents,
- this must not be a directory. */
- {
- err = ENOTDIR;
- goto finished;
- }
- else if (s->added_slash)
- /* S->name must be the same name we passed; if we added a `./'
- prefix, removed it so the client gets back what it passed. */
- name += 2;
+ {
+ if (s->contents)
+ /* We know that the name originally request had a slash in
+ it (because we added one if necessary), so if a name in
+ the listing has one too, it can't be the contents of a
+ directory; if this is the case and we wanted the
+ contents, this must not be a directory. */
+ {
+ err = ENOTDIR;
+ goto finished;
+ }
+ else if (s->added_slash)
+ /* S->name must be the same name we passed; if we added a
+ `./' prefix, removed it so the client gets back what it
+ passed. */
+ name += 2;
+ }
/* Pass only directory-relative names to the callback function. */
name = basename (name);