diff options
author | peter <peter@FreeBSD.org> | 1996-09-19 17:28:34 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1996-09-19 17:28:34 +0000 |
commit | a229cd8427a7660044f96404d43114548b041149 (patch) | |
tree | a26bc1e0e219713683b4a497c4522c8381b12756 /lib | |
parent | b3f9cfa0e28c63f9f7b5b9a812a3bd8e4cad6c23 (diff) | |
download | FreeBSD-src-a229cd8427a7660044f96404d43114548b041149.zip FreeBSD-src-a229cd8427a7660044f96404d43114548b041149.tar.gz |
Make libftpio 64-bit clean.
Major version bumped (by me) since the ftpGet() public interface has
changed (an "int *" becomes and "off_t *")
Submitted by: Jason Thorpe <thorpej@nas.nasa.gov>, PR#1640
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libftpio/Makefile | 3 | ||||
-rw-r--r-- | lib/libftpio/ftpio.c | 51 | ||||
-rw-r--r-- | lib/libftpio/ftpio.h | 7 |
3 files changed, 36 insertions, 25 deletions
diff --git a/lib/libftpio/Makefile b/lib/libftpio/Makefile index 79d270e..bfb9de2 100644 --- a/lib/libftpio/Makefile +++ b/lib/libftpio/Makefile @@ -4,6 +4,9 @@ SRCS= ftpio.c ftperr.c MAN3= ftpio.3 CLEANFILES+= ftperr.c +SHLIB_MAJOR= 3 +SHLIB_MINOR= 0 + beforeinstall: ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 ${.CURDIR}/ftpio.h \ ${DESTDIR}/usr/include diff --git a/lib/libftpio/ftpio.c b/lib/libftpio/ftpio.c index df4c7d4..71cae49 100644 --- a/lib/libftpio/ftpio.c +++ b/lib/libftpio/ftpio.c @@ -14,26 +14,27 @@ * Turned inside out. Now returns xfers as new file ids, not as a special * `state' of FTP_t * - * $Id: ftpio.c,v 1.12 1996/08/24 09:51:59 jkh Exp $ + * $Id: ftpio.c,v 1.13 1996/08/31 22:02:18 jkh Exp $ * */ -#include <stdlib.h> -#include <stdio.h> -#include <unistd.h> -#include <netdb.h> -#include <errno.h> #include <sys/types.h> #include <sys/socket.h> + #include <netinet/in.h> -#include <stdarg.h> -#include <string.h> -#include <ctype.h> -#include <sys/signal.h> -#include <sys/socket.h> -#include <netinet/in.h> + #include <arpa/inet.h> + +#include <ctype.h> +#include <errno.h> #include <ftpio.h> +#include <netdb.h> +#include <signal.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> #define SUCCESS 0 #define FAILURE -1 @@ -58,7 +59,7 @@ static int get_a_number(FTP_t ftp, char **q); static int botch(char *func, char *botch_state); static int cmd(FTP_t ftp, const char *fmt, ...); static int ftp_login_session(FTP_t ftp, char *host, char *user, char *passwd, int port, int verbose); -static int ftp_file_op(FTP_t ftp, char *operation, char *file, FILE **fp, char *mode, int *seekto); +static int ftp_file_op(FTP_t ftp, char *operation, char *file, FILE **fp, char *mode, off_t *seekto); static int ftp_close(FTP_t ftp); static int get_url_info(char *url_in, char *host_ret, int *port_ret, char *name_ret); @@ -176,12 +177,13 @@ ftpErrString(int errno) return("Unknown error"); } -size_t +off_t ftpGetSize(FILE *fp, char *name) { int i; - char p[BUFSIZ], *cp; + char p[BUFSIZ], *cp, *ep; FTP_t ftp = fcookie(fp); + off_t size; check_passive(fp); sprintf(p, "SIZE %s\r\n", name); @@ -189,11 +191,16 @@ ftpGetSize(FILE *fp, char *name) fprintf(stderr, "Sending %s", p); i = writes(ftp->fd_ctrl, p); if (i) - return (size_t)-1; + return (off_t)-1; i = get_a_number(ftp, &cp); if (check_code(ftp, i, 213)) - return (size_t)-1; - return (size_t)atoi(cp); + return (off_t)-1; + + errno = 0; /* to check for ERANGE */ + size = (off_t)strtoq(cp, &ep, 10); + if (*ep != '\0' || errno == ERANGE) + return (off_t)-1; + return size; } time_t @@ -230,7 +237,7 @@ ftpGetModtime(FILE *fp, char *name) } FILE * -ftpGet(FILE *fp, char *file, int *seekto) +ftpGet(FILE *fp, char *file, off_t *seekto) { FILE *fp2; FTP_t ftp = fcookie(fp); @@ -646,7 +653,7 @@ ftp_login_session(FTP_t ftp, char *host, char *user, char *passwd, int port, int } static int -ftp_file_op(FTP_t ftp, char *operation, char *file, FILE **fp, char *mode, int *seekto) +ftp_file_op(FTP_t ftp, char *operation, char *file, FILE **fp, char *mode, off_t *seekto) { int i,s; char *q; @@ -700,7 +707,7 @@ ftp_file_op(FTP_t ftp, char *operation, char *file, FILE **fp, char *mode, int * if (i < 0 || FTP_TIMEOUT(i)) { close(s); ftp->errno = i; - *seekto = 0; + *seekto = (off_t)0; return i; } } @@ -748,7 +755,7 @@ ftp_file_op(FTP_t ftp, char *operation, char *file, FILE **fp, char *mode, int * return i; } else if (i != 350) - *seekto = 0; + *seekto = (off_t)0; } i = cmd(ftp, "%s %s", operation, file); if (i < 0 || i > 299) { diff --git a/lib/libftpio/ftpio.h b/lib/libftpio/ftpio.h index 49da730..2164ebd 100644 --- a/lib/libftpio/ftpio.h +++ b/lib/libftpio/ftpio.h @@ -2,6 +2,7 @@ #define _FTP_H_INCLUDE #include <sys/types.h> +#include <stdio.h> #include <time.h> /* @@ -20,7 +21,7 @@ * Turned inside out. Now returns xfers as new file ids, not as a special * `state' of FTP_t * - * $Id: ftpio.h,v 1.6 1996/08/03 11:58:54 jkh Exp $ + * $Id: ftpio.h,v 1.7 1996/08/21 01:12:11 jkh Exp $ */ /* Internal housekeeping data structure for FTP sessions */ @@ -48,8 +49,8 @@ extern int const ftpErrListLength; extern FILE *ftpLogin(char *host, char *user, char *passwd, int port, int verbose); extern int ftpChdir(FILE *fp, char *dir); extern int ftpErrno(FILE *fp); -extern size_t ftpGetSize(FILE *fp, char *file); -extern FILE *ftpGet(FILE *fp, char *file, int *seekto); +extern off_t ftpGetSize(FILE *fp, char *file); +extern FILE *ftpGet(FILE *fp, char *file, off_t *seekto); extern FILE *ftpPut(FILE *fp, char *file); extern int ftpAscii(FILE *fp); extern int ftpBinary(FILE *fp); |