Add an ftpErrString() function for returning human readable failure
codes. Submitted-By: Archie Cobbs <archie@whistle.com>
This commit is contained in:
parent
8c2e11aad8
commit
6f828b77f3
@ -1,10 +1,25 @@
|
||||
LIB= ftpio
|
||||
CFLAGS+= -I${.CURDIR} -Wall
|
||||
SRCS= ftpio.c
|
||||
SRCS= ftpio.c ftperr.c
|
||||
MAN3= ftpio.3
|
||||
CLEANFILES+= ftperr.c
|
||||
|
||||
beforeinstall:
|
||||
cd ${.CURDIR}; cmp -s ftpio.h ${DESTDIR}/usr/include/ftpio.h || \
|
||||
${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 ftpio.h ${DESTDIR}/usr/include
|
||||
|
||||
ftperr.c: ftp.errors
|
||||
@echo '#include <stdio.h>' > ${.TARGET}
|
||||
@echo '#include "ftpio.h"' >> ${.TARGET}
|
||||
@echo "struct ftperr ftpErrList[] = {" \ >> ${.TARGET}
|
||||
@cat ${.ALLSRC} \
|
||||
| grep -v ^# \
|
||||
| sort \
|
||||
| while read NUM STRING; do \
|
||||
echo " { $${NUM}, \"$${STRING}\" },"; \
|
||||
done >> ${.TARGET}
|
||||
@echo "};" >> ${.TARGET}
|
||||
@echo -n "int const ftpErrListLength = " >> ${.TARGET}
|
||||
@echo "sizeof(ftpErrList) / sizeof(*ftpErrList);" >> ${.TARGET}
|
||||
|
||||
.include <bsd.lib.mk>
|
||||
|
44
lib/libftpio/ftp.errors
Normal file
44
lib/libftpio/ftp.errors
Normal file
@ -0,0 +1,44 @@
|
||||
# $Id$
|
||||
#
|
||||
# This list is taken from RFC 959.
|
||||
# It probably needs a going over.
|
||||
#
|
||||
110 Restart marker reply
|
||||
120 Service ready in a few minutes
|
||||
125 Data connection already open; transfer starting
|
||||
150 File status okay; about to open data connection
|
||||
200 Command okay
|
||||
202 Command not implemented, superfluous at this site
|
||||
211 System status, or system help reply
|
||||
212 Directory status
|
||||
213 File status
|
||||
214 Help message
|
||||
215 Set system type
|
||||
220 Service ready for new user
|
||||
221 Service closing control connection
|
||||
225 Data connection open; no transfer in progress
|
||||
226 Requested file action successful
|
||||
227 Entering Passive Mode
|
||||
230 User logged in, proceed
|
||||
250 Requested file action okay, completed
|
||||
257 File/directory created
|
||||
331 User name okay, need password
|
||||
332 Need account for login
|
||||
350 Requested file action pending further information
|
||||
421 Service not available, closing control connection
|
||||
425 Can't open data connection
|
||||
426 Connection closed; transfer aborted
|
||||
450 File unavailable (e.g., file busy)
|
||||
451 Requested action aborted: local error in processing
|
||||
452 Insufficient storage space in system
|
||||
500 Syntax error, command unrecognized
|
||||
501 Syntax error in parameters or arguments
|
||||
502 Command not implemented
|
||||
503 Bad sequence of commands
|
||||
504 Command not implemented for that parameter
|
||||
530 Not logged in
|
||||
532 Need account for storing files
|
||||
550 File unavailable (e.g., file not found, no access)
|
||||
551 Requested action aborted. Page type unknown
|
||||
552 Exceeded storage allocation
|
||||
553 File name not allowed
|
@ -48,6 +48,8 @@
|
||||
.Fn ftpChdir "FILE *stream, char *dirname"
|
||||
.Ft int
|
||||
.Fn ftpErrno "FILE *stream"
|
||||
.Ft const char *
|
||||
.Fn ftpErrString "int errno"
|
||||
.Ft time_t
|
||||
.Fn ftpGetModtime "FILE *stream, char *file"
|
||||
.Ft size_t
|
||||
@ -95,6 +97,8 @@ On success, zero is returned. On failure, the error code from the server.
|
||||
.Fn ftpErrno
|
||||
returns the server failure code for the last operation (useful for seeing
|
||||
more about what happened if you're familiar with FTP error codes).
|
||||
.Fn ftpErrString
|
||||
returns a human readable version of the supplied server failure code.
|
||||
.Pp
|
||||
.Fn ftpGet
|
||||
attempts to retreive the file named by the
|
||||
@ -187,8 +191,7 @@ all my tests.
|
||||
.Sh HISTORY
|
||||
Started life as Poul-Henning Kamp's ftp driver for the system installation
|
||||
utility, later significantly mutated into a more general form as an
|
||||
extension of stdio and given a TCL interface (not enabled by default)
|
||||
by Jordan Hubbard. Also incorporates some ideas and extensions from
|
||||
Jean-Marc Zucconi.
|
||||
extension of stdio by Jordan Hubbard. Also incorporates some ideas and
|
||||
extensions from Jean-Marc Zucconi.
|
||||
.Sh AUTHORS
|
||||
Jordan Hubbard, Poul-Henning Kamp and Jean-Marc Zucconi
|
||||
|
@ -14,7 +14,7 @@
|
||||
* Turned inside out. Now returns xfers as new file ids, not as a special
|
||||
* `state' of FTP_t
|
||||
*
|
||||
* $Id: ftpio.c,v 1.8 1996/07/04 00:55:20 jkh Exp $
|
||||
* $Id: ftpio.c,v 1.9 1996/08/03 11:58:53 jkh Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -165,6 +165,17 @@ ftpErrno(FILE *fp)
|
||||
return ftp->errno;
|
||||
}
|
||||
|
||||
const char *
|
||||
ftpErrString(int errno)
|
||||
{
|
||||
int k;
|
||||
|
||||
for (k = 0; k < ftpErrListLength; k++)
|
||||
if (ftpErrList[k].num == errno)
|
||||
return(ftpErrList[k].string);
|
||||
return("Unknown error");
|
||||
}
|
||||
|
||||
size_t
|
||||
ftpGetSize(FILE *fp, char *name)
|
||||
{
|
||||
|
@ -20,7 +20,7 @@
|
||||
* Turned inside out. Now returns xfers as new file ids, not as a special
|
||||
* `state' of FTP_t
|
||||
*
|
||||
* $Id: ftpio.h,v 1.5 1996/07/04 00:55:21 jkh Exp $
|
||||
* $Id: ftpio.h,v 1.6 1996/08/03 11:58:54 jkh Exp $
|
||||
*/
|
||||
|
||||
/* Internal housekeeping data structure for FTP sessions */
|
||||
@ -36,6 +36,14 @@ typedef struct {
|
||||
int is_verbose;
|
||||
} *FTP_t;
|
||||
|
||||
/* Structure we use to match FTP error codes with readable strings */
|
||||
struct ftperr {
|
||||
const int num;
|
||||
const char *string;
|
||||
};
|
||||
extern struct ftperr ftpErrList[];
|
||||
extern int const ftpErrListLength;
|
||||
|
||||
/* Exported routines - deal only with FILE* type */
|
||||
extern FILE *ftpLogin(char *host, char *user, char *passwd, int port, int verbose);
|
||||
extern int ftpChdir(FILE *fp, char *dir);
|
||||
@ -50,5 +58,6 @@ extern void ftpVerbose(FILE *fp, int status);
|
||||
extern FILE *ftpGetURL(char *url, char *user, char *passwd);
|
||||
extern FILE *ftpPutURL(char *url, char *user, char *passwd);
|
||||
extern time_t ftpGetModtime(FILE *fp, char *s);
|
||||
extern const char *ftpErrString(int errno);
|
||||
|
||||
#endif /* _FTP_H_INCLUDE */
|
||||
|
Loading…
x
Reference in New Issue
Block a user