From c8b0e5ec7be876d9163fb5d6077ea17a177aceeb Mon Sep 17 00:00:00 2001 From: jb Date: Sat, 20 Dec 1997 04:06:06 +0000 Subject: Change errno usage as a field in a structure and as an argument to a function from 'errno' to 'error' so that there is no conflict with the thread-safe definition of errno in errno.h. --- lib/libftpio/ftpio.c | 50 +++++++++++++++++++++++++------------------------- lib/libftpio/ftpio.h | 6 +++--- 2 files changed, 28 insertions(+), 28 deletions(-) (limited to 'lib') diff --git a/lib/libftpio/ftpio.c b/lib/libftpio/ftpio.c index 5be77f4..877896c 100644 --- a/lib/libftpio/ftpio.c +++ b/lib/libftpio/ftpio.c @@ -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.27 1997/10/01 07:21:41 jkh Exp $ + * $Id: ftpio.c,v 1.28 1997/10/02 23:26:03 fenner Exp $ * */ @@ -103,7 +103,7 @@ networkInit() static int check_code(FTP_t ftp, int var, int preferred) { - ftp->errno = 0; + ftp->error = 0; while (1) { if (var == preferred) return 0; @@ -114,7 +114,7 @@ check_code(FTP_t ftp, int var, int preferred) else if (var == FTP_GENERALLY_HAPPY) /* general success code */ var = get_a_number(ftp, NULL); else { - ftp->errno = var; + ftp->error = var; return 1; } } @@ -172,21 +172,21 @@ int ftpErrno(FILE *fp) { FTP_t ftp = fcookie(fp); - return ftp->errno; + return ftp->error; } const char * -ftpErrString(int errno) +ftpErrString(int error) { int k; - if (errno == -1) + if (error == -1) return("connection in wrong state"); - if (errno < 100) + if (error < 100) /* XXX soon UNIX errnos will catch up with FTP protocol errnos */ - return strerror(errno); + return strerror(error); for (k = 0; k < ftpErrListLength; k++) - if (ftpErrList[k].num == errno) + if (ftpErrList[k].num == error) return(ftpErrList[k].string); return("Unknown error"); } @@ -285,7 +285,7 @@ ftpLogin(char *host, char *user, char *passwd, int port, int verbose, int *retco if (!n) *retcode = (FtpTimedOut ? FTP_TIMED_OUT : -1); /* Poor attempt at mapping real errnos to FTP error codes */ - else switch(n->errno) { + else switch(n->error) { case EADDRNOTAVAIL: *retcode = FTP_TIMED_OUT; /* Actually no such host, but we have no way of saying that. :-( */ break; @@ -295,7 +295,7 @@ ftpLogin(char *host, char *user, char *passwd, int port, int verbose, int *retco break; default: - *retcode = n->errno; + *retcode = n->error; break; } } @@ -457,7 +457,7 @@ ftp_new(void) ftp->is_binary = FALSE; ftp->is_passive = FALSE; ftp->is_verbose = FALSE; - ftp->errno = 0; + ftp->error = 0; return ftp; } @@ -616,7 +616,7 @@ ftp_close(FTP_t ftp) if (ftp->con_state == isopen) { ftp->con_state = quit; /* If last operation timed out, don't try to quit - just close */ - if (ftp->errno != FTP_TIMED_OUT) + if (ftp->error != FTP_TIMED_OUT) i = cmd(ftp, "QUIT"); else i = FTP_QUIT_HAPPY; @@ -677,7 +677,7 @@ ftp_login_session(FTP_t ftp, char *host, char *user, char *passwd, int port, int if (ftp->con_state != init) { ftp_close(ftp); - ftp->errno = -1; + ftp->error = -1; return FAILURE; } @@ -698,7 +698,7 @@ ftp_login_session(FTP_t ftp, char *host, char *user, char *passwd, int port, int else { he = gethostbyname(host); if (!he) { - ftp->errno = 0; + ftp->error = 0; return FAILURE; } ftp->addrtype = sin.sin_family = he->h_addrtype; @@ -708,13 +708,13 @@ ftp_login_session(FTP_t ftp, char *host, char *user, char *passwd, int port, int sin.sin_port = htons(port); if ((s = socket(ftp->addrtype, SOCK_STREAM, 0)) < 0) { - ftp->errno = -1; + ftp->error = -1; return FAILURE; } if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) { (void)close(s); - ftp->errno = errno; + ftp->error = errno; return FAILURE; } @@ -728,7 +728,7 @@ ftp_login_session(FTP_t ftp, char *host, char *user, char *passwd, int port, int if (i >= 299 || i < 0) { ftp_close(ftp); if (i > 0) - ftp->errno = i; + ftp->error = i; return FAILURE; } return SUCCESS; @@ -751,7 +751,7 @@ ftp_file_op(FTP_t ftp, char *operation, char *file, FILE **fp, char *mode, off_t return botch("ftp_file_op", "open"); if ((s = socket(ftp->addrtype, SOCK_STREAM, 0)) < 0) { - ftp->errno = errno; + ftp->error = errno; return FAILURE; } @@ -761,7 +761,7 @@ ftp_file_op(FTP_t ftp, char *operation, char *file, FILE **fp, char *mode, off_t if (writes(ftp->fd_ctrl, "PASV\r\n")) { ftp_close(ftp); if (FtpTimedOut) - ftp->errno = FTP_TIMED_OUT; + ftp->error = FTP_TIMED_OUT; return FTP_TIMED_OUT; } i = get_a_number(ftp, &q); @@ -793,7 +793,7 @@ ftp_file_op(FTP_t ftp, char *operation, char *file, FILE **fp, char *mode, off_t i = cmd(ftp, "REST %d", *seekto); if (i < 0 || FTP_TIMEOUT(i)) { close(s); - ftp->errno = i; + ftp->error = i; *seekto = (off_t)0; return i; } @@ -801,7 +801,7 @@ ftp_file_op(FTP_t ftp, char *operation, char *file, FILE **fp, char *mode, off_t i = cmd(ftp, "%s %s", operation, file); if (i < 0 || i > 299) { close(s); - ftp->errno = i; + ftp->error = i; return i; } *fp = fdopen(s, mode); @@ -838,7 +838,7 @@ ftp_file_op(FTP_t ftp, char *operation, char *file, FILE **fp, char *mode, off_t i = cmd(ftp, "REST %d", *seekto); if (i < 0 || FTP_TIMEOUT(i)) { close(s); - ftp->errno = i; + ftp->error = i; return i; } else if (i != 350) @@ -847,13 +847,13 @@ ftp_file_op(FTP_t ftp, char *operation, char *file, FILE **fp, char *mode, off_t i = cmd(ftp, "%s %s", operation, file); if (i < 0 || i > 299) { close(s); - ftp->errno = i; + ftp->error = i; return FAILURE; } fd = accept(s, 0, 0); if (fd < 0) { close(s); - ftp->errno = 401; + ftp->error = 401; return FAILURE; } close(s); diff --git a/lib/libftpio/ftpio.h b/lib/libftpio/ftpio.h index 4dee7d9..41e7c1e 100644 --- a/lib/libftpio/ftpio.h +++ b/lib/libftpio/ftpio.h @@ -22,7 +22,7 @@ * Turned inside out. Now returns xfers as new file ids, not as a special * `state' of FTP_t * - * $Id: ftpio.h,v 1.12 1997/02/22 15:06:52 peter Exp $ + * $Id: ftpio.h,v 1.13 1997/05/05 11:18:55 jkh Exp $ */ /* Internal housekeeping data structure for FTP sessions */ @@ -32,7 +32,7 @@ typedef struct { int addrtype; char *host; char *file; - int errno; + int error; int is_binary; int is_passive; int is_verbose; @@ -62,7 +62,7 @@ extern void ftpVerbose(FILE *fp, int status); extern FILE *ftpGetURL(char *url, char *user, char *passwd, int *retcode); extern FILE *ftpPutURL(char *url, char *user, char *passwd, int *retcode); extern time_t ftpGetModtime(FILE *fp, char *s); -extern const char *ftpErrString(int errno); +extern const char *ftpErrString(int error); __END_DECLS #endif /* _FTP_H_INCLUDE */ -- cgit v1.1