summaryrefslogtreecommitdiff
path: root/lib/libfetch/ftp.c
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2001-05-26 17:31:50 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2001-05-26 17:31:50 +0000
commitdbd3b502318a9b8b5870f90ef634be04f61ac3f1 (patch)
tree5bec16aac6e092d688cfde93bcef136caf6f9163 /lib/libfetch/ftp.c
parent9f85b2588ff872be1a956de057486366cfc7af13 (diff)
Notes
Diffstat (limited to 'lib/libfetch/ftp.c')
-rw-r--r--lib/libfetch/ftp.c45
1 files changed, 22 insertions, 23 deletions
diff --git a/lib/libfetch/ftp.c b/lib/libfetch/ftp.c
index a2dfc93d1bb2..0cc9910adaca 100644
--- a/lib/libfetch/ftp.c
+++ b/lib/libfetch/ftp.c
@@ -60,6 +60,7 @@
#include <netinet/in.h>
#include <ctype.h>
+#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <netdb.h>
@@ -166,7 +167,7 @@ _ftp_chkerr(int cd)
* Send a command and check reply
*/
static int
-_ftp_cmd(int cd, char *fmt, ...)
+_ftp_cmd(int cd, const char *fmt, ...)
{
va_list ap;
size_t len;
@@ -197,8 +198,8 @@ _ftp_cmd(int cd, char *fmt, ...)
/*
* Return a pointer to the filename part of a path
*/
-static char *
-_ftp_filename(char *file)
+static const char *
+_ftp_filename(const char *file)
{
char *s;
@@ -213,7 +214,7 @@ _ftp_filename(char *file)
* specified file.
*/
static int
-_ftp_cwd(int cd, char *file)
+_ftp_cwd(int cd, const char *file)
{
char *s;
int e;
@@ -234,9 +235,10 @@ _ftp_cwd(int cd, char *file)
* Request and parse file stats
*/
static int
-_ftp_stat(int cd, char *file, struct url_stat *us)
+_ftp_stat(int cd, const char *file, struct url_stat *us)
{
- char *ln, *s;
+ char *ln;
+ const char *s;
struct tm tm;
time_t t;
int e;
@@ -416,13 +418,10 @@ _ftp_closefn(void *v)
io->dir = -1;
io->dsd = -1;
DEBUG(fprintf(stderr, "Waiting for final status\n"));
- if ((r = _ftp_chkerr(io->csd)) != FTP_TRANSFER_COMPLETE)
- io->err = r;
- else
- io->err = 0;
+ r = _ftp_chkerr(io->csd);
close(io->csd);
- io->csd = -1;
- return io->err ? -1 : 0;
+ free(io);
+ return (r == FTP_TRANSFER_COMPLETE) ? 0 : -1;
}
static FILE *
@@ -447,8 +446,8 @@ _ftp_setup(int csd, int dsd, int mode)
* Transfer file
*/
static FILE *
-_ftp_transfer(int cd, char *oper, char *file,
- int mode, off_t offset, char *flags)
+_ftp_transfer(int cd, const char *oper, const char *file,
+ int mode, off_t offset, const char *flags)
{
struct sockaddr_storage sin;
struct sockaddr_in6 *sin6;
@@ -716,7 +715,7 @@ ouch:
* Log on to FTP server
*/
static int
-_ftp_connect(struct url *url, struct url *purl, char *flags)
+_ftp_connect(struct url *url, struct url *purl, const char *flags)
{
int cd, e, direct, verbose;
#ifdef INET6
@@ -725,7 +724,8 @@ _ftp_connect(struct url *url, struct url *purl, char *flags)
int af = AF_INET;
#endif
const char *logname;
- char *user, *pwd;
+ const char *user;
+ const char *pwd;
char localhost[MAXHOSTNAMELEN];
char pbuf[MAXHOSTNAMELEN + MAXLOGNAME + 1];
@@ -842,7 +842,7 @@ _ftp_isconnected(struct url *url)
* Check the cache, reconnect if no luck
*/
static int
-_ftp_cached_connect(struct url *url, struct url *purl, char *flags)
+_ftp_cached_connect(struct url *url, struct url *purl, const char *flags)
{
int e, cd;
@@ -901,7 +901,7 @@ _ftp_get_proxy(void)
* Get and stat file
*/
FILE *
-fetchXGetFTP(struct url *url, struct url_stat *us, char *flags)
+fetchXGetFTP(struct url *url, struct url_stat *us, const char *flags)
{
struct url *purl;
int cd;
@@ -939,7 +939,7 @@ fetchXGetFTP(struct url *url, struct url_stat *us, char *flags)
* Get file
*/
FILE *
-fetchGetFTP(struct url *url, char *flags)
+fetchGetFTP(struct url *url, const char *flags)
{
return fetchXGetFTP(url, NULL, flags);
}
@@ -948,7 +948,7 @@ fetchGetFTP(struct url *url, char *flags)
* Put file
*/
FILE *
-fetchPutFTP(struct url *url, char *flags)
+fetchPutFTP(struct url *url, const char *flags)
{
struct url *purl;
int cd;
@@ -982,7 +982,7 @@ fetchPutFTP(struct url *url, char *flags)
* Get file stats
*/
int
-fetchStatFTP(struct url *url, struct url_stat *us, char *flags)
+fetchStatFTP(struct url *url, struct url_stat *us, const char *flags)
{
struct url *purl;
int cd;
@@ -1019,9 +1019,8 @@ fetchStatFTP(struct url *url, struct url_stat *us, char *flags)
/*
* List a directory
*/
-extern void warnx(char *, ...);
struct url_ent *
-fetchListFTP(struct url *url, char *flags)
+fetchListFTP(struct url *url, const char *flags)
{
warnx("fetchListFTP(): not implemented");
return NULL;