merge tnftp 20050610

This commit is contained in:
lukem 2005-06-10 05:06:25 +00:00
parent f6e9257fb3
commit 84c028ec5e
62 changed files with 1424 additions and 1131 deletions

View file

@ -1,4 +1,4 @@
NetBSD: COPYING,v 1.4 2005/05/11 03:03:42 lukem Exp
NetBSD: COPYING,v 1.5 2005/05/28 13:15:14 lukem Exp
Copyright (c) 2001-2005 The NetBSD Foundation, Inc.
All rights reserved.
@ -42,11 +42,13 @@ acknowledgements:
This product includes software developed by the NetBSD Foundation,
Inc. and its contributors. Those contributors include:
- Simon Burge
- Jaromir Dolecek
- Klaus Klein
- Luke Mewburn
- Jason R. Thorpe of the Numerical Aerospace Simulation
Facility, NASA Ames Research Center.
- Christos Zoulas
This product includes software developed by the University of
California, Berkeley and its contributors. Those contributors include:

View file

@ -1,4 +1,144 @@
NetBSD: ChangeLog,v 1.17 2005/05/14 04:46:26 lukem Exp
NetBSD: ChangeLog,v 1.27 2005/06/10 04:40:13 lukem Exp
Fri Jun 10 04:39:33 UTC 2005 lukem
* Release as "tnftp 20050610"
* Add dependencies on ${srcdir}/../tnftp.h and ../config.h
* Merge NetBSD ftp from 20050609 to 20050610. Changes:
- Implement getline() to read a line into a buffer.
- Convert to use getline() instead of fgets() whenever reading
user input to ensure that an overly long input line doesn't
leave excess characters for the next input operation to
accidentally use as input.
- Zero out the password & account after we've finished with it.
- Consistently use getpass(3) (i.e, character echo suppressed)
when reading the account data. For some reason, historically
the "login" code suppressed echo for Account: yet the "user"
command did not!
- Display the hostname in the "getaddrinfo failed" warning.
- Appease some -Wcast-qual warnings. Fixing all of these
requires significant code refactoring. (mmm, legacy code).
Thu Jun 9 16:49:05 UTC 2005 lukem
* src, libnetbsd: Excise RCSID block, rather than using
#if 0 ... #endif. The point was to minimise RCSID
conflicts, and the latter isn't helping there.
* Merge NetBSD ftp from 20050531 to 20050609. Changes:
- Only print the "Trying <address>..." message if verbose
and there's more than one struct addrinfo in the
getaddrinfo() result.
- Don't use non-standard "u_int".
Wed Jun 1 15:08:01 UTC 2005 lukem
* Look for dirname(3), which may be in -lgen on IRIX, and
replace it if not found..
Wed Jun 1 11:48:58 UTC 2005 lukem
* libnetbsd:
- Don't use non-standard: u_char u_short u_int.
- Use uint32_t instead of u_int32_t.
- Don't use register.
* libedit: Don't use non-standard uint or u_int.
Tue May 31 02:23:08 UTC 2005 lukem
* tnftp.h: need <libgen.h> for dirname(3)
* Merge ftp from 20050513 to 20050531. Changes:
- Helps if the definition of xconnect() matches its
declaration....
- Fix some cast issues highlighted by Scott Reynolds using
gcc 4 on OSX.4
- Use size_t instead of int where appropriate.
- Make this compile on sparc64 (size_t != int).
- Printf field widths and size_t don't always mix well, so
cast to int. Fixes build problem for alpha.
- Some const cleanups.
- tab cleanup
- Improve method used in fileindir() to determine if `file'
is in or under `dir': realpath(3) on non-NetBSD systems may
fail if the target filename doesn't exist, so instead use
realpath(3) on the parent directory of `file'.
Per discussion with Todd Eigenschink.
- formatbuf(): fix %m and %M to use the hostname, not the
username.
- fetch_ftp(): preserve 'anonftp' across a disconnect() so
that multiple ftp auto-fetches on the same command line
login automatically.
- auto_fetch(): use an initialized volatile int to appease
IRIX cc.
* Merge libedit from NetBSD 20050105 to 20050531. Changes include:
- Rui Paulo: Incorrect tok_line and tok_str declarations.
- Remove clause 3 from the UCB license.
- Luke Mewburn: Don't abuse unconstify'ing a string
and writing to it, because you'll core dump. Also remove
extra const that gives pain to the irix compiler.
- Make sure we flush after we prepare when we are unbuffered
otherwise the prompt will not appear immediately.
- Terminate the arglist with a NULL instead of 0.
(Shuts up gcc4.x)
Sat May 28 13:19:38 UTC 2005 lukem
* libnetbsd/strvis.c:
- Sync to NetBSD's vis.c 1.33:
Use malloc(3) instead of alloca(3).
- Remove extraenous #endif
Fri May 27 05:46:58 UTC 2005 lukem
* libnetbsd/strvis.c: Sync to NetBSD's vis.c 1.30:
Use a more standard TNF license.
* libedit/sig.c: Include "src/progressbar.h" for xsignal_restart()
prototype.
* Ensure that fallback #define of __attribute__ is available.
Fixes build problem on HP-UX with cc.
Thu May 26 14:21:08 UTC 2005 lukem
* Extend xpoll()'s HAVE_SELECT implementation to support POLLRDNORM,
POLLWRNORM, and POLLRDBAND - the latter using exceptfds.
Per discussion with Christos Zoulas.
Mon May 16 13:33:27 UTC 2005 lukem
* Pull in <poll.h> or <sys/poll.h> if they exist even if we're
not using poll, as struct pollfd might exist in those.
Fixes build problem on OSX.3.
* Separate CPPFLAGS from CFLAGS.
* Sync various files in libnetbsd with the original versions
in NetBSD. Notable changes
- Convert 4 clause UCB license to 3 clause.
- Use strlcpy instead of strcpy.
- Update ISC copyright.
- Use NS_INADDRSZ, NS_IN6ADDRSZ and NS_INT16SZ instead of
equivalents without NS_ prefix.
- Use socklen_t instead of size_t where appropriate.
- Improve bounds checking.
- Don't update the size of allocated storage until
realloc succeeds.
- Fix comment about return value.
- Reverse the order of two loop invariant to make
'strlcat(0, "foo", 0)' not get a SEGV.
- Use Todd C. Miller's latest copyright notice (more loose).
- Use "long long" instead of "quad" in various
comments & constants.
- Support VIS_HTTPSTYLE.
- Implement svis(), strsvis(), strsvisx(), strunvisx().
* Prefer poll over select when implementing replacement usleep().
Sat May 14 04:44:35 UTC 2005 lukem

View file

@ -1,5 +1,5 @@
/* config.h.in. Generated automatically from configure.in by autoheader. */
/* NetBSD: config.h.in,v 1.9 2005/05/14 04:41:27 lukem Exp */
/* NetBSD: config.h.in,v 1.10 2005/06/01 15:10:21 lukem Exp */
/* Define if on AIX 3.
@ -45,6 +45,9 @@
/* The number of bytes in a off_t. */
#undef SIZEOF_OFF_T
/* Define if you have the dirname function. */
#undef HAVE_DIRNAME
/* Define if you have the err function. */
#undef HAVE_ERR

File diff suppressed because it is too large Load diff

View file

@ -1,10 +1,10 @@
dnl NetBSD: configure.in,v 1.13 2005/05/14 04:34:50 lukem Exp
dnl NetBSD: configure.in,v 1.16 2005/06/02 00:20:32 lukem Exp
dnl
dnl configure.in --
dnl process this file with autoconf to produce a configure script.
dnl
AC_REVISION([Revision: 1.13])dnl
AC_REVISION([Revision: 1.16])dnl
AC_INIT(tnftp.h)
@ -43,6 +43,7 @@ if test $opt_editcomplete = yes; then
AC_MSG_ERROR([no relevant library found containing tgetent]))
AC_SEARCH_LIBS(el_init, [edit], [have_libedit=yes], [have_libedit=no])
fi
AC_SEARCH_LIBS(dirname, [gen], [have_dirname=yes], [have_dirname=no])
AC_LIBRARY_NET
AC_LIBRARY_SOCKS
if test -n "$socks"; then
@ -191,6 +192,9 @@ AC_CHECK_FUNCS([gethostbyname2 getpassphrase getpgrp memmove select])
if test $have_fparseln != yes; then
AC_REPLACE_FUNCS(fparseln)
fi
if test $have_dirname != yes; then
AC_REPLACE_FUNCS(dirname)
fi
if test $ac_cv_func_getpgrp = yes; then
AC_FUNC_GETPGRP
fi

View file

@ -1,4 +1,4 @@
# NetBSD: Makefile.in,v 1.2 2005/05/11 01:17:39 lukem Exp
# NetBSD: Makefile.in,v 1.4 2005/06/10 04:36:12 lukem Exp
#
srcdir = @srcdir@
@ -6,7 +6,8 @@ VPATH = @srcdir@
SHELL = /bin/sh
CC = @CC@
CFLAGS = -I${srcdir} -I${srcdir}/.. -I. -I.. @INCLUDES@ @CFLAGS@
CFLAGS = @CFLAGS@
CPPFLAGS= -I${srcdir} -I${srcdir}/.. -I. -I.. @INCLUDES@ @CPPFLAGS@
AR = @AR@
RANLIB = @RANLIB@
@ -25,6 +26,11 @@ ${LIB}: ${OBJS}
${AR} cr $@ ${OBJS}
${RANLIB} $@
${OBJS}: ${srcdir}/../tnftp.h ../config.h
.c.o:
${CC} ${CFLAGS} ${CPPFLAGS} -c $<
install:
clean:

View file

@ -1,4 +1,4 @@
/* NetBSD: chared.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
/* NetBSD: chared.c,v 1.6 2005/06/09 16:48:57 lukem Exp */
/* from NetBSD: chared.c,v 1.22 2004/08/13 12:10:38 mycroft Exp */
/*-
@ -36,17 +36,6 @@
#include "tnftp.h"
#include "sys.h"
#if 0
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
#if 0
static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("NetBSD: chared.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
#endif
#endif /* not lint && not SCCSID */
#endif
/*
* chared.c: Character editor utilities
*/
@ -64,7 +53,7 @@ cv_undo(EditLine *el)
{
c_undo_t *vu = &el->el_chared.c_undo;
c_redo_t *r = &el->el_chared.c_redo;
uint size;
unsigned int size;
/* Save entire line for undo */
size = el->el_line.lastchar - el->el_line.buffer;

View file

@ -1,4 +1,4 @@
/* NetBSD: common.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
/* NetBSD: common.c,v 1.5 2005/06/09 16:48:57 lukem Exp */
/* from NetBSD: common.c,v 1.16 2003/08/07 16:44:30 agc Exp */
/*-
@ -36,17 +36,6 @@
#include "tnftp.h"
#include "sys.h"
#if 0
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
#if 0
static char sccsid[] = "@(#)common.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("NetBSD: common.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
#endif
#endif /* not lint && not SCCSID */
#endif
/*
* common.c: Common Editor functions
*/

View file

@ -1,5 +1,5 @@
.\" NetBSD: editline.3,v 1.2 2005/05/11 01:17:39 lukem Exp
.\" from NetBSD: editline.3,v 1.45 2004/04/15 08:13:29 wiz Exp
.\" NetBSD: editline.3,v 1.3 2005/05/31 02:07:02 lukem Exp
.\" from NetBSD: editline.3,v 1.46 2005/03/19 17:36:02 christos Exp
.\"
.\" Copyright (c) 1997-2003 The NetBSD Foundation, Inc.
.\" All rights reserved.
@ -34,7 +34,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd December 5, 2003
.Dd March 19, 2005
.Os
.Dt EDITLINE 3
.Sh NAME
@ -106,9 +106,9 @@
.Ft void
.Fn tok_reset "Tokenizer *t"
.Ft int
.Fn tok_line "Tokenizer *t" "const LineInfo *li" "int *argc" "const char *argv[]" "int *cursorc" "int *cursoro"
.Fn tok_line "Tokenizer *t" "const LineInfo *li" "int *argc" "const char **argv[]" "int *cursorc" "int *cursoro"
.Ft int
.Fn tok_str "Tokenizer *t" "const char *str" "int *argc" "const char *argv[]"
.Fn tok_str "Tokenizer *t" "const char *str" "int *argc" "const char **argv[]"
.Sh DESCRIPTION
The
.Nm

View file

@ -1,4 +1,4 @@
/* NetBSD: el.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
/* NetBSD: el.c,v 1.5 2005/06/09 16:48:57 lukem Exp */
/* from NetBSD: el.c,v 1.39 2004/07/08 00:51:36 christos Exp */
/*-
@ -36,17 +36,6 @@
#include "tnftp.h"
#include "sys.h"
#if 0
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
#if 0
static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94";
#else
__RCSID("NetBSD: el.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
#endif
#endif /* not lint && not SCCSID */
#endif
/*
* el.c: EditLine interface functions
*/

View file

@ -1,4 +1,4 @@
/* NetBSD: emacs.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
/* NetBSD: emacs.c,v 1.5 2005/06/09 16:48:57 lukem Exp */
/* from NetBSD: emacs.c,v 1.19 2004/10/28 21:14:52 dsl Exp */
/*-
@ -36,17 +36,6 @@
#include "tnftp.h"
#include "sys.h"
#if 0
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
#if 0
static char sccsid[] = "@(#)emacs.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("NetBSD: emacs.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
#endif
#endif /* not lint && not SCCSID */
#endif
/*
* emacs.c: Emacs functions
*/

View file

@ -1,4 +1,4 @@
/* NetBSD: hist.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
/* NetBSD: hist.c,v 1.5 2005/06/09 16:48:57 lukem Exp */
/* from NetBSD: hist.c,v 1.15 2003/11/01 23:36:39 christos Exp */
/*-
@ -36,17 +36,6 @@
#include "tnftp.h"
#include "sys.h"
#if 0
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
#if 0
static char sccsid[] = "@(#)hist.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("NetBSD: hist.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
#endif
#endif /* not lint && not SCCSID */
#endif
/*
* hist.c: History access functions
*/

View file

@ -1,5 +1,5 @@
/* NetBSD: histedit.h,v 1.2 2005/05/11 01:17:39 lukem Exp */
/* from NetBSD: histedit.h,v 1.25 2003/12/05 13:37:48 lukem Exp */
/* NetBSD: histedit.h,v 1.3 2005/05/31 02:07:02 lukem Exp */
/* from NetBSD: histedit.h,v 1.26 2005/05/07 16:01:25 dsl Exp */
/*-
* Copyright (c) 1992, 1993
@ -107,6 +107,7 @@ int el_parse(EditLine *, int, const char **);
*/
int el_set(EditLine *, int, ...);
int el_get(EditLine *, int, void *);
unsigned char _el_fn_complete(EditLine *, int);
/*
* el_set/el_get parameters

View file

@ -1,4 +1,4 @@
/* NetBSD: history.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
/* NetBSD: history.c,v 1.5 2005/06/09 16:48:58 lukem Exp */
/* from NetBSD: history.c,v 1.28 2004/11/27 18:31:45 christos Exp */
/*-
@ -36,17 +36,6 @@
#include "tnftp.h"
#include "sys.h"
#if 0
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
#if 0
static char sccsid[] = "@(#)history.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("NetBSD: history.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
#endif
#endif /* not lint && not SCCSID */
#endif
/*
* hist.c: History access functions
*/

View file

@ -1,4 +1,4 @@
/* NetBSD: key.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
/* NetBSD: key.c,v 1.5 2005/06/09 16:48:58 lukem Exp */
/* from NetBSD: key.c,v 1.15 2003/10/18 23:48:42 christos Exp */
/*-
@ -36,17 +36,6 @@
#include "tnftp.h"
#include "sys.h"
#if 0
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
#if 0
static char sccsid[] = "@(#)key.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("NetBSD: key.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
#endif
#endif /* not lint && not SCCSID */
#endif
/*
* key.c: This module contains the procedures for maintaining
* the extended-key map.

View file

@ -1,4 +1,4 @@
/* NetBSD: map.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
/* NetBSD: map.c,v 1.5 2005/06/09 16:48:58 lukem Exp */
/* from NetBSD: map.c,v 1.20 2004/08/13 12:10:39 mycroft Exp */
/*-
@ -36,17 +36,6 @@
#include "tnftp.h"
#include "sys.h"
#if 0
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
#if 0
static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("NetBSD: map.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
#endif
#endif /* not lint && not SCCSID */
#endif
/*
* map.c: Editor function definitions
*/

View file

@ -1,5 +1,5 @@
/* NetBSD: parse.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
/* from NetBSD: parse.c,v 1.20 2003/12/05 13:37:48 lukem Exp */
/* NetBSD: parse.c,v 1.6 2005/06/09 16:48:58 lukem Exp */
/* from NetBSD: parse.c,v 1.22 2005/05/29 04:58:15 lukem Exp */
/*-
* Copyright (c) 1992, 1993
@ -36,17 +36,6 @@
#include "tnftp.h"
#include "sys.h"
#if 0
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
#if 0
static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("NetBSD: parse.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
#endif
#endif /* not lint && not SCCSID */
#endif
/*
* parse.c: parse an editline extended command
*
@ -142,7 +131,7 @@ el_parse(EditLine *el, int argc, const char *argv[])
* the appropriate character or -1 if the escape is not valid
*/
protected int
parse__escape(const char **const ptr)
parse__escape(const char **ptr)
{
const char *p;
int c;

View file

@ -1,5 +1,5 @@
/* NetBSD: parse.h,v 1.2 2005/05/11 01:17:39 lukem Exp */
/* from NetBSD: parse.h,v 1.5 2003/08/07 16:44:32 agc Exp */
/* NetBSD: parse.h,v 1.3 2005/05/31 02:07:02 lukem Exp */
/* from NetBSD: parse.h,v 1.6 2005/05/29 04:58:15 lukem Exp */
/*-
* Copyright (c) 1992, 1993
@ -42,7 +42,7 @@
#define _h_el_parse
protected int parse_line(EditLine *, const char *);
protected int parse__escape(const char ** const);
protected int parse__escape(const char **);
protected char *parse__string(char *, const char *);
protected int parse_cmd(EditLine *, const char *);

View file

@ -1,4 +1,4 @@
/* NetBSD: prompt.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
/* NetBSD: prompt.c,v 1.5 2005/06/09 16:48:58 lukem Exp */
/* from NetBSD: prompt.c,v 1.11 2003/08/07 16:44:32 agc Exp */
/*-
@ -36,17 +36,6 @@
#include "tnftp.h"
#include "sys.h"
#if 0
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
#if 0
static char sccsid[] = "@(#)prompt.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("NetBSD: prompt.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
#endif
#endif /* not lint && not SCCSID */
#endif
/*
* prompt.c: Prompt printing functions
*/

View file

@ -1,5 +1,5 @@
/* NetBSD: read.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
/* from NetBSD: read.c,v 1.34 2004/07/08 00:51:36 christos Exp */
/* NetBSD: read.c,v 1.7 2005/06/09 16:48:58 lukem Exp */
/* from NetBSD: read.c,v 1.35 2005/03/09 23:55:02 christos Exp */
/*-
* Copyright (c) 1992, 1993
@ -36,17 +36,6 @@
#include "tnftp.h"
#include "sys.h"
#if 0
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
#if 0
static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("NetBSD: read.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
#endif
#endif /* not lint && not SCCSID */
#endif
/*
* read.c: Clean this junk up! This is horrible code.
* Terminal read functions
@ -372,6 +361,9 @@ read_prepare(EditLine *el)
re_clear_display(el); /* reset the display stuff */
ch_reset(el);
re_refresh(el); /* print the prompt */
if (el->el_flags & UNBUFFERED)
term__flush();
}
protected void
@ -488,7 +480,7 @@ el_gets(EditLine *el, int *nread)
#endif /* DEBUG_READ */
break;
}
if ((uint)cmdnum >= el->el_map.nfunc) { /* BUG CHECK command */
if ((unsigned int)cmdnum >= el->el_map.nfunc) { /* BUG CHECK command */
#ifdef DEBUG_EDIT
(void) fprintf(el->el_errfile,
"ERROR: illegal command from key 0%o\r\n", ch);

View file

@ -1,5 +1,5 @@
/* NetBSD: readline.h,v 1.2 2005/05/11 01:17:39 lukem Exp */
/* from NetBSD: readline.h,v 1.12 2004/09/08 18:15:37 christos Exp */
/* NetBSD: readline.h,v 1.3 2005/05/31 02:07:02 lukem Exp */
/* from NetBSD: readline.h,v 1.14 2005/05/27 11:35:07 agc Exp */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -46,6 +46,7 @@
/* typedefs */
typedef int Function(const char *, int);
typedef void VFunction(void);
typedef void VCPFunction(char *);
typedef char *CPFunction(const char *, int);
typedef char **CPPFunction(const char *, int, int);
@ -103,6 +104,7 @@ extern char *rl_completer_word_break_characters;
extern char *rl_completer_quote_characters;
extern Function *rl_completion_entry_function;
extern CPPFunction *rl_attempted_completion_function;
extern int rl_attempted_completion_over;
extern int rl_completion_type;
extern int rl_completion_query_items;
extern char *rl_special_prefixes;
@ -167,7 +169,7 @@ void rl_reset_terminal(const char *);
int rl_bind_key(int, int (*)(int, int));
int rl_newline(int, int);
void rl_callback_read_char(void);
void rl_callback_handler_install(const char *, VFunction *);
void rl_callback_handler_install(const char *, VCPFunction *);
void rl_callback_handler_remove(void);
void rl_redisplay(void);
int rl_get_previous_history(int, int);
@ -175,6 +177,7 @@ void rl_prep_terminal(int);
void rl_deprep_terminal(void);
int rl_read_init_file(const char *);
int rl_parse_and_bind(const char *);
int rl_variable_bind(const char *, const char *);
void rl_stuff_char(int);
int rl_add_defun(const char *, Function *, int);

View file

@ -1,4 +1,4 @@
/* NetBSD: refresh.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
/* NetBSD: refresh.c,v 1.5 2005/06/09 16:48:58 lukem Exp */
/* from NetBSD: refresh.c,v 1.26 2003/08/07 16:44:33 agc Exp */
/*-
@ -36,17 +36,6 @@
#include "tnftp.h"
#include "sys.h"
#if 0
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
#if 0
static char sccsid[] = "@(#)refresh.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("NetBSD: refresh.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
#endif
#endif /* not lint && not SCCSID */
#endif
/*
* refresh.c: Lower level screen refreshing functions
*/

View file

@ -1,4 +1,4 @@
/* NetBSD: search.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
/* NetBSD: search.c,v 1.5 2005/06/09 16:48:58 lukem Exp */
/* from NetBSD: search.c,v 1.20 2004/11/04 01:16:03 christos Exp */
/*-
@ -36,17 +36,6 @@
#include "tnftp.h"
#include "sys.h"
#if 0
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
#if 0
static char sccsid[] = "@(#)search.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("NetBSD: search.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
#endif
#endif /* not lint && not SCCSID */
#endif
/*
* search.c: History and character search functions
*/

View file

@ -1,4 +1,4 @@
/* NetBSD: sig.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
/* NetBSD: sig.c,v 1.6 2005/06/09 16:48:58 lukem Exp */
/* from NetBSD: sig.c,v 1.11 2003/08/07 16:44:33 agc Exp */
/*-
@ -36,17 +36,6 @@
#include "tnftp.h"
#include "sys.h"
#if 0
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
#if 0
static char sccsid[] = "@(#)sig.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("NetBSD: sig.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
#endif
#endif /* not lint && not SCCSID */
#endif
/*
* sig.c: Signal handling stuff.
* our policy is to trap all signals, set a good state
@ -55,6 +44,8 @@ __RCSID("NetBSD: sig.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
#include "el.h"
#include <stdlib.h>
#include "src/progressbar.h" /* for xsignal_restart() */
private EditLine *sel = NULL;
private const int sighdl[] = {

View file

@ -1,4 +1,4 @@
/* NetBSD: sys.h,v 1.3 2005/05/11 01:17:39 lukem Exp */
/* NetBSD: sys.h,v 1.4 2005/05/27 04:58:05 lukem Exp */
/* from NetBSD: sys.h,v 1.9 2004/01/17 17:57:40 christos Exp */
/*-
@ -41,15 +41,11 @@
#ifndef _h_sys
#define _h_sys
#if __not_for_tnftp
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8)
# define __attribute__(A)
#endif
#if __not_for_tnftp
#ifndef __BEGIN_DECLS
# ifdef __cplusplus
# define __BEGIN_DECLS extern "C" {

View file

@ -1,4 +1,4 @@
/* NetBSD: term.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
/* NetBSD: term.c,v 1.5 2005/06/09 16:48:58 lukem Exp */
/* from NetBSD: term.c,v 1.40 2004/05/22 23:21:28 christos Exp */
/*-
@ -36,17 +36,6 @@
#include "tnftp.h"
#include "sys.h"
#if 0
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
#if 0
static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95";
#else
__RCSID("NetBSD: term.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
#endif
#endif /* not lint && not SCCSID */
#endif
/*
* term.c: Editor/termcap-curses interface
* We have to declare a static variable here, since the

View file

@ -1,5 +1,5 @@
/* NetBSD: term.h,v 1.2 2005/05/11 01:17:39 lukem Exp */
/* from NetBSD: term.h,v 1.15 2003/09/14 21:48:55 christos Exp */
/* NetBSD: term.h,v 1.3 2005/05/31 02:07:02 lukem Exp */
/* from NetBSD: term.h,v 1.16 2005/03/15 00:10:40 christos Exp */
/*-
* Copyright (c) 1992, 1993
@ -116,6 +116,7 @@ protected void term__flush(void);
#define EL_CAN_CEOL (EL_FLAGS & TERM_CAN_CEOL)
#define EL_CAN_TAB (EL_FLAGS & TERM_CAN_TAB)
#define EL_CAN_ME (EL_FLAGS & TERM_CAN_ME)
#define EL_CAN_UP (EL_FLAGS & TERM_CAN_UP)
#define EL_HAS_META (EL_FLAGS & TERM_HAS_META)
#define EL_HAS_AUTO_MARGINS (EL_FLAGS & TERM_HAS_AUTO_MARGINS)
#define EL_HAS_MAGIC_MARGINS (EL_FLAGS & TERM_HAS_MAGIC_MARGINS)

View file

@ -1,4 +1,4 @@
/* NetBSD: tokenizer.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
/* NetBSD: tokenizer.c,v 1.5 2005/06/09 16:48:58 lukem Exp */
/* from NetBSD: tokenizer.c,v 1.14 2003/12/05 13:37:48 lukem Exp */
/*-
@ -36,17 +36,6 @@
#include "tnftp.h"
#include "sys.h"
#if 0
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
#if 0
static char sccsid[] = "@(#)tokenizer.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("NetBSD: tokenizer.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
#endif
#endif /* not lint && not SCCSID */
#endif
/*
* tokenize.c: Bourne shell like tokenizer
*/

View file

@ -1,5 +1,5 @@
/* NetBSD: tty.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
/* from NetBSD: tty.c,v 1.21 2004/08/13 12:10:39 mycroft Exp */
/* NetBSD: tty.c,v 1.7 2005/06/09 16:48:58 lukem Exp */
/* from NetBSD: tty.c,v 1.22 2005/05/29 03:55:37 christos Exp */
/*-
* Copyright (c) 1992, 1993
@ -36,17 +36,6 @@
#include "tnftp.h"
#include "sys.h"
#if 0
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
#if 0
static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("NetBSD: tty.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
#endif
#endif /* not lint && not SCCSID */
#endif
/*
* tty.c: tty interface stuff
*/
@ -56,7 +45,7 @@ __RCSID("NetBSD: tty.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
typedef struct ttymodes_t {
const char *m_name;
u_int m_value;
unsigned int m_value;
int m_type;
} ttymodes_t;
@ -1234,7 +1223,7 @@ tty_stty(EditLine *el, int argc __attribute__((__unused__)), const char **argv)
return (0);
}
while (argv && (s = *argv++)) {
char *p;
const char *p;
switch (*s) {
case '+':
case '-':
@ -1245,10 +1234,10 @@ tty_stty(EditLine *el, int argc __attribute__((__unused__)), const char **argv)
break;
}
d = s;
if ((p = strchr(s, '=')) != NULL)
*p++ = '\0';
p = strchr(s, '=');
for (m = ttymodes; m->m_name; m++)
if (strcmp(m->m_name, d) == 0 &&
if ((p ? strncmp(m->m_name, d, (size_t)(p - d)) :
strcmp(m->m_name, d)) == 0 &&
(p == NULL || m->m_type == MD_CHAR))
break;
@ -1259,7 +1248,7 @@ tty_stty(EditLine *el, int argc __attribute__((__unused__)), const char **argv)
}
if (p) {
int c = ffs((int)m->m_value);
int v = *p ? parse__escape((const char **const) &p) :
int v = *++p ? parse__escape((const char **) &p) :
el->el_tty.t_vdisable;
assert(c-- != 0);
c = tty__getcharindex(c);

View file

@ -1,4 +1,4 @@
/* NetBSD: tty.h,v 1.2 2005/05/11 01:17:39 lukem Exp */
/* NetBSD: tty.h,v 1.3 2005/06/01 11:42:24 lukem Exp */
/* from NetBSD: tty.h,v 1.10 2003/08/07 16:44:34 agc Exp */
/*-
@ -451,8 +451,8 @@
typedef struct {
const char *t_name;
u_int t_setmask;
u_int t_clrmask;
unsigned int t_setmask;
unsigned int t_clrmask;
} ttyperm_t[NN_IO][MD_NN];
typedef unsigned char ttychar_t[NN_IO][C_NCC];

View file

@ -1,5 +1,5 @@
/* NetBSD: vi.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
/* from NetBSD: vi.c,v 1.20 2004/08/13 12:10:39 mycroft Exp */
/* NetBSD: vi.c,v 1.6 2005/06/09 16:48:58 lukem Exp */
/* from NetBSD: vi.c,v 1.21 2005/04/25 01:06:03 matt Exp */
/*-
* Copyright (c) 1992, 1993
@ -36,21 +36,6 @@
#include "tnftp.h"
#include "sys.h"
#if 0
#include "config.h"
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#if !defined(lint) && !defined(SCCSID)
#if 0
static char sccsid[] = "@(#)vi.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("NetBSD: vi.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
#endif
#endif /* not lint && not SCCSID */
#endif
/*
* vi.c: Vi mode commands.
*/
@ -1027,7 +1012,7 @@ vi_histedit(EditLine *el, int c)
return CC_ERROR;
case 0:
close(fd);
execlp("vi", "vi", tempfile, 0);
execlp("vi", "vi", tempfile, NULL);
exit(0);
/*NOTREACHED*/
default:

View file

@ -1,4 +1,4 @@
# NetBSD: Makefile.in,v 1.3 2005/05/11 01:01:56 lukem Exp
# NetBSD: Makefile.in,v 1.5 2005/06/10 04:36:12 lukem Exp
#
srcdir = @srcdir@
@ -6,7 +6,8 @@ VPATH = @srcdir@
SHELL = /bin/sh
CC = @CC@
CFLAGS = -I${srcdir} -I${srcdir}/.. -I.. @INCLUDES@ @CFLAGS@
CFLAGS = @CFLAGS@
CPPFLAGS= -I${srcdir} -I${srcdir}/.. -I. -I.. @INCLUDES@ @CPPFLAGS@
AR = @AR@
RANLIB = @RANLIB@
@ -22,6 +23,11 @@ ${LIB}: ${OBJS}
${AR} cr $@ ${OBJS}
${RANLIB} $@
${OBJS}: ${srcdir}/../tnftp.h ../config.h
.c.o:
${CC} ${CFLAGS} ${CPPFLAGS} -c $<
install:
clean:

View file

@ -1,5 +1,5 @@
/* NetBSD: ftpglob.h,v 1.2 2005/05/11 01:01:56 lukem Exp */
/* from NetBSD: glob.h,v 1.13 2001/03/16 21:02:42 christos Exp */
/* NetBSD: ftpglob.h,v 1.3 2005/05/16 05:45:40 lukem Exp */
/* from NetBSD: glob.h,v 1.19 2005/02/03 04:39:32 perry Exp */
/*
* Copyright (c) 1989, 1993
@ -16,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*

View file

@ -1,5 +1,5 @@
/* NetBSD: ftpvis.h,v 1.2 2005/05/11 01:01:56 lukem Exp */
/* from NetBSD: vis.h,v 1.10 1998/11/13 12:20:18 christos Exp */
/* NetBSD: ftpvis.h,v 1.3 2005/05/16 13:25:48 lukem Exp */
/* from NetBSD: vis.h,v 1.15 2005/02/03 04:39:32 perry Exp */
/*-
* Copyright (c) 1990, 1993
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -59,6 +55,7 @@
* other
*/
#define VIS_NOSLASH 0x40 /* inhibit printing '\' */
#define VIS_HTTPSTYLE 0x80 /* http-style escape % HEX HEX */
/*
* unvis return codes
@ -75,9 +72,13 @@
#define UNVIS_END 1 /* no more characters */
char *vis(char *, int, int, int);
char *svis(char *, int, int, int, const char *);
int strvis(char *, const char *, int);
int strsvis(char *, const char *, int, const char *);
int strvisx(char *, const char *, size_t, int);
int strsvisx(char *, const char *, size_t, int, const char *);
int strunvis(char *, const char *);
int strunvisx(char *, const char *, int);
int unvis(char *, int, int *, int);
#endif /* !_VIS_H_ */

View file

@ -1,4 +1,4 @@
/* NetBSD: getnameinfo.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
/* NetBSD: getnameinfo.c,v 1.5 2005/06/01 11:48:49 lukem Exp */
/* from ? */
/*
@ -67,9 +67,9 @@ static struct afd {
};
struct sockinet {
u_char si_len;
u_char si_family;
u_short si_port;
unsigned char si_len;
unsigned char si_family;
unsigned short si_port;
};
#ifdef INET6
@ -87,13 +87,13 @@ static int ip6_sa2str(const struct sockaddr_in6 *, char *, size_t, int);
#define ENI_SALEN EAI_FAMILY
int
getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host,
size_t hostlen, char *serv, size_t servlen, int flags)
getnameinfo(const struct sockaddr *sa, socklen_t salen,
char *host, size_t hostlen, char *serv, size_t servlen, int flags)
{
struct afd *afd;
struct servent *sp;
struct hostent *hp;
u_short port;
unsigned short port;
int family, i;
const char *addr;
unsigned int v4a;

View file

@ -1,5 +1,5 @@
/* NetBSD: glob.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
/* from NetBSD: __glob13.c,v 1.23 2001/09/18 16:37:26 christos Exp */
/* NetBSD: glob.c,v 1.5 2005/06/01 11:48:49 lukem Exp */
/* from NetBSD: __glob13.c,v 1.25 2003/08/07 16:42:45 agc Exp */
/*
* Copyright (c) 1989, 1993
@ -16,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -88,7 +84,7 @@
#define M_MASK 0xffff
#define M_ASCII 0x00ff
typedef u_short Char;
typedef unsigned short Char;
#else
@ -137,11 +133,11 @@ int
glob(const char *pattern, int flags, int (*errfunc)(const char *, int),
glob_t *pglob)
{
const u_char *patnext;
const unsigned char *patnext;
int c;
Char *bufnext, *bufend, patbuf[MAXPATHLEN+1];
patnext = (const u_char *) pattern;
patnext = (const unsigned char *) pattern;
if (!(flags & GLOB_APPEND)) {
pglob->gl_pathc = 0;
pglob->gl_pathv = NULL;
@ -616,7 +612,7 @@ glob3(Char *pathbuf, Char *pathend, Char *pathlim,
else
readdirfunc = (struct dirent *(*)(void *)) readdir;
while ((dp = (*readdirfunc)(dirp)) != NULL) {
u_char *sc;
unsigned char *sc;
Char *dc;
/* Initial DOT must be matched literally. */
@ -626,7 +622,7 @@ glob3(Char *pathbuf, Char *pathend, Char *pathlim,
* The resulting string contains EOS, so we can
* use the pathlim character, if it is the nul
*/
for (sc = (u_char *) dp->d_name, dc = pathend;
for (sc = (unsigned char *) dp->d_name, dc = pathend;
dc <= pathlim && (*dc++ = *sc++) != EOS;)
continue;
@ -806,7 +802,7 @@ g_opendir(Char *str, glob_t *pglob)
char buf[MAXPATHLEN];
if (!*str)
(void)strcpy(buf, ".");
(void)strlcpy(buf, ".", sizeof(buf));
else {
if (g_Ctoc(str, buf, sizeof(buf)))
return NULL;

View file

@ -1,20 +1,21 @@
/* NetBSD: inet_ntop.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
/* from NetBSD: inet_ntop.c,v 1.9 2000/01/22 22:19:16 mycroft Exp */
/* NetBSD: inet_ntop.c,v 1.6 2005/06/01 11:48:49 lukem Exp */
/* from NetBSD: inet_ntop.c,v 1.2 2004/05/20 23:12:33 christos Exp */
/* Copyright (c) 1996 by Internet Software Consortium.
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "tnftp.h"
@ -23,18 +24,12 @@
#include <arpa/nameser.h>
#endif
#ifndef IN6ADDRSZ
#define IN6ADDRSZ 16
#ifndef NS_IN6ADDRSZ
#define NS_IN6ADDRSZ 16
#endif
#ifndef INT16SZ
#define INT16SZ 2
#endif
#ifdef SPRINTF_CHAR
# define SPRINTF(x) strlen(sprintf/**/x)
#else
# define SPRINTF(x) ((size_t)sprintf x)
#ifndef NS_INT16SZ
#define NS_INT16SZ 2
#endif
/*
@ -42,8 +37,8 @@
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
*/
static const char *inet_ntop4(const u_char *src, char *dst, size_t size);
static const char *inet_ntop6(const u_char *src, char *dst, size_t size);
static const char *inet_ntop4(const unsigned char *src, char *dst, socklen_t size);
static const char *inet_ntop6(const unsigned char *src, char *dst, socklen_t size);
/* char *
* inet_ntop(af, src, dst, size)
@ -54,7 +49,7 @@ static const char *inet_ntop6(const u_char *src, char *dst, size_t size);
* Paul Vixie, 1996.
*/
const char *
inet_ntop(int af, const void *src, char *dst, size_t size)
inet_ntop(int af, const void *src, char *dst, socklen_t size)
{
switch (af) {
@ -78,21 +73,23 @@ inet_ntop(int af, const void *src, char *dst, size_t size)
* `dst' (as a const)
* notes:
* (1) uses no statics
* (2) takes a u_char* not an in_addr as input
* (2) takes a unsigned char* not an in_addr as input
* author:
* Paul Vixie, 1996.
*/
static const char *
inet_ntop4(const u_char *src, char *dst, size_t size)
inet_ntop4(const unsigned char *src, char *dst, socklen_t size)
{
static const char fmt[] = "%u.%u.%u.%u";
char tmp[sizeof "255.255.255.255"];
int l;
if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) > size) {
l = snprintf(tmp, sizeof(tmp), "%u.%u.%u.%u",
src[0], src[1], src[2], src[3]);
if (l <= 0 || (socklen_t) l >= size) {
errno = ENOSPC;
return (NULL);
}
strcpy(dst, tmp);
strlcpy(dst, tmp, size);
return (dst);
}
@ -104,7 +101,7 @@ inet_ntop4(const u_char *src, char *dst, size_t size)
* Paul Vixie, 1996.
*/
static const char *
inet_ntop6(const u_char *src, char *dst, size_t size)
inet_ntop6(const unsigned char *src, char *dst, socklen_t size)
{
/*
* Note that int32_t and int16_t need only be "at least" large enough
@ -113,10 +110,12 @@ inet_ntop6(const u_char *src, char *dst, size_t size)
* Keep this in mind if you think this function should have been coded
* to use pointer overlays. All the world's not a VAX.
*/
char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
char *tp, *ep;
struct { int base, len; } best, cur;
u_int words[IN6ADDRSZ / INT16SZ];
unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ];
int i;
int advance;
/*
* Preprocess:
@ -124,11 +123,11 @@ inet_ntop6(const u_char *src, char *dst, size_t size)
* Find the longest run of 0x00's in src[] for :: shorthanding.
*/
memset(words, '\0', sizeof words);
for (i = 0; i < IN6ADDRSZ; i++)
for (i = 0; i < NS_IN6ADDRSZ; i++)
words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
best.base = -1;
cur.base = -1;
for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
if (words[i] == 0) {
if (cur.base == -1)
cur.base = i, cur.len = 1;
@ -153,7 +152,8 @@ inet_ntop6(const u_char *src, char *dst, size_t size)
* Format the result.
*/
tp = tmp;
for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
ep = tmp + sizeof(tmp);
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
/* Are we inside the best run of 0x00's? */
if (best.base != -1 && i >= best.base &&
i < (best.base + best.len)) {
@ -162,21 +162,35 @@ inet_ntop6(const u_char *src, char *dst, size_t size)
continue;
}
/* Are we following an initial run of 0x00s or any real hex? */
if (i != 0)
if (i != 0) {
if (tp + 1 >= ep)
return (NULL);
*tp++ = ':';
}
/* Is this address an encapsulated IPv4? */
if (i == 6 && best.base == 0 &&
(best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp)))
(best.len == 6 ||
(best.len == 7 && words[7] != 0x0001) ||
(best.len == 5 && words[5] == 0xffff))) {
if (!inet_ntop4(src+12, tp, (socklen_t)(ep - tp)))
return (NULL);
tp += strlen(tp);
break;
}
tp += SPRINTF((tp, "%x", words[i]));
advance = snprintf(tp, (size_t)(ep - tp), "%x", words[i]);
if (advance <= 0 || advance >= ep - tp)
return (NULL);
tp += advance;
}
/* Was it a trailing run of 0x00's? */
if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ))
if (best.base != -1 && (best.base + best.len) ==
(NS_IN6ADDRSZ / NS_INT16SZ)) {
if (tp + 1 >= ep)
return (NULL);
*tp++ = ':';
}
if (tp + 1 >= ep)
return (NULL);
*tp++ = '\0';
/*
@ -186,7 +200,7 @@ inet_ntop6(const u_char *src, char *dst, size_t size)
errno = ENOSPC;
return (NULL);
}
strcpy(dst, tmp);
strlcpy(dst, tmp, size);
return (dst);
}
#endif

View file

@ -1,20 +1,21 @@
/* NetBSD: inet_pton.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
/* from NetBSD: inet_pton.c,v 1.16 2000/02/07 18:51:02 itojun Exp */
/* NetBSD: inet_pton.c,v 1.5 2005/06/01 11:48:49 lukem Exp */
/* from NetBSD: inet_pton.c,v 1.2 2004/05/20 23:12:33 christos Exp */
/* Copyright (c) 1996 by Internet Software Consortium.
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996,1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "tnftp.h"
@ -23,8 +24,16 @@
#include <arpa/nameser.h>
#endif
#ifndef INADDRSZ
#define INADDRSZ 4
#ifndef NS_INADDRSZ
#define NS_INADDRSZ 4
#endif
#ifndef NS_IN6ADDRSZ
#define NS_IN6ADDRSZ 16
#endif
#ifndef NS_INT16SZ
#define NS_INT16SZ 2
#endif
/*
@ -32,9 +41,9 @@
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
*/
static int inet_pton4(const char *src, u_char *dst, int pton);
static int inet_pton4(const char *src, unsigned char *dst, int pton);
#ifdef INET6
static int inet_pton6(const char *src, u_char *dst);
static int inet_pton6(const char *src, unsigned char *dst);
#endif
/* int
@ -78,14 +87,14 @@ inet_pton(int af, const char *src, void *dst)
* Paul Vixie, 1996.
*/
static int
inet_pton4(const char *src, u_char *dst, int pton)
inet_pton4(const char *src, unsigned char *dst, int pton)
{
u_int val;
u_int digit;
int base, n;
uint32_t val;
unsigned int digit, base;
int n;
unsigned char c;
u_int parts[4];
register u_int *pp = parts;
unsigned int parts[4];
unsigned int *pp = parts;
c = *src;
for (;;) {
@ -179,7 +188,7 @@ inet_pton4(const char *src, u_char *dst, int pton)
}
if (dst) {
val = htonl(val);
memcpy(dst, &val, INADDRSZ);
memcpy(dst, &val, NS_INADDRSZ);
}
return (1);
}
@ -199,17 +208,17 @@ inet_pton4(const char *src, u_char *dst, int pton)
* Paul Vixie, 1996.
*/
static int
inet_pton6(const char *src, u_char *dst)
inet_pton6(const char *src, unsigned char *dst)
{
static const char xdigits_l[] = "0123456789abcdef",
xdigits_u[] = "0123456789ABCDEF";
u_char tmp[IN6ADDRSZ], *tp, *endp, *colonp;
unsigned char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
const char *xdigits, *curtok;
int ch, saw_xdigit;
u_int val;
unsigned int val;
memset((tp = tmp), '\0', IN6ADDRSZ);
endp = tp + IN6ADDRSZ;
memset((tp = tmp), '\0', NS_IN6ADDRSZ);
endp = tp + NS_IN6ADDRSZ;
colonp = NULL;
/* Leading :: requires some special handling. */
if (*src == ':')
@ -242,25 +251,25 @@ inet_pton6(const char *src, u_char *dst)
return (0);
if (tp + INT16SZ > endp)
return (0);
*tp++ = (u_char) (val >> 8) & 0xff;
*tp++ = (u_char) val & 0xff;
*tp++ = (unsigned char) (val >> 8) & 0xff;
*tp++ = (unsigned char) val & 0xff;
saw_xdigit = 0;
val = 0;
continue;
}
if (ch == '.' && ((tp + INADDRSZ) <= endp) &&
if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
inet_pton4(curtok, tp, 1) > 0) {
tp += INADDRSZ;
tp += NS_INADDRSZ;
saw_xdigit = 0;
break; /* '\0' was seen by inet_pton4(). */
}
return (0);
}
if (saw_xdigit) {
if (tp + INT16SZ > endp)
if (tp + NS_INT16SZ > endp)
return (0);
*tp++ = (u_char) (val >> 8) & 0xff;
*tp++ = (u_char) val & 0xff;
*tp++ = (unsigned char) (val >> 8) & 0xff;
*tp++ = (unsigned char) val & 0xff;
}
if (colonp != NULL) {
/*
@ -280,7 +289,7 @@ inet_pton6(const char *src, u_char *dst)
}
if (tp != endp)
return (0);
memcpy(dst, tmp, IN6ADDRSZ);
memcpy(dst, tmp, NS_IN6ADDRSZ);
return (1);
}
#endif

View file

@ -1,5 +1,5 @@
/* NetBSD: mkstemp.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
/* from NetBSD: gettemp.c,v 1.5 1999/09/20 04:39:30 lukem Exp */
/* NetBSD: mkstemp.c,v 1.5 2005/06/01 11:48:49 lukem Exp */
/* from NetBSD: gettemp.c,v 1.13 2003/12/05 00:57:36 uebayasi Exp */
/*
* Copyright (c) 1987, 1993
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -41,7 +37,7 @@ mkstemp(char *path)
{
char *start, *trv;
struct stat sbuf;
u_int pid;
unsigned int pid;
int fd;
/* To guarantee multiple calls generate unique names even if
@ -60,9 +56,9 @@ mkstemp(char *path)
xcnt = 0;
/* Use at least one from xtra. Use 2 if more than 6 X's. */
if (*(trv-1) == 'X')
if (*(trv - 1) == 'X')
*--trv = xtra[0];
if (xcnt > 6 && *(trv-1) == 'X')
if (xcnt > 6 && *(trv - 1) == 'X')
*--trv = xtra[1];
/* Set remaining X's to pid digits with 0's to the left. */
@ -103,7 +99,7 @@ mkstemp(char *path)
}
for (;;) {
if ((fd = open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0)
if ((fd = open(path, O_CREAT | O_EXCL | O_RDWR, 0600)) >= 0)
return (fd);
if (errno != EEXIST)
return (-1);

View file

@ -1,5 +1,5 @@
/* NetBSD: sl_init.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
/* from NetBSD: stringlist.c,v 1.8 1999/11/28 03:44:09 lukem Exp */
/* NetBSD: sl_init.c,v 1.4 2005/05/16 06:37:47 lukem Exp */
/* from NetBSD: stringlist.c,v 1.10 2000/01/25 16:24:40 enami Exp */
/*-
* Copyright (c) 1994, 1999 The NetBSD Foundation, Inc.
@ -73,10 +73,11 @@ sl_add(StringList *sl, char *name)
if (sl->sl_cur == sl->sl_max - 1) {
char **new;
sl->sl_max += _SL_CHUNKSIZE;
new = (char **)realloc(sl->sl_str, sl->sl_max * sizeof(char *));
new = (char **)realloc(sl->sl_str,
(sl->sl_max + _SL_CHUNKSIZE) * sizeof(char *));
if (new == NULL)
return (-1);
sl->sl_max += _SL_CHUNKSIZE;
sl->sl_str = new;
}
sl->sl_str[sl->sl_cur++] = name;
@ -114,7 +115,7 @@ sl_find(StringList *sl, char *name)
for (i = 0; i < sl->sl_cur; i++)
if (strcmp(sl->sl_str[i], name) == 0)
return sl->sl_str[i];
return (sl->sl_str[i]);
return (NULL);
}

View file

@ -1,5 +1,5 @@
/* NetBSD: strdup.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
/* from NetBSD: strdup.c,v 1.11 1999/09/20 04:3 9:46 lukem Exp */
/* NetBSD: strdup.c,v 1.4 2005/05/16 06:40:04 lukem Exp */
/* from NetBSD: strdup.c,v 1.13 2003/08/07 16:43:50 agc Exp */
/*
* Copyright (c) 1988, 1993
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*

View file

@ -1,32 +1,21 @@
/* NetBSD: strlcat.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
/* from NetBSD: strlcat.c,v 1.5 1999/09/20 04:39:47 lukem Exp */
/* from OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp */
/* NetBSD: strlcat.c,v 1.4 2005/05/16 06:55:48 lukem Exp */
/* from NetBSD: strlcat.c,v 1.16 2003/10/27 00:12:42 lukem Exp */
/* from OpenBSD: strlcat.c,v 1.10 2003/04/12 21:56:39 millert Exp */
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE
* FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "tnftp.h"
@ -34,8 +23,9 @@
/*
* Appends src to string dst of size siz (unlike strncat, siz is the
* full size of dst, not space left). At most siz-1 characters
* will be copied. Always NUL terminates (unless siz == 0).
* Returns strlen(src); if retval >= siz, truncation occurred.
* will be copied. Always NUL terminates (unless siz <= strlen(dst)).
* Returns strlen(src) + MIN(siz, strlen(initial dst)).
* If retval >= siz, truncation occurred.
*/
size_t
strlcat(char *dst, const char *src, size_t siz)
@ -46,7 +36,7 @@ strlcat(char *dst, const char *src, size_t siz)
size_t dlen;
/* Find the end of dst and adjust bytes left but don't go past end */
while (*d != '\0' && n-- != 0)
while (n-- != 0 && *d != '\0')
d++;
dlen = d - dst;
n = siz - dlen;

View file

@ -1,32 +1,21 @@
/* NetBSD: strlcpy.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
/* from NetBSD: strlcpy.c,v 1.5 1999/09/20 04:39:47 lukem Exp */
/* from OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp */
/* NetBSD: strlcpy.c,v 1.4 2005/05/16 06:58:06 lukem Exp */
/* from NetBSD: strlcpy.c,v 1.14 2003/10/27 00:12:42 lukem Exp */
/* from OpenBSD: strlcpy.c,v 1.7 2003/04/12 21:56:39 millert Exp */
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE
* FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "tnftp.h"

View file

@ -1,5 +1,5 @@
/* NetBSD: strsep.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
/* from NetBSD: strsep.c,v 1.10 1999/09/20 04:39:48 lukem Exp */
/* NetBSD: strsep.c,v 1.4 2005/05/16 08:51:51 lukem Exp */
/* from NetBSD: strsep.c,v 1.14 2003/08/07 16:43:52 agc Exp */
/*-
* Copyright (c) 1990, 1993
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*

View file

@ -1,5 +1,5 @@
/* NetBSD: strtoll.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
/* from NetBSD: strtoq.c,v 1.14 1999/09/20 04:39:42 lukem Exp */
/* NetBSD: strtoll.c,v 1.4 2005/05/16 11:27:58 lukem Exp */
/* from NetBSD: strtoll.c,v 1.6 2003/10/27 00:12:42 lukem Exp */
/*-
* Copyright (c) 1992, 1993
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -37,16 +33,17 @@
#include "tnftp.h"
/*
* Convert a string to a quad integer.
* Convert a string to a long long integer.
*
* Ignores `locale' stuff. Assumes that the upper and lower case
* alphabets and digits are each contiguous.
*/
long long
long long int
strtoll(const char *nptr, char **endptr, int base)
{
const char *s;
long long acc, cutoff;
/* LONGLONG */
long long int acc, cutoff;
int c;
int neg, any, cutlim;
@ -90,7 +87,7 @@ strtoll(const char *nptr, char **endptr, int base)
* followed by a legal input character, is too big. One that
* is equal to this value may be valid or not; the limit
* between valid and invalid numbers is then based on the last
* digit. For instance, if the range for quads is
* digit. For instance, if the range for long longs is
* [-9223372036854775808..9223372036854775807] and the input base
* is 10, cutoff will be set to 922337203685477580 and cutlim to
* either 7 (neg==0) or 8 (neg==1), meaning that if we have
@ -101,7 +98,7 @@ strtoll(const char *nptr, char **endptr, int base)
* Set any if any `digits' consumed; make it negative to indicate
* overflow.
*/
cutoff = neg ? QUAD_MIN : QUAD_MAX;
cutoff = neg ? LLONG_MIN : LLONG_MAX;
cutlim = (int)(cutoff % base);
cutoff /= base;
if (neg) {
@ -125,7 +122,7 @@ strtoll(const char *nptr, char **endptr, int base)
if (neg) {
if (acc < cutoff || (acc == cutoff && c > cutlim)) {
any = -1;
acc = QUAD_MIN;
acc = LLONG_MIN;
errno = ERANGE;
} else {
any = 1;
@ -135,7 +132,7 @@ strtoll(const char *nptr, char **endptr, int base)
} else {
if (acc > cutoff || (acc == cutoff && c > cutlim)) {
any = -1;
acc = QUAD_MAX;
acc = LLONG_MAX;
errno = ERANGE;
} else {
any = 1;

View file

@ -1,5 +1,5 @@
/* NetBSD: strunvis.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
/* from NetBSD: unvis.c,v 1.16 1999/09/20 04:39:06 lukem Exp */
/* NetBSD: strunvis.c,v 1.5 2005/06/01 11:48:49 lukem Exp */
/* from NetBSD: unvis.c,v 1.27 2005/05/16 11:42:04 lukem Exp */
/*-
* Copyright (c) 1989, 1993
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -46,8 +42,11 @@
#define S_CTRL 4 /* control char started (^) */
#define S_OCTAL2 5 /* octal digit 2 */
#define S_OCTAL3 6 /* octal digit 3 */
#define S_HEX1 7 /* hex digit */
#define S_HEX2 8 /* hex digit 2 */
#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
#define isoctal(c) (((unsigned char)(c)) >= '0' && ((unsigned char)(c)) <= '7')
#define xtod(c) (isdigit(c) ? (c - '0') : ((tolower(c) - 'a') + 10))
/*
* unvis - decode characters previously encoded by vis
@ -55,12 +54,14 @@
int
unvis(char *cp, int c, int *astate, int flag)
{
unsigned char uc = (unsigned char)c;
if (flag & UNVIS_END) {
if (*astate == S_OCTAL2 || *astate == S_OCTAL3) {
if (*astate == S_OCTAL2 || *astate == S_OCTAL3
|| *astate == S_HEX2) {
*astate = S_GROUND;
return (UNVIS_VALID);
}
}
return (*astate == S_GROUND ? UNVIS_NOCHAR : UNVIS_SYNBAD);
}
@ -71,7 +72,11 @@ unvis(char *cp, int c, int *astate, int flag)
if (c == '\\') {
*astate = S_START;
return (0);
}
}
if ((flag & VIS_HTTPSTYLE) && c == '%') {
*astate = S_HEX1;
return (0);
}
*cp = c;
return (UNVIS_VALID);
@ -144,7 +149,7 @@ unvis(char *cp, int c, int *astate, int flag)
}
*astate = S_GROUND;
return (UNVIS_SYNBAD);
case S_META:
if (c == '-')
*astate = S_META1;
@ -155,12 +160,12 @@ unvis(char *cp, int c, int *astate, int flag)
return (UNVIS_SYNBAD);
}
return (0);
case S_META1:
*astate = S_GROUND;
*cp |= c;
return (UNVIS_VALID);
case S_CTRL:
if (c == '?')
*cp |= 0177;
@ -170,23 +175,23 @@ unvis(char *cp, int c, int *astate, int flag)
return (UNVIS_VALID);
case S_OCTAL2: /* second possible octal digit */
if (isoctal(c)) {
/*
* yes - and maybe a third
if (isoctal(uc)) {
/*
* yes - and maybe a third
*/
*cp = (*cp << 3) + (c - '0');
*astate = S_OCTAL3;
*astate = S_OCTAL3;
return (0);
}
/*
* no - done with current sequence, push back passed char
}
/*
* no - done with current sequence, push back passed char
*/
*astate = S_GROUND;
return (UNVIS_VALIDPUSH);
case S_OCTAL3: /* third possible octal digit */
*astate = S_GROUND;
if (isoctal(c)) {
if (isoctal(uc)) {
*cp = (*cp << 3) + (c - '0');
return (UNVIS_VALID);
}
@ -194,10 +199,30 @@ unvis(char *cp, int c, int *astate, int flag)
* we were done, push back passed char
*/
return (UNVIS_VALIDPUSH);
default:
/*
* decoder in unknown state - (probably uninitialized)
case S_HEX1:
if (isxdigit(uc)) {
*cp = xtod(uc);
*astate = S_HEX2;
return (0);
}
/*
* no - done with current sequence, push back passed char
*/
*astate = S_GROUND;
return (UNVIS_VALIDPUSH);
case S_HEX2:
*astate = S_GROUND;
if (isxdigit(uc)) {
*cp = xtod(uc) | (*cp << 4);
return (UNVIS_VALID);
}
return (UNVIS_VALIDPUSH);
default:
/*
* decoder in unknown state - (probably uninitialized)
*/
*astate = S_GROUND;
return (UNVIS_SYNBAD);
@ -205,22 +230,22 @@ unvis(char *cp, int c, int *astate, int flag)
}
/*
* strunvis - decode src into dst
* strunvis - decode src into dst
*
* Number of chars decoded into dst is returned, -1 on error.
* Dst is null terminated.
*/
int
strunvis(char *dst, const char *src)
strunvisx(char *dst, const char *src, int flag)
{
char c;
char *start = dst;
int state = 0;
while ((c = *src++) != '\0') {
again:
switch (unvis(dst, c, &state, 0)) {
again:
switch (unvis(dst, c, &state, flag)) {
case UNVIS_VALID:
dst++;
break;
@ -239,3 +264,9 @@ strunvis(char *dst, const char *src)
*dst = '\0';
return (dst - start);
}
int
strunvis(char *dst, const char *src)
{
return strunvisx(dst, src, 0);
}

View file

@ -1,5 +1,5 @@
/* NetBSD: strvis.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
/* from NetBSD: vis.c,v 1.13 1999/09/20 04:39:07 lukem Exp */
/* NetBSD: strvis.c,v 1.8 2005/06/01 11:48:49 lukem Exp */
/* from NetBSD: vis.c,v 1.33 2005/05/28 13:11:14 lukem Exp */
/*-
* Copyright (c) 1989, 1993
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -34,9 +30,260 @@
* SUCH DAMAGE.
*/
/*-
* Copyright (c) 1999, 2005 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "tnftp.h"
#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
#undef BELL
#define BELL '\a'
#define isoctal(c) (((unsigned char)(c)) >= '0' && ((unsigned char)(c)) <= '7')
#define iswhite(c) (c == ' ' || c == '\t' || c == '\n')
#define issafe(c) (c == '\b' || c == BELL || c == '\r')
#define xtoa(c) "0123456789abcdef"[c]
#define MAXEXTRAS 5
#define MAKEEXTRALIST(flag, extra, orig) \
do { \
const char *o = orig; \
char *e; \
while (*o++) \
continue; \
extra = malloc((size_t)((o - orig) + MAXEXTRAS)); \
if (!extra) break; \
for (o = orig, e = extra; (*e++ = *o++) != '\0';) \
continue; \
e--; \
if (flag & VIS_SP) *e++ = ' '; \
if (flag & VIS_TAB) *e++ = '\t'; \
if (flag & VIS_NL) *e++ = '\n'; \
if ((flag & VIS_NOSLASH) == 0) *e++ = '\\'; \
*e = '\0'; \
} while (/*CONSTCOND*/0)
/*
* This is HVIS, the macro of vis used to HTTP style (RFC 1808)
*/
#define HVIS(dst, c, flag, nextc, extra) \
do \
if (!isascii(c) || !isalnum(c) || strchr("$-_.+!*'(),", c) != NULL) { \
*dst++ = '%'; \
*dst++ = xtoa(((unsigned int)c >> 4) & 0xf); \
*dst++ = xtoa((unsigned int)c & 0xf); \
} else { \
SVIS(dst, c, flag, nextc, extra); \
} \
while (/*CONSTCOND*/0)
/*
* This is SVIS, the central macro of vis.
* dst: Pointer to the destination buffer
* c: Character to encode
* flag: Flag word
* nextc: The character following 'c'
* extra: Pointer to the list of extra characters to be
* backslash-protected.
*/
#define SVIS(dst, c, flag, nextc, extra) \
do { \
int isextra; \
isextra = strchr(extra, c) != NULL; \
if (!isextra && isascii(c) && (isgraph(c) || iswhite(c) || \
((flag & VIS_SAFE) && issafe(c)))) { \
*dst++ = c; \
break; \
} \
if (flag & VIS_CSTYLE) { \
switch (c) { \
case '\n': \
*dst++ = '\\'; *dst++ = 'n'; \
continue; \
case '\r': \
*dst++ = '\\'; *dst++ = 'r'; \
continue; \
case '\b': \
*dst++ = '\\'; *dst++ = 'b'; \
continue; \
case BELL: \
*dst++ = '\\'; *dst++ = 'a'; \
continue; \
case '\v': \
*dst++ = '\\'; *dst++ = 'v'; \
continue; \
case '\t': \
*dst++ = '\\'; *dst++ = 't'; \
continue; \
case '\f': \
*dst++ = '\\'; *dst++ = 'f'; \
continue; \
case ' ': \
*dst++ = '\\'; *dst++ = 's'; \
continue; \
case '\0': \
*dst++ = '\\'; *dst++ = '0'; \
if (isoctal(nextc)) { \
*dst++ = '0'; \
*dst++ = '0'; \
} \
continue; \
default: \
if (isgraph(c)) { \
*dst++ = '\\'; *dst++ = c; \
continue; \
} \
} \
} \
if (isextra || ((c & 0177) == ' ') || (flag & VIS_OCTAL)) { \
*dst++ = '\\'; \
*dst++ = (unsigned char)(((uint32_t)(unsigned char)c >> 6) & 03) + '0'; \
*dst++ = (unsigned char)(((uint32_t)(unsigned char)c >> 3) & 07) + '0'; \
*dst++ = (c & 07) + '0'; \
} else { \
if ((flag & VIS_NOSLASH) == 0) *dst++ = '\\'; \
if (c & 0200) { \
c &= 0177; *dst++ = 'M'; \
} \
if (iscntrl(c)) { \
*dst++ = '^'; \
if (c == 0177) \
*dst++ = '?'; \
else \
*dst++ = c + '@'; \
} else { \
*dst++ = '-'; *dst++ = c; \
} \
} \
} while (/*CONSTCOND*/0)
/*
* svis - visually encode characters, also encoding the characters
* pointed to by `extra'
*/
char *
svis(char *dst, int c, int flag, int nextc, const char *extra)
{
char *nextra = NULL;
MAKEEXTRALIST(flag, nextra, extra);
if (!nextra) {
*dst = '\0'; /* can't create nextra, return "" */
return dst;
}
if (flag & VIS_HTTPSTYLE)
HVIS(dst, c, flag, nextc, nextra);
else
SVIS(dst, c, flag, nextc, nextra);
free(nextra);
*dst = '\0';
return dst;
}
/*
* strsvis, strsvisx - visually encode characters from src into dst
*
* Extra is a pointer to a \0-terminated list of characters to
* be encoded, too. These functions are useful e. g. to
* encode strings in such a way so that they are not interpreted
* by a shell.
*
* Dst must be 4 times the size of src to account for possible
* expansion. The length of dst, not including the trailing NULL,
* is returned.
*
* Strsvisx encodes exactly len bytes from src into dst.
* This is useful for encoding a block of data.
*/
int
strsvis(char *dst, const char *csrc, int flag, const char *extra)
{
int c;
char *start;
char *nextra = NULL;
const unsigned char *src = (const unsigned char *)csrc;
MAKEEXTRALIST(flag, nextra, extra);
if (!nextra) {
*dst = '\0'; /* can't create nextra, return "" */
return 0;
}
if (flag & VIS_HTTPSTYLE) {
for (start = dst; (c = *src++) != '\0'; /* empty */)
HVIS(dst, c, flag, *src, nextra);
} else {
for (start = dst; (c = *src++) != '\0'; /* empty */)
SVIS(dst, c, flag, *src, nextra);
}
free(nextra);
*dst = '\0';
return (dst - start);
}
int
strsvisx(char *dst, const char *csrc, size_t len, int flag, const char *extra)
{
unsigned char c;
char *start;
char *nextra = NULL;
const unsigned char *src = (const unsigned char *)csrc;
MAKEEXTRALIST(flag, nextra, extra);
if (! nextra) {
*dst = '\0'; /* can't create nextra, return "" */
return 0;
}
if (flag & VIS_HTTPSTYLE) {
for (start = dst; len > 0; len--) {
c = *src++;
HVIS(dst, c, flag, len ? *src : '\0', nextra);
}
} else {
for (start = dst; len > 0; len--) {
c = *src++;
SVIS(dst, c, flag, len ? *src : '\0', nextra);
}
}
free(nextra);
*dst = '\0';
return (dst - start);
}
/*
* vis - visually encode characters
@ -44,97 +291,30 @@
char *
vis(char *dst, int c, int flag, int nextc)
{
char *extra = NULL;
unsigned char uc = (unsigned char)c;
if (((u_int)c <= UCHAR_MAX && isascii(c) && isgraph(c)) ||
((flag & VIS_SP) == 0 && c == ' ') ||
((flag & VIS_TAB) == 0 && c == '\t') ||
((flag & VIS_NL) == 0 && c == '\n') ||
((flag & VIS_SAFE) && (c == '\b' || c == '\007' || c == '\r'))) {
*dst++ = c;
if (c == '\\' && (flag & VIS_NOSLASH) == 0)
*dst++ = '\\';
*dst = '\0';
return (dst);
MAKEEXTRALIST(flag, extra, "");
if (! extra) {
*dst = '\0'; /* can't create extra, return "" */
return dst;
}
if (flag & VIS_CSTYLE) {
switch(c) {
case '\n':
*dst++ = '\\';
*dst++ = 'n';
goto done;
case '\r':
*dst++ = '\\';
*dst++ = 'r';
goto done;
case '\b':
*dst++ = '\\';
*dst++ = 'b';
goto done;
case '\a':
*dst++ = '\\';
*dst++ = 'a';
goto done;
case '\v':
*dst++ = '\\';
*dst++ = 'v';
goto done;
case '\t':
*dst++ = '\\';
*dst++ = 't';
goto done;
case '\f':
*dst++ = '\\';
*dst++ = 'f';
goto done;
case ' ':
*dst++ = '\\';
*dst++ = 's';
goto done;
case '\0':
*dst++ = '\\';
*dst++ = '0';
if (isoctal(nextc)) {
*dst++ = '0';
*dst++ = '0';
}
goto done;
}
}
if (((c & 0177) == ' ') || (flag & VIS_OCTAL)) {
*dst++ = '\\';
*dst++ = ((((unsigned int)c) >> 6) & 07) + '0';
*dst++ = ((((unsigned int)c) >> 3) & 07) + '0';
*dst++ = (((u_char)c) & 07) + '0';
goto done;
}
if ((flag & VIS_NOSLASH) == 0)
*dst++ = '\\';
if (c & 0200) {
c &= 0177;
*dst++ = 'M';
}
if (iscntrl(c)) {
*dst++ = '^';
if (c == 0177)
*dst++ = '?';
else
*dst++ = c + '@';
} else {
*dst++ = '-';
*dst++ = c;
}
done:
if (flag & VIS_HTTPSTYLE)
HVIS(dst, uc, flag, nextc, extra);
else
SVIS(dst, uc, flag, nextc, extra);
free(extra);
*dst = '\0';
return (dst);
return dst;
}
/*
* strvis, strvisx - visually encode characters from src into dst
*
*
* Dst must be 4 times the size of src to account for possible
* expansion. The length of dst, not including the trailing NULL,
* is returned.
* is returned.
*
* Strvisx encodes exactly len bytes from src into dst.
* This is useful for encoding a block of data.
@ -142,28 +322,32 @@ done:
int
strvis(char *dst, const char *src, int flag)
{
char c;
char *start;
char *extra = NULL;
int rv;
for (start = dst; (c = *src) != '\0';)
dst = vis(dst, c, flag, *++src);
*dst = '\0';
return (dst - start);
MAKEEXTRALIST(flag, extra, "");
if (!extra) {
*dst = '\0'; /* can't create extra, return "" */
return 0;
}
rv = strsvis(dst, src, flag, extra);
free(extra);
return rv;
}
int
strvisx(char *dst, const char *src, size_t len, int flag)
{
char c;
char *start;
char *extra = NULL;
int rv;
for (start = dst; len > 1; len--) {
c = *src;
dst = vis(dst, c, flag, *++src);
MAKEEXTRALIST(flag, extra, "");
if (!extra) {
*dst = '\0'; /* can't create extra, return "" */
return 0;
}
if (len)
dst = vis(dst, *src, flag, '\0');
*dst = '\0';
return (dst - start);
rv = strsvisx(dst, src, len, flag, extra);
free(extra);
return rv;
}

View file

@ -1,7 +1,7 @@
/* NetBSD: usleep.c,v 1.3 2005/05/11 01:01:56 lukem Exp */
/* NetBSD: usleep.c,v 1.4 2005/05/16 13:21:43 lukem Exp */
/*-
* Copyright (c) 1999-2000 The NetBSD Foundation, Inc.
* Copyright (c) 1999,2000,2005 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -41,14 +41,14 @@
int
usleep(unsigned int usec)
{
#if HAVE_SELECT
#if HAVE_POLL
return (poll(NULL, 0, usec / 1000);
#elif HAVE_SELECT
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = usec;
return (select(1, NULL, NULL, NULL, &tv));
#elif HAVE_POLL
return (poll(NULL, 0, usec / 1000);
#else
# error no way to implement usleep
#endif

View file

@ -1,4 +1,4 @@
# NetBSD: Makefile.in,v 1.3 2005/05/11 03:01:40 lukem Exp
# NetBSD: Makefile.in,v 1.5 2005/06/10 04:36:12 lukem Exp
#
srcdir = @srcdir@
@ -14,27 +14,35 @@ transform = @program_transform_name@
mandircat1 = ${mandir}/cat1
CC = @CC@
CFLAGS = -I${srcdir} -I${srcdir}/.. -I. -I.. @INCLUDES@ @CFLAGS@
CFLAGS = @CFLAGS@
CPPFLAGS= -I${srcdir} -I${srcdir}/.. -I. -I.. @INCLUDES@ @CPPFLAGS@
LIBS = @LIBS@
LDFLAGS = @LDFLAGS@
INSTALL = @INSTALL@
PROG = ftp
OBJS = cmds.o cmdtab.o complete.o domacro.o fetch.o ftp.o main.o \
progressbar.o ruserpass.o util.o
SRCS = cmds.c cmdtab.c complete.c domacro.c fetch.c ftp.c main.c \
progressbar.c ruserpass.c util.c
OBJS = ${SRCS:.c=.o}
all: ${PROG}
${PROG}: ${OBJS} @LIBDEPENDS@
${CC} ${CFLAGS} ${LDFLAGS} -o ${PROG} ${OBJS} ${LIBS}
${OBJS}: ${srcdir}/../tnftp.h ../config.h
.c.o:
${CC} ${CFLAGS} ${CPPFLAGS} -c $<
install: all
-mkdir -p ${bindir}
${INSTALL} -m 555 ${PROG} ${bindir}/`echo ${PROG}|sed '$(transform)'`
-mkdir -p ${mandircat1}
${INSTALL} -m 444 ${srcdir}/${PROG}.cat1 ${mandircat1}/`echo ${PROG}|sed '$(transform)'`.1
${PROG}: ${OBJS} @LIBDEPENDS@
${CC} ${CFLAGS} ${LDFLAGS} -o ${PROG} ${OBJS} ${LIBS}
clean:
rm -f core ${PROG} ${OBJS}

View file

@ -1,5 +1,5 @@
/* NetBSD: cmds.c,v 1.6 2005/05/11 02:41:28 lukem Exp */
/* from NetBSD: cmds.c,v 1.112 2005/04/11 01:49:31 lukem Exp */
/* NetBSD: cmds.c,v 1.9 2005/06/10 04:05:01 lukem Exp */
/* from NetBSD: cmds.c,v 1.115 2005/06/10 00:18:46 lukem Exp */
/*-
* Copyright (c) 1996-2005 The NetBSD Foundation, Inc.
@ -99,17 +99,6 @@
* SUCH DAMAGE.
*/
#if 0
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94";
#else
__RCSID("NetBSD: cmds.c,v 1.6 2005/05/11 02:41:28 lukem Exp");
#endif
#endif /* not lint */
#endif
/*
* FTP User Program -- Command Routines.
*/
@ -146,6 +135,7 @@ static const char *dotrans(char *, size_t, const char *);
static int
confirm(const char *cmd, const char *file)
{
const char *errormsg;
char line[BUFSIZ];
if (!interactive || confirmrest)
@ -153,10 +143,9 @@ confirm(const char *cmd, const char *file)
while (1) {
fprintf(ttyout, "%s %s [anpqy?]? ", cmd, file);
(void)fflush(ttyout);
if (fgets(line, sizeof(line), stdin) == NULL) {
if (getline(stdin, line, sizeof(line), &errormsg) < 0) {
mflag = 0;
fprintf(ttyout, "\nEOF received; %s aborted\n", mname);
clearerr(stdin);
fprintf(ttyout, "%s; %s aborted\n", errormsg, mname);
return (0);
}
switch (tolower((unsigned char)*line)) {
@ -764,7 +753,7 @@ fget(int argc, char *argv[])
fclose(fp);
}
char *
const char *
onoff(int bool)
{
@ -1319,7 +1308,7 @@ ls(int argc, char *argv[])
if (pagecmd) {
char *p;
int len;
size_t len;
p = getoptionvalue("pager");
if (EMPTYSTRING(p))
@ -1460,7 +1449,7 @@ shell(int argc, char *argv[])
void
user(int argc, char *argv[])
{
char acct[80];
char *password;
int n, aflag = 0;
if (argc == 0)
@ -1477,34 +1466,31 @@ user(int argc, char *argv[])
n = command("USER %s", argv[1]);
if (n == CONTINUE) {
if (argc < 3) {
argv[2] = getpass("Password: ");
argc++;
password = getpass("Password: ");
} else {
password = argv[2];
}
n = command("PASS %s", argv[2]);
n = command("PASS %s", password);
memset(password, 0, strlen(password));
}
if (n == CONTINUE) {
if (argc < 4) {
(void)fputs("Account: ", ttyout);
(void)fflush(ttyout);
if (fgets(acct, sizeof(acct) - 1, stdin) == NULL) {
fprintf(ttyout,
"\nEOF received; login aborted.\n");
clearerr(stdin);
code = -1;
return;
}
acct[strlen(acct) - 1] = '\0';
argv[3] = acct; argc++;
}
n = command("ACCT %s", argv[3]);
aflag++;
if (argc < 4) {
password = getpass("Account: ");
} else {
password = argv[3];
}
n = command("ACCT %s", password);
memset(password, 0, strlen(password));
}
if (n != COMPLETE) {
fputs("Login failed.\n", ttyout);
return;
}
if (!aflag && argc == 4) {
(void)command("ACCT %s", argv[3]);
password = argv[3];
(void)command("ACCT %s", password);
memset(password, 0, strlen(password));
}
connected = -1;
getremoteinfo();
@ -2513,7 +2499,7 @@ newer(int argc, char *argv[])
void
lpage(int argc, char *argv[])
{
int len;
size_t len;
char *p, *pager, *locfile;
if (argc == 0 || argc > 2 ||
@ -2546,7 +2532,8 @@ lpage(int argc, char *argv[])
void
page(int argc, char *argv[])
{
int ohash, orestart_point, overbose, len;
int ohash, orestart_point, overbose;
size_t len;
char *p, *pager;
if (argc == 0 || argc > 2 ||

View file

@ -1,8 +1,8 @@
/* NetBSD: cmdtab.c,v 1.5 2005/05/11 02:41:28 lukem Exp */
/* from NetBSD: cmdtab.c,v 1.44 2005/04/11 01:49:31 lukem Exp */
/* NetBSD: cmdtab.c,v 1.7 2005/06/10 04:05:01 lukem Exp */
/* from NetBSD: cmdtab.c,v 1.45 2005/06/09 16:38:29 lukem Exp */
/*-
* Copyright (c) 1996-2000 The NetBSD Foundation, Inc.
* Copyright (c) 1996-2005 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -66,17 +66,6 @@
* SUCH DAMAGE.
*/
#if 0
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)cmdtab.c 8.4 (Berkeley) 10/9/94";
#else
__RCSID("NetBSD: cmdtab.c,v 1.5 2005/05/11 02:41:28 lukem Exp");
#endif
#endif /* not lint */
#endif
#include "tnftp.h"
#include "ftp_var.h"

View file

@ -1,8 +1,8 @@
/* NetBSD: complete.c,v 1.3 2005/05/11 02:41:28 lukem Exp */
/* from NetBSD: complete.c,v 1.38 2000/05/01 10:35:17 lukem Exp */
/* NetBSD: complete.c,v 1.6 2005/06/10 04:05:01 lukem Exp */
/* from NetBSD: complete.c,v 1.40 2005/06/09 16:38:29 lukem Exp */
/*-
* Copyright (c) 1997-2000 The NetBSD Foundation, Inc.
* Copyright (c) 1997-2000,2005 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,13 +37,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#if 0
#include <sys/cdefs.h>
#ifndef lint
__RCSID("NetBSD: complete.c,v 1.3 2005/05/11 02:41:28 lukem Exp");
#endif /* not lint */
#endif
/*
* FTP user program - command and file completion routines
*/
@ -64,7 +57,7 @@ static unsigned char complete_remote (char *, int);
static int
comparstr(const void *a, const void *b)
{
return (strcmp(*(const char **)a, *(const char **)b));
return (strcmp(*(const char * const *)a, *(const char * const *)b));
}
/*
@ -300,7 +293,7 @@ complete_remote(char *word, int list)
if (dirchange || dirlist == NULL ||
strcmp(dir, lastdir) != 0) { /* dir not cached */
char *emesg;
const char *emesg;
if (dirlist != NULL)
sl_free(dirlist, 1);

View file

@ -1,4 +1,4 @@
/* NetBSD: domacro.c,v 1.4 2005/05/11 02:41:28 lukem Exp */
/* NetBSD: domacro.c,v 1.5 2005/06/09 16:47:50 lukem Exp */
/* from NetBSD: domacro.c,v 1.20 2003/08/07 11:13:53 agc Exp */
/*
@ -30,17 +30,6 @@
* SUCH DAMAGE.
*/
#if 0
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)domacro.c 8.3 (Berkeley) 4/2/94";
#else
__RCSID("NetBSD: domacro.c,v 1.4 2005/05/11 02:41:28 lukem Exp");
#endif
#endif /* not lint */
#endif
#include "tnftp.h"
#include "ftp_var.h"

View file

@ -1,5 +1,5 @@
/* NetBSD: extern.h,v 1.5 2005/05/11 02:41:28 lukem Exp */
/* from NetBSD: extern.h,v 1.66 2005/04/11 01:49:31 lukem Exp */
/* NetBSD: extern.h,v 1.7 2005/06/10 04:05:01 lukem Exp */
/* from NetBSD: extern.h,v 1.69 2005/06/10 00:18:46 lukem Exp */
/*-
* Copyright (c) 1996-2005 The NetBSD Foundation, Inc.
@ -142,6 +142,7 @@ int ftp_login(const char *, const char *, const char *);
void get(int, char **);
struct cmd *getcmd(const char *);
int getit(int, char **, int, const char *);
int getline(FILE *, char *, size_t, const char **);
struct option *getoption(const char *);
char *getoptionvalue(const char *);
void getremoteinfo(void);
@ -171,7 +172,7 @@ void mls(int, char **);
void mlst(int, char **);
void modtime(int, char **);
void mput(int, char **);
char *onoff(int);
const char *onoff(int);
void opts(int, char **);
void newer(int, char **);
void page(int, char **);
@ -190,7 +191,7 @@ void quote1(const char *, int, char **);
void recvrequest(const char *, const char *, const char *,
const char *, int, int);
void reget(int, char **);
char *remglob(char **, int, char **);
char *remglob(char **, int, const char **);
time_t remotemodtime(const char *, int);
off_t remotesize(const char *, int);
void removedir(int, char **);
@ -200,8 +201,7 @@ void restart(int, char **);
void rmthelp(int, char **);
void rmtstatus(int, char **);
char *rprompt(void);
int ruserpass(const char *, const char **, const char **,
const char **);
int ruserpass(const char *, char **, char **, char **);
void sendrequest(const char *, const char *, const char *, int);
void setascii(int, char **);
void setbell(int, char **);
@ -249,7 +249,7 @@ void updatelocalcwd(void);
void updateremotecwd(void);
void usage(void);
void user(int, char **);
int xconnect(int, const struct sockaddr *, int);
int xconnect(int, const struct sockaddr *, socklen_t);
int xlisten(int, int);
int xpoll(struct pollfd *, int, int);
void *xmalloc(size_t);

View file

@ -1,8 +1,8 @@
/* NetBSD: fetch.c,v 1.7 2005/05/11 02:41:28 lukem Exp */
/* from NetBSD: fetch.c,v 1.157 2005/04/11 01:49:31 lukem Exp */
/* NetBSD: fetch.c,v 1.11 2005/06/10 04:05:01 lukem Exp */
/* from NetBSD: fetch.c,v 1.162 2005/06/10 00:18:46 lukem Exp */
/*-
* Copyright (c) 1997-2004 The NetBSD Foundation, Inc.
* Copyright (c) 1997-2005 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -40,13 +40,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#if 0
#include <sys/cdefs.h>
#ifndef lint
__RCSID("NetBSD: fetch.c,v 1.7 2005/05/11 02:41:28 lukem Exp");
#endif /* not lint */
#endif
/*
* FTP User Program -- Command line file retrieval
*/
@ -129,7 +122,7 @@ static int
auth_url(const char *challenge, char **response, const char *guser,
const char *gpass)
{
const char *cp, *scheme;
const char *cp, *scheme, *errormsg;
char *ep, *clear, *realm;
char user[BUFSIZ], *pass;
int rval;
@ -176,8 +169,8 @@ auth_url(const char *challenge, char **response, const char *guser,
fprintf(ttyout, "%s\n", user);
} else {
(void)fflush(ttyout);
if (fgets(user, sizeof(user) - 1, stdin) == NULL) {
clearerr(stdin);
if (getline(stdin, user, sizeof(user), &errormsg) < 0) {
warnx("%s; can't authenticate", errormsg);
goto cleanup_auth_url;
}
user[strlen(user) - 1] = '\0';
@ -201,7 +194,8 @@ auth_url(const char *challenge, char **response, const char *guser,
(void)strlcpy(*response, scheme, rlen);
len = strlcat(*response, " ", rlen);
/* use `clen - 1' to not encode the trailing NUL */
base64_encode(clear, clen - 1, (unsigned char *)*response + len);
base64_encode((unsigned char *)clear, clen - 1,
(unsigned char *)*response + len);
memset(clear, 0, clen);
rval = 0;
@ -332,6 +326,8 @@ parse_url(const char *url, const char *desc, url_t *type,
warnx("Invalid %s `%s'", desc, url);
cleanup_parse_url:
FREEPTR(*user);
if (*pass != NULL)
memset(*pass, 0, strlen(*pass));
FREEPTR(*pass);
FREEPTR(*host);
FREEPTR(*port);
@ -677,7 +673,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
hints.ai_protocol = 0;
error = getaddrinfo(host, NULL, &hints, &res0);
if (error) {
warnx("%s", gai_strerror(error));
warnx("%s: %s", host, gai_strerror(error));
goto cleanup_fetch_url;
}
if (res0->ai_canonname)
@ -693,8 +689,9 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST) != 0)
strlcpy(hbuf, "invalid", sizeof(hbuf));
if (verbose && res != res0)
if (verbose && res0->ai_next) {
fprintf(ttyout, "Trying %s...\n", hbuf);
}
((struct sockaddr_in *)res->ai_addr)->sin_port =
htons(portnum);
@ -1037,9 +1034,8 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
fprintf(ttyout,
"Authorization failed. Retry (y/n)? ");
if (fgets(reply, sizeof(reply), stdin)
== NULL) {
clearerr(stdin);
if (getline(stdin, reply, sizeof(reply), NULL)
< 0) {
goto cleanup_fetch_url;
}
if (tolower((unsigned char)reply[0]) != 'y')
@ -1261,12 +1257,16 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
freeaddrinfo(res0);
FREEPTR(savefile);
FREEPTR(user);
if (pass != NULL)
memset(pass, 0, strlen(pass));
FREEPTR(pass);
FREEPTR(host);
FREEPTR(port);
FREEPTR(path);
FREEPTR(decodedpath);
FREEPTR(puser);
if (ppass != NULL)
memset(ppass, 0, strlen(ppass));
FREEPTR(ppass);
FREEPTR(buf);
FREEPTR(auth);
@ -1282,7 +1282,7 @@ void
aborthttp(int notused)
{
char msgbuf[100];
int len;
size_t len;
sigint_raised = 1;
alarmtimer(0);
@ -1302,7 +1302,8 @@ fetch_ftp(const char *url)
char *cp, *xargv[5], rempath[MAXPATHLEN];
char *host, *path, *dir, *file, *user, *pass;
char *port;
int dirhasglob, filehasglob, oautologin, rval, type, xargc;
int dirhasglob, filehasglob, rval, type, xargc;
int oanonftp, oautologin;
in_port_t portnum;
url_t urltype;
@ -1420,8 +1421,10 @@ fetch_ftp(const char *url)
}
/* Set up the connection */
oanonftp = anonftp;
if (connected)
disconnect(0, NULL);
anonftp = oanonftp;
xargv[0] = (char *)getprogname(); /* XXX discards const */
xargv[1] = host;
xargv[2] = NULL;
@ -1610,6 +1613,8 @@ fetch_ftp(const char *url)
FREEPTR(host);
FREEPTR(path);
FREEPTR(user);
if (pass)
memset(pass, 0, strlen(pass));
FREEPTR(pass);
return (rval);
}
@ -1700,10 +1705,9 @@ go_fetch(const char *url)
int
auto_fetch(int argc, char *argv[])
{
volatile int argpos;
int rval;
volatile int argpos, rval;
argpos = 0;
argpos = rval = 0;
if (sigsetjmp(toplevel, 1)) {
if (connected)
@ -1718,7 +1722,7 @@ auto_fetch(int argc, char *argv[])
/*
* Loop through as long as there's files to fetch.
*/
for (rval = 0; (rval == 0) && (argpos < argc); argpos++) {
for (; (rval == 0) && (argpos < argc); argpos++) {
if (strchr(argv[argpos], ':') == NULL)
break;
redirect_loop = 0;
@ -1742,7 +1746,8 @@ int
auto_put(int argc, char **argv, const char *uploadserver)
{
char *uargv[4], *path, *pathsep;
int uargc, rval, len;
int uargc, rval;
size_t len;
uargc = 0;
uargv[uargc++] = "mput";
@ -1761,8 +1766,6 @@ auto_put(int argc, char **argv, const char *uploadserver)
* make sure we always pass a directory to auto_fetch
*/
if (argc > 1) { /* more than one file to upload */
int len;
len = strlen(uploadserver) + 2; /* path + "/" + "\0" */
free(path);
path = (char *)xmalloc(len);

View file

@ -1,5 +1,5 @@
/* NetBSD: ftp.c,v 1.7 2005/05/14 03:53:28 lukem Exp */
/* from NetBSD: ftp.c,v 1.131 2005/05/13 05:03:49 lukem Exp */
/* NetBSD: ftp.c,v 1.11 2005/06/10 04:05:01 lukem Exp */
/* from NetBSD: ftp.c,v 1.134 2005/06/10 00:18:46 lukem Exp */
/*-
* Copyright (c) 1996-2005 The NetBSD Foundation, Inc.
@ -97,17 +97,6 @@
#include "tnftp.h"
#if 0
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94";
#else
__RCSID("NetBSD: ftp.c,v 1.7 2005/05/14 03:53:28 lukem Exp");
#endif
#endif /* not lint */
#endif
#include <arpa/telnet.h>
#include "ftp_var.h"
@ -147,11 +136,12 @@ struct sockinet myctladdr, hisctladdr, data_addr;
char *
hookup(char *host, char *port)
{
int s = -1, len, error, portnum;
int s = -1, error, portnum;
struct addrinfo hints, *res, *res0;
char hbuf[MAXHOSTNAMELEN];
static char hostnamebuf[MAXHOSTNAMELEN];
char *cause = "unknown";
socklen_t len;
int on = 1;
memset((char *)&hisctladdr, 0, sizeof (hisctladdr));
@ -164,7 +154,7 @@ hookup(char *host, char *port)
hints.ai_protocol = 0;
error = getaddrinfo(host, NULL, &hints, &res0);
if (error) {
warnx("%s", gai_strerror(error));
warnx("%s: %s", host, gai_strerror(error));
code = -1;
return (0);
}
@ -196,12 +186,8 @@ hookup(char *host, char *port)
* we use it as native. What a mess!
*/
ai_unmapped(res);
#if 0 /*old behavior*/
if (res != res0) /* not on the first address */
#else
if (res0->ai_next) /* if we have multiple possibilities */
#endif
{
if (verbose && res0->ai_next) {
/* if we have multiple possibilities */
if (getnameinfo(res->ai_addr, res->ai_addrlen,
hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST))
strlcpy(hbuf, "?", sizeof(hbuf));
@ -244,7 +230,7 @@ hookup(char *host, char *port)
res0 = res = NULL;
len = hisctladdr.su_len;
if (getsockname(s, (struct sockaddr *)&myctladdr.si_su, &len) < 0) {
if (getsockname(s, (struct sockaddr *)&myctladdr.si_su, &len) == -1) {
warn("getsockname");
code = -1;
goto bad;
@ -553,7 +539,7 @@ void
abortxfer(int notused)
{
char msgbuf[100];
int len;
size_t len;
sigint_raised = 1;
alarmtimer(0);
@ -1253,11 +1239,12 @@ int
initconn(void)
{
char *p, *a;
int result, len, tmpno = 0;
int result, tmpno = 0;
int on = 1;
int error;
u_int addr[16], port[2];
u_int af, hal, pal;
unsigned int addr[16], port[2];
unsigned int af, hal, pal;
socklen_t len;
char *pasvcmd = NULL;
#ifdef INET6
@ -1557,7 +1544,7 @@ initconn(void)
}
len = sizeof(data_addr.si_su);
memset((char *)&data_addr, 0, sizeof (data_addr));
if (getsockname(data, (struct sockaddr *)&data_addr.si_su, &len) < 0) {
if (getsockname(data, (struct sockaddr *)&data_addr.si_su, &len) == -1) {
warn("getsockname");
goto bad;
}
@ -1672,9 +1659,10 @@ FILE *
dataconn(const char *lmode)
{
struct sockinet from;
int s, fromlen, flags, rv, timeout;
int s, flags, rv, timeout;
struct timeval endtime, now, td;
struct pollfd pfd[1];
socklen_t fromlen;
if (passivemode) /* passive data connection */
return (fdopen(data, lmode));
@ -2064,7 +2052,7 @@ void
abort_squared(int dummy)
{
char msgbuf[100];
int len;
size_t len;
sigint_raised = 1;
alarmtimer(0);
@ -2123,7 +2111,7 @@ ai_unmapped(struct addrinfo *ai)
#ifdef INET6
struct sockaddr_in6 *sin6;
struct sockaddr_in sin;
int len;
socklen_t len;
if (ai->ai_family != AF_INET6)
return;

View file

@ -1,8 +1,8 @@
/* NetBSD: main.c,v 1.8 2005/05/14 03:53:28 lukem Exp */
/* from NetBSD: main.c,v 1.94 2005/05/13 05:03:49 lukem Exp */
/* NetBSD: main.c,v 1.11 2005/06/10 04:05:01 lukem Exp */
/* from NetBSD: main.c,v 1.97 2005/06/10 00:18:46 lukem Exp */
/*-
* Copyright (c) 1996-2004 The NetBSD Foundation, Inc.
* Copyright (c) 1996-2005 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -95,22 +95,6 @@
* SUCH DAMAGE.
*/
#if 0
#include <sys/cdefs.h>
#ifndef lint
__COPYRIGHT("@(#) Copyright (c) 1985, 1989, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94";
#else
__RCSID("NetBSD: main.c,v 1.8 2005/05/14 03:53:28 lukem Exp");
#endif
#endif /* not lint */
#endif
/*
* FTP User Program -- Command Interface.
*/
@ -134,7 +118,8 @@ main(int argc, char *argv[])
int ch, rval;
struct passwd *pw;
char *cp, *ep, *anonuser, *anonpass, *upload_path;
int dumbterm, s, len, isupload;
int dumbterm, s, isupload;
size_t len;
socklen_t slen;
#if 0 /* XXX */
@ -623,7 +608,8 @@ cmdscanner(void)
{
struct cmd *c;
char *p;
int num;
int ch;
size_t num;
for (;;) {
#ifndef NO_EDITCOMPLETE
@ -636,32 +622,31 @@ cmdscanner(void)
fprintf(ttyout, "%s ", p);
(void)fflush(ttyout);
}
if (fgets(line, sizeof(line), stdin) == NULL) {
num = getline(stdin, line, sizeof(line), NULL);
switch (num) {
case -1: /* EOF */
case -2: /* error */
if (fromatty)
putc('\n', ttyout);
quit(0, NULL);
}
num = strlen(line);
if (num == 0)
break;
if (line[--num] == '\n') {
if (num == 0)
break;
line[num] = '\0';
} else if (num == sizeof(line) - 2) {
/* NOTREACHED */
case -3: /* too long; try again */
fputs("Sorry, input line is too long.\n",
ttyout);
while ((num = getchar()) != '\n' && num != EOF)
/* void */;
continue;
case 0: /* empty; try again */
continue;
default: /* all ok */
break;
} /* else it was a line without a newline */
}
#ifndef NO_EDITCOMPLETE
} else {
const char *buf;
HistEvent ev;
cursor_pos = NULL;
buf = el_gets(el, &num);
buf = el_gets(el, &ch);
num = ch;
if (buf == NULL || num == 0) {
if (fromatty)
putc('\n', ttyout);

View file

@ -1,9 +1,9 @@
/* pkgsrc $NetBSD $/
/* NetBSD: progressbar.c,v 1.6 2005/05/11 02:41:28 lukem Exp */
/* from NetBSD: progressbar.c,v 1.7 2005/04/11 01:49:31 lukem Exp */
/* pkgsrc $NetBSD: progressbar.c,v 1.5 2005/06/10 05:06:26 lukem Exp $ */
/* NetBSD: progressbar.c,v 1.9 2005/06/10 04:05:01 lukem Exp */
/* from NetBSD: progressbar.c,v 1.10 2005/06/09 16:38:29 lukem Exp */
/*-
* Copyright (c) 1997-2003 The NetBSD Foundation, Inc.
* Copyright (c) 1997-2005 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -38,13 +38,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#if 0
#include <sys/cdefs.h>
#ifndef lint
__RCSID("NetBSD: progressbar.c,v 1.6 2005/05/11 02:41:28 lukem Exp");
#endif /* not lint */
#endif
/*
* FTP User Program -- Misc support routines
*/
@ -119,7 +112,8 @@ progressmeter(int flag)
struct timeval td;
off_t abbrevsize, bytespersec;
double elapsed;
int ratio, barlength, i, remaining;
int ratio, i, remaining;
size_t barlength;
/*
* Work variables for progress bar.
@ -130,7 +124,7 @@ progressmeter(int flag)
* these appropriately.
*/
#endif
int len;
size_t len;
char buf[256]; /* workspace for progress bar */
#ifndef NO_PROGRESS
#define BAROVERHEAD 43 /* non `*' portion of progress bar */
@ -217,7 +211,7 @@ progressmeter(int flag)
if (barlength > 0) {
i = barlength * ratio / 100;
len += snprintf(buf + len, BUFLEFT,
"|%.*s%*s|", i, stars, barlength - i, "");
"|%.*s%*s|", i, stars, (int)(barlength - i), "");
}
}
@ -294,7 +288,8 @@ ptransfer(int siginfo)
struct timeval now, td, wait;
double elapsed;
off_t bytespersec;
int remaining, hh, i, len;
int remaining, hh, i;
size_t len;
char buf[256]; /* Work variable for transfer status. */

View file

@ -1,5 +1,5 @@
/* NetBSD: ruserpass.c,v 1.4 2005/05/11 02:41:28 lukem Exp */
/* from NetBSD: ruserpass.c,v 1.29 2003/08/07 11:13:57 agc Exp */
/* NetBSD: ruserpass.c,v 1.6 2005/06/10 04:05:01 lukem Exp */
/* from NetBSD: ruserpass.c,v 1.30 2005/06/10 00:18:47 lukem Exp */
/*
* Copyright (c) 1985, 1993, 1994
@ -30,17 +30,6 @@
* SUCH DAMAGE.
*/
#if 0
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)ruserpass.c 8.4 (Berkeley) 4/27/95";
#else
__RCSID("NetBSD: ruserpass.c,v 1.4 2005/05/11 02:41:28 lukem Exp");
#endif
#endif /* not lint */
#endif
#include "tnftp.h"
#include "ftp_var.h"
@ -59,7 +48,7 @@ static FILE *cfile;
static char tokval[100];
static struct toktab {
char *tokstr;
const char *tokstr;
int tval;
} toktab[] = {
{ "default", DEFAULT },
@ -73,11 +62,11 @@ static struct toktab {
};
int
ruserpass(const char *host, const char **aname, const char **apass,
const char **aacct)
ruserpass(const char *host, char **aname, char **apass, char **aacct)
{
char *tmp;
char myname[MAXHOSTNAMELEN + 1], *mydomain;
const char *mydomain;
char myname[MAXHOSTNAMELEN + 1];
int t, i, c, usedefault = 0;
struct stat stb;

View file

@ -1,5 +1,5 @@
/* NetBSD: util.c,v 1.10 2005/05/14 03:53:28 lukem Exp */
/* from NetBSD: util.c,v 1.122 2005/05/13 05:03:49 lukem Exp */
/* NetBSD: util.c,v 1.14 2005/06/10 04:05:01 lukem Exp */
/* from NetBSD: util.c,v 1.129 2005/06/10 00:18:47 lukem Exp */
/*-
* Copyright (c) 1997-2005 The NetBSD Foundation, Inc.
@ -70,13 +70,6 @@
* SUCH DAMAGE.
*/
#if 0
#include <sys/cdefs.h>
#ifndef lint
__RCSID("NetBSD: util.c,v 1.10 2005/05/14 03:53:28 lukem Exp");
#endif /* not lint */
#endif
/*
* FTP User Program -- Misc support routines
*/
@ -355,34 +348,35 @@ lostpeer(int dummy)
* Return non-zero if successful.
*/
int
ftp_login(const char *host, const char *user, const char *pass)
ftp_login(const char *host, const char *luser, const char *lpass)
{
char tmp[80];
const char *acct;
int n, aflag, rval, freeuser, freepass, freeacct;
char *user, *pass, *acct, *p;
const char *errormsg;
int n, aflag, rval, nlen;
acct = NULL;
aflag = rval = freeuser = freepass = freeacct = 0;
aflag = rval = 0;
user = pass = acct = NULL;
if (luser)
user = xstrdup(luser);
if (lpass)
pass = xstrdup(lpass);
if (debug)
fprintf(ttyout, "ftp_login: user `%s' pass `%s' host `%s'\n",
user ? user : "<null>", pass ? pass : "<null>",
host ? host : "<null>");
/*
* Set up arguments for an anonymous FTP session, if necessary.
*/
if (anonftp) {
user = "anonymous"; /* as per RFC 1635 */
pass = getoptionvalue("anonpass");
FREEPTR(user);
user = xstrdup("anonymous"); /* as per RFC 1635 */
FREEPTR(pass);
pass = xstrdup(getoptionvalue("anonpass"));
}
if (user == NULL)
freeuser = 1;
if (pass == NULL)
freepass = 1;
freeacct = 1;
if (ruserpass(host, &user, &pass, &acct) < 0) {
code = -1;
goto cleanup_ftp_login;
@ -393,53 +387,55 @@ ftp_login(const char *host, const char *user, const char *pass)
fprintf(ttyout, "Name (%s:%s): ", host, localname);
else
fprintf(ttyout, "Name (%s): ", host);
*tmp = '\0';
if (fgets(tmp, sizeof(tmp) - 1, stdin) == NULL) {
fprintf(ttyout, "\nEOF received; login aborted.\n");
clearerr(stdin);
errormsg = NULL;
nlen = getline(stdin, tmp, sizeof(tmp), &errormsg);
if (nlen < 0) {
fprintf(ttyout, "%s; %s aborted.\n", errormsg, "login");
code = -1;
goto cleanup_ftp_login;
} else if (nlen == 0) {
user = xstrdup(localname);
} else {
user = xstrdup(tmp);
}
tmp[strlen(tmp) - 1] = '\0';
freeuser = 0;
if (*tmp == '\0')
user = localname;
else
user = tmp;
}
if (gatemode) {
char *nuser;
int len;
size_t len;
len = strlen(user) + 1 + strlen(host) + 1;
nuser = xmalloc(len);
(void)strlcpy(nuser, user, len);
(void)strlcat(nuser, "@", len);
(void)strlcat(nuser, host, len);
freeuser = 1;
FREEPTR(user);
user = nuser;
}
n = command("USER %s", user);
if (n == CONTINUE) {
if (pass == NULL) {
freepass = 0;
pass = getpass("Password:");
p = getpass("Password: ");
pass = xstrdup(p);
memset(p, 0, strlen(p));
}
n = command("PASS %s", pass);
memset(pass, 0, strlen(pass));
}
if (n == CONTINUE) {
aflag++;
if (acct == NULL) {
freeacct = 0;
acct = getpass("Account:");
p = getpass("Account: ");
acct = xstrdup(p);
memset(p, 0, strlen(p));
}
if (acct[0] == '\0') {
warnx("Login failed.");
goto cleanup_ftp_login;
}
n = command("ACCT %s", acct);
memset(acct, 0, strlen(acct));
}
if ((n != COMPLETE) ||
(!aflag && acct != NULL && command("ACCT %s", acct) != COMPLETE)) {
@ -465,12 +461,13 @@ ftp_login(const char *host, const char *user, const char *pass)
updateremotecwd();
cleanup_ftp_login:
if (user != NULL && freeuser)
free((char *)user);
if (pass != NULL && freepass)
free((char *)pass);
if (acct != NULL && freeacct)
free((char *)acct);
FREEPTR(user);
if (pass != NULL)
memset(pass, 0, strlen(pass));
FREEPTR(pass);
if (acct != NULL)
memset(acct, 0, strlen(pass));
FREEPTR(acct);
return (rval);
}
@ -483,21 +480,24 @@ ftp_login(const char *host, const char *user, const char *pass)
int
another(int *pargc, char ***pargv, const char *prompt)
{
int len = strlen(line), ret;
const char *errormsg;
int ret, nlen;
size_t len;
len = strlen(line);
if (len >= sizeof(line) - 3) {
fputs("sorry, arguments too long.\n", ttyout);
fputs("Sorry, arguments too long.\n", ttyout);
intr(0);
}
fprintf(ttyout, "(%s) ", prompt);
line[len++] = ' ';
if (fgets(&line[len], sizeof(line) - len, stdin) == NULL) {
clearerr(stdin);
errormsg = NULL;
nlen = getline(stdin, line + len, sizeof(line)-len, &errormsg);
if (nlen < 0) {
fprintf(ttyout, "%s; %s aborted.\n", errormsg, "operation");
intr(0);
}
len += strlen(&line[len]);
if (len > 0 && line[len - 1] == '\n')
line[len - 1] = '\0';
len += nlen;
makeargv();
ret = margc > *pargc;
*pargc = margc;
@ -511,65 +511,67 @@ another(int *pargc, char ***pargv, const char *prompt)
* of writing to the screen.
*/
char *
remglob(char *argv[], int doswitch, char **errbuf)
remglob(char *argv[], int doswitch, const char **errbuf)
{
char temp[MAXPATHLEN];
static char buf[MAXPATHLEN];
static FILE *ftemp = NULL;
static char **args;
int oldverbose, oldhash, oldprogress, fd, len;
char *cp, *mode;
static char buf[MAXPATHLEN];
static FILE *ftemp = NULL;
static char **args;
char temp[MAXPATHLEN];
int oldverbose, oldhash, oldprogress, fd;
char *cp;
const char *mode;
size_t len;
if (!mflag || !connected) {
if (!doglob)
args = NULL;
else {
if (ftemp) {
(void)fclose(ftemp);
ftemp = NULL;
}
}
return (NULL);
}
if (!doglob) {
if (args == NULL)
args = argv;
if ((cp = *++args) == NULL)
args = NULL;
return (cp);
}
if (ftemp == NULL) {
if (!mflag || !connected) {
if (!doglob)
args = NULL;
else {
if (ftemp) {
(void)fclose(ftemp);
ftemp = NULL;
}
}
return (NULL);
}
if (!doglob) {
if (args == NULL)
args = argv;
if ((cp = *++args) == NULL)
args = NULL;
return (cp);
}
if (ftemp == NULL) {
len = strlcpy(temp, tmpdir, sizeof(temp));
if (temp[len - 1] != '/')
(void)strlcat(temp, "/", sizeof(temp));
(void)strlcat(temp, TMPFILE, sizeof(temp));
if ((fd = mkstemp(temp)) < 0) {
warn("unable to create temporary file %s", temp);
return (NULL);
}
close(fd);
oldverbose = verbose;
if ((fd = mkstemp(temp)) < 0) {
warn("unable to create temporary file %s", temp);
return (NULL);
}
close(fd);
oldverbose = verbose;
verbose = (errbuf != NULL) ? -1 : 0;
oldhash = hash;
oldhash = hash;
oldprogress = progress;
hash = 0;
hash = 0;
progress = 0;
if (doswitch)
pswitch(!proxy);
for (mode = "w"; *++argv != NULL; mode = "a")
recvrequest("NLST", temp, *argv, mode, 0, 0);
if (doswitch)
pswitch(!proxy);
for (mode = "w"; *++argv != NULL; mode = "a")
recvrequest("NLST", temp, *argv, mode, 0, 0);
if ((code / 100) != COMPLETE) {
if (errbuf != NULL)
*errbuf = reply_string;
}
if (doswitch)
pswitch(!proxy);
verbose = oldverbose;
if (doswitch)
pswitch(!proxy);
verbose = oldverbose;
hash = oldhash;
progress = oldprogress;
ftemp = fopen(temp, "r");
(void)unlink(temp);
if (ftemp == NULL) {
ftemp = fopen(temp, "r");
(void)unlink(temp);
if (ftemp == NULL) {
if (errbuf == NULL)
fputs(
"can't find list of remote files, oops.\n",
@ -577,17 +579,17 @@ remglob(char *argv[], int doswitch, char **errbuf)
else
*errbuf =
"can't find list of remote files, oops.";
return (NULL);
}
}
if (fgets(buf, sizeof(buf), ftemp) == NULL) {
(void)fclose(ftemp);
return (NULL);
}
}
if (fgets(buf, sizeof(buf), ftemp) == NULL) {
(void)fclose(ftemp);
ftemp = NULL;
return (NULL);
}
if ((cp = strchr(buf, '\n')) != NULL)
*cp = '\0';
return (buf);
return (NULL);
}
if ((cp = strchr(buf, '\n')) != NULL)
*cp = '\0';
return (buf);
}
/*
@ -815,20 +817,30 @@ updateremotecwd(void)
int
fileindir(const char *file, const char *dir)
{
char realfile[PATH_MAX+1];
char parentdirbuf[PATH_MAX+1], *parentdir;
char realdir[PATH_MAX+1];
size_t dirlen;
if (realpath(file, realfile) == NULL) {
warn("Unable to determine real path of `%s'", file);
/* determine parent directory of file */
(void)strlcpy(parentdirbuf, file, sizeof(parentdirbuf));
parentdir = dirname(parentdirbuf);
if (strcmp(parentdir, ".") == 0)
return 1; /* current directory is ok */
/* find the directory */
if (realpath(parentdir, realdir) == NULL) {
warn("Unable to determine real path of `%s'", parentdir);
return 0;
}
if (realfile[0] != '/') /* relative result */
if (realdir[0] != '/') /* relative result is ok */
return 1;
dirlen = strlen(dir);
#if 0
printf("file %s realfile %s dir %s [%d]\n", file, realfile, dir, dirlen);
printf("file %s parent %s realdir %s dir %s [%d]\n",
file, parentdir, realdir, dir, dirlen);
#endif
if (strncmp(realfile, dir, dirlen) == 0 && realfile[dirlen] == '/')
if (strncmp(realdir, dir, dirlen) == 0 &&
(realdir[dirlen] == '/' || realdir[dirlen] == '\0'))
return 1;
return 0;
}
@ -839,9 +851,10 @@ printf("file %s realfile %s dir %s [%d]\n", file, realfile, dir, dirlen);
void
list_vertical(StringList *sl)
{
int i, j, w;
int columns, width, lines;
int i, j;
int columns, lines;
char *p;
size_t w, width;
width = 0;
@ -1055,8 +1068,7 @@ ftpvis(char *dst, size_t dstlen, const char *src, size_t srclen)
void
formatbuf(char *buf, size_t len, const char *src)
{
const char *p;
char *p2, *q;
const char *p, *p2, *q;
int i, op, updirs, pdirs;
#define ADDBUF(x) do { \
@ -1135,7 +1147,7 @@ formatbuf(char *buf, size_t len, const char *src)
case 'M':
case 'm':
for (p2 = connected && username ? username : "-";
for (p2 = connected && hostname ? hostname : "-";
*p2 ; p2++) {
if (op == 'm' && *p2 == '.')
break;
@ -1223,6 +1235,56 @@ isipv6addr(const char *addr)
return (rv == 1) ? 1 : 0;
}
/*
* Read a line from the FILE stream into buf/buflen using fgets(), so up
* to buflen-1 chars will be read and the result will be NUL terminated.
* If the line has a trailing newline it will be removed.
* If the line is too long, excess characters will be read until
* newline/EOF/error.
* If EOF/error occurs or a too-long line is encountered and errormsg
* isn't NULL, it will be changed to a description of the problem.
* (The EOF message has a leading \n for cosmetic purposes).
* Returns:
* >=0 length of line (excluding trailing newline) if all ok
* -1 error occurred
* -2 EOF encountered
* -3 line was too long
*/
int
getline(FILE *stream, char *buf, size_t buflen, const char **errormsg)
{
int rv, ch;
size_t len;
if (fgets(buf, buflen, stream) == NULL) {
if (feof(stream)) { /* EOF */
rv = -2;
if (errormsg)
*errormsg = "\nEOF received";
} else { /* error */
rv = -1;
if (errormsg)
*errormsg = "Error encountered";
}
clearerr(stream);
return rv;
}
len = strlen(buf);
if (buf[len-1] == '\n') { /* clear any trailing newline */
buf[--len] = '\0';
} else if (len == buflen-1) { /* line too long */
while ((ch = getchar()) != '\n' && ch != EOF)
continue;
if (errormsg)
*errormsg = "Input line is too long";
clearerr(stream);
return -3;
}
if (errormsg)
*errormsg = NULL;
return len;
}
/*
* Internal version of connect(2); sets socket buffer sizes first and
@ -1233,7 +1295,7 @@ isipv6addr(const char *addr)
* Returns -1 upon failure (with errno set to the problem), or 0 on success.
*/
int
xconnect(int sock, const struct sockaddr *name, int namelen)
xconnect(int sock, const struct sockaddr *name, socklen_t namelen)
{
int flags, rv, timeout, error;
socklen_t slen;
@ -1327,12 +1389,16 @@ xpoll(struct pollfd *fds, int nfds, int timeout)
return poll(fds, nfds, timeout);
#elif HAVE_SELECT /* implement poll(2) using select(2) */
fd_set rset, wset;
fd_set rset, wset, xset;
const int rsetflags = POLLIN | POLLRDNORM;
const int wsetflags = POLLOUT | POLLWRNORM;
const int xsetflags = POLLRDBAND;
struct timeval tv, *ptv;
int i, max, rv;
FD_ZERO(&rset); /* build list of read & write events */
FD_ZERO(&wset);
FD_ZERO(&xset);
max = 0;
for (i = 0; i < nfds; i++) {
if (fds[i].fd > FD_SETSIZE) {
@ -1341,10 +1407,12 @@ xpoll(struct pollfd *fds, int nfds, int timeout)
return -1;
} else if (fds[i].fd > max)
max = fds[i].fd;
if (fds[i].events & POLLIN)
if (fds[i].events & rsetflags)
FD_SET(fds[i].fd, &rset);
if (fds[i].events & POLLOUT)
if (fds[i].events & wsetflags)
FD_SET(fds[i].fd, &wset);
if (fds[i].events & xsetflags)
FD_SET(fds[i].fd, &xset);
}
ptv = &tv; /* determine timeout */
@ -1358,15 +1426,17 @@ xpoll(struct pollfd *fds, int nfds, int timeout)
ptv->tv_sec = timeout / 1000;
ptv->tv_usec = (timeout % 1000) * 1000;
}
rv = select(max + 1, &rset, &wset, NULL, ptv);
rv = select(max + 1, &rset, &wset, &xset, ptv);
if (rv <= 0) /* -1 == error, 0 == timeout */
return rv;
for (i = 0; i < nfds; i++) { /* determine results */
if (FD_ISSET(fds[i].fd, &rset))
fds[i].revents |= POLLIN;
fds[i].revents |= (fds[i].events & rsetflags);
if (FD_ISSET(fds[i].fd, &wset))
fds[i].revents |= POLLOUT;
fds[i].revents |= (fds[i].events & wsetflags);
if (FD_ISSET(fds[i].fd, &xset))
fds[i].revents |= (fds[i].events & xsetflags);
}
return rv;

View file

@ -1,4 +1,5 @@
/* from NetBSD: version.h,v 1.49 2005/05/13 05:03:49 lukem Exp */
/* NetBSD: version.h,v 1.1.1.10 2005/06/10 03:53:48 lukem Exp */
/* from NetBSD: version.h,v 1.55 2005/06/10 00:18:47 lukem Exp */
/*-
* Copyright (c) 1999-2005 The NetBSD Foundation, Inc.
* All rights reserved.
@ -40,5 +41,5 @@
#endif
#ifndef FTP_VERSION
#define FTP_VERSION "20050513"
#define FTP_VERSION "20050610"
#endif

View file

@ -1,7 +1,7 @@
/* NetBSD: tnftp.h,v 1.13 2005/05/14 04:46:26 lukem Exp */
/* NetBSD: tnftp.h,v 1.19 2005/06/10 04:40:13 lukem Exp */
#define FTP_PRODUCT "tnftp"
#define FTP_VERSION "20050514"
#define FTP_VERSION "20050610"
#include "config.h"
@ -22,6 +22,7 @@
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <libgen.h>
#include <limits.h>
#ifdef HAVE_RFC2553_NETDB
#include <netdb.h>
@ -55,10 +56,19 @@
# include <sys/poll.h>
#endif
#ifndef POLLIN
# define POLLIN 1
# define POLLIN 0x0001
#endif
#ifndef POLLOUT
# define POLLOUT 4
# define POLLOUT 0x0004
#endif
#ifndef POLLRDNORM
# define POLLRDNORM 0x0040
#endif
#ifndef POLLWRNORM
# define POLLWRNORM POLLOUT
#endif
#ifndef POLLRDBAND
# define POLLRDBAND 0x0080
#endif
#ifndef INFTIM
# define INFTIM -1
@ -253,20 +263,20 @@ typedef unsigned int socklen_t;
#if ! HAVE_RFC2553_NETDB && ! HAVE_ADDRINFO
struct addrinfo {
int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
int ai_family; /* PF_xxx */
int ai_socktype; /* SOCK_xxx */
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
size_t ai_addrlen; /* length of ai_addr */
char *ai_canonname; /* canonical name for hostname */
int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
int ai_family; /* PF_xxx */
int ai_socktype; /* SOCK_xxx */
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
socklen_t ai_addrlen; /* length of ai_addr */
char *ai_canonname; /* canonical name for hostname */
struct sockaddr *ai_addr; /* binary address */
struct addrinfo *ai_next; /* next structure in linked list */
};
int getaddrinfo(const char *, const char *,
const struct addrinfo *, struct addrinfo **);
int getnameinfo(const struct sockaddr *, socklen_t, char *,
size_t, char *, size_t, int);
int getnameinfo(const struct sockaddr *, socklen_t,
char *, size_t, char *, size_t, int);
void freeaddrinfo(struct addrinfo *);
char *gai_strerror(int);
@ -302,6 +312,10 @@ extern int optind;
int pclose(FILE *);
#endif
#if ! HAVE_DIRNAME
char *dirname(char *);
#endif
#if ! HAVE_ERR
void err(int, const char *, ...);
void errx(int, const char *, ...);
@ -327,7 +341,7 @@ char *fparseln(FILE *, size_t *, size_t *, const char[3], int);
#endif
#if ! HAVE_INET_NTOP
const char *inet_ntop(int, const void *, char *, size_t);
const char *inet_ntop(int, const void *, char *, socklen_t);
#endif
#if ! HAVE_INET_PTON
@ -362,11 +376,11 @@ char *strptime(const char *, const char *, struct tm *);
#if HAVE_QUAD_SUPPORT
# if ! HAVE_STRTOLL && HAVE_LONG_LONG
long long strtoll(const char *, char **, int);
# if ! defined(QUAD_MIN)
# define QUAD_MIN (-0x7fffffffffffffffL-1)
# if ! defined(LLONG_MIN)
# define LLONG_MIN (-0x7fffffffffffffffL-1)
# endif
# if ! defined(QUAD_MAX)
# define QUAD_MAX (0x7fffffffffffffffL)
# if ! defined(LLONG_MAX)
# define LLONG_MAX (0x7fffffffffffffffL)
# endif
# endif
#else /* ! HAVE_QUAD_SUPPORT */