mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
[svn] Remove K&R support.
This commit is contained in:
parent
9000d2b527
commit
277e840a0f
@ -1,3 +1,7 @@
|
||||
2005-06-19 Hrvoje Niksic <hniksic@xemacs.org>
|
||||
|
||||
* aclocal.m4: Remove support for K&R compilers.
|
||||
|
||||
2005-05-10 Hrvoje Niksic <hniksic@xemacs.org>
|
||||
|
||||
* configure.in: Test for OpenSSL includes we actually need.
|
||||
|
57
aclocal.m4
vendored
57
aclocal.m4
vendored
@ -111,63 +111,6 @@ AC_DEFUN([WGET_NSL_SOCKET], [
|
||||
])
|
||||
|
||||
|
||||
# serial 1
|
||||
|
||||
# @defmac AC_PROG_CC_STDC
|
||||
# @maindex PROG_CC_STDC
|
||||
# @ovindex CC
|
||||
# If the C compiler in not in ANSI C mode by default, try to add an option
|
||||
# to output variable @code{CC} to make it so. This macro tries various
|
||||
# options that select ANSI C on some system or another. It considers the
|
||||
# compiler to be in ANSI C mode if it defines @code{__STDC__} to 1 and
|
||||
# handles function prototypes correctly.
|
||||
#
|
||||
# If you use this macro, you should check after calling it whether the C
|
||||
# compiler has been set to accept ANSI C; if not, the shell variable
|
||||
# @code{am_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source
|
||||
# code in ANSI C, you can make an un-ANSIfied copy of it by using the
|
||||
# program @code{ansi2knr}, which comes with Ghostscript.
|
||||
# @end defmac
|
||||
|
||||
AC_DEFUN(AM_PROG_CC_STDC,
|
||||
[AC_REQUIRE([AC_PROG_CC])
|
||||
AC_MSG_CHECKING([for ${CC-cc} option to accept ANSI C])
|
||||
AC_CACHE_VAL(am_cv_prog_cc_stdc,
|
||||
[am_cv_prog_cc_stdc=no
|
||||
ac_save_CC="$CC"
|
||||
# Don't try gcc -ansi; that turns off useful extensions and
|
||||
# breaks some systems' header files.
|
||||
# AIX -qlanglvl=ansi
|
||||
# Ultrix and OSF/1 -std1
|
||||
# HP-UX -Aa -D_HPUX_SOURCE
|
||||
for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE"
|
||||
do
|
||||
CC="$ac_save_CC $ac_arg"
|
||||
AC_TRY_COMPILE(
|
||||
[#if !defined(__STDC__)
|
||||
choke me
|
||||
#endif
|
||||
/* DYNIX/ptx V4.1.3 can't compile sys/stat.h with -Xc -D__EXTENSIONS__. */
|
||||
#ifdef _SEQUENT_
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
], [
|
||||
int test (int i, double x);
|
||||
struct s1 {int (*f) (int a);};
|
||||
struct s2 {int (*f) (double a);};],
|
||||
[am_cv_prog_cc_stdc="$ac_arg"; break])
|
||||
done
|
||||
CC="$ac_save_CC"
|
||||
])
|
||||
AC_MSG_RESULT($am_cv_prog_cc_stdc)
|
||||
case "x$am_cv_prog_cc_stdc" in
|
||||
x|xno) ;;
|
||||
*) CC="$CC $am_cv_prog_cc_stdc" ;;
|
||||
esac
|
||||
])
|
||||
|
||||
|
||||
dnl ************************************************************
|
||||
dnl START OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
|
||||
dnl ************************************************************
|
||||
|
23
configure.in
23
configure.in
@ -85,7 +85,7 @@ case "${ENABLE_OPIE}${ENABLE_DIGEST}" in
|
||||
wget_need_md5=yes
|
||||
esac
|
||||
if test x"$ENABLE_OPIE" = xyes; then
|
||||
OPIE_OBJ='ftp-opie$o'
|
||||
OPIE_OBJ='ftp-opie.o'
|
||||
fi
|
||||
AC_SUBST(OPIE_OBJ)
|
||||
|
||||
@ -109,7 +109,6 @@ test -z "$CC" && cc_specified=yes
|
||||
|
||||
AC_PROG_CC
|
||||
AC_AIX
|
||||
AM_PROG_CC_STDC
|
||||
|
||||
dnl Turn on optimization by default. Specifically:
|
||||
dnl
|
||||
@ -155,14 +154,6 @@ AC_C_VOLATILE
|
||||
AC_C_BIGENDIAN
|
||||
AC_C_PROTOTYPES
|
||||
|
||||
if test x"$am_cv_prog_cc_stdc" != xno; then :
|
||||
AC_SUBST(U, [])
|
||||
AC_SUBST(ANSI2KNR, [])
|
||||
else
|
||||
AC_SUBST(U, [_])
|
||||
AC_SUBST(ANSI2KNR, [./ansi2knr])
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl Checks for header files that might be missing.
|
||||
dnl
|
||||
@ -173,7 +164,7 @@ dnl HAVE_SYS_TYPES_H, etc. before including them.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(sys/types.h sys/stat.h)
|
||||
dnl Now check for the others.
|
||||
AC_CHECK_HEADERS(string.h strings.h stdarg.h limits.h unistd.h sys/time.h)
|
||||
AC_CHECK_HEADERS(string.h strings.h limits.h unistd.h sys/time.h)
|
||||
AC_CHECK_HEADERS(termios.h sys/ioctl.h sys/select.h utime.h sys/utime.h)
|
||||
AC_CHECK_HEADERS(stdint.h inttypes.h signal.h setjmp.h pwd.h)
|
||||
AC_HEADER_TIME
|
||||
@ -237,7 +228,7 @@ dnl
|
||||
dnl Check if we need to compile in getopt.c.
|
||||
dnl
|
||||
AC_CHECK_FUNC(getopt_long, [], [
|
||||
GETOPT_OBJ='getopt$o'
|
||||
GETOPT_OBJ='getopt.o'
|
||||
])
|
||||
AC_SUBST(GETOPT_OBJ)
|
||||
|
||||
@ -404,7 +395,7 @@ main(){return 0;}
|
||||
AC_DEFINE([HAVE_SSL], 1,
|
||||
[Define if SSL support should be compiled in.])
|
||||
AC_SUBST(SSL_INCLUDES)
|
||||
SSL_OBJ='openssl$o'
|
||||
SSL_OBJ='openssl.o'
|
||||
AC_SUBST(SSL_OBJ)
|
||||
else
|
||||
LDFLAGS=$wget_save_LDFLAGS
|
||||
@ -434,7 +425,7 @@ then
|
||||
then
|
||||
AC_DEFINE([ENABLE_NTLM], 1,
|
||||
[Define if you want the NTLM authorization support compiled in.])
|
||||
NTLM_OBJ='http-ntlm$o'
|
||||
NTLM_OBJ='http-ntlm.o'
|
||||
fi
|
||||
else
|
||||
dnl If SSL is unavailable and the user explicitly requested NTLM,
|
||||
@ -455,7 +446,7 @@ then
|
||||
dnl This should be moved to an AC_DEFUN, but I'm not sure how to
|
||||
dnl manipulate MD5_OBJ from the defun.
|
||||
|
||||
MD5_OBJ='gen-md5$o'
|
||||
MD5_OBJ='gen-md5.o'
|
||||
found_md5=no
|
||||
|
||||
dnl Check for the system MD5 library on Solaris. We don't check for
|
||||
@ -491,7 +482,7 @@ then
|
||||
dnl If none of the above worked, use the one we ship with Wget.
|
||||
if test x"$found_md5" = xno; then
|
||||
AC_DEFINE([HAVE_BUILTIN_MD5], 1, [Define to use built-in MD5.])
|
||||
MD5_OBJ="$MD5_OBJ gnu-md5\$o"
|
||||
MD5_OBJ="$MD5_OBJ gnu-md5.o"
|
||||
found_md5=yes
|
||||
AC_MSG_NOTICE([using the GNU MD5 implementation])
|
||||
fi
|
||||
|
@ -1,3 +1,7 @@
|
||||
2005-06-20 Hrvoje Niksic <hniksic@xemacs.org>
|
||||
|
||||
* ansi2knr.1: Removed.
|
||||
|
||||
2005-06-16 Hrvoje Niksic <hniksic@xemacs.org>
|
||||
|
||||
* wget.texi (Logging and Input File Options): It's --no-verbose,
|
||||
|
@ -1,36 +0,0 @@
|
||||
.TH ANSI2KNR 1 "19 Jan 1996"
|
||||
.SH NAME
|
||||
ansi2knr \- convert ANSI C to Kernighan & Ritchie C
|
||||
.SH SYNOPSIS
|
||||
.I ansi2knr
|
||||
[--varargs] input_file [output_file]
|
||||
.SH DESCRIPTION
|
||||
If no output_file is supplied, output goes to stdout.
|
||||
.br
|
||||
There are no error messages.
|
||||
.sp
|
||||
.I ansi2knr
|
||||
recognizes function definitions by seeing a non-keyword identifier at the left
|
||||
margin, followed by a left parenthesis, with a right parenthesis as the last
|
||||
character on the line, and with a left brace as the first token on the
|
||||
following line (ignoring possible intervening comments). It will recognize a
|
||||
multi-line header provided that no intervening line ends with a left or right
|
||||
brace or a semicolon. These algorithms ignore whitespace and comments, except
|
||||
that the function name must be the first thing on the line.
|
||||
.sp
|
||||
The following constructs will confuse it:
|
||||
.br
|
||||
- Any other construct that starts at the left margin and follows the
|
||||
above syntax (such as a macro or function call).
|
||||
.br
|
||||
- Some macros that tinker with the syntax of the function header.
|
||||
.sp
|
||||
The --varargs switch is obsolete, and is recognized only for
|
||||
backwards compatibility. The present version of
|
||||
.I ansi2knr
|
||||
will always attempt to convert a ... argument to va_alist and va_dcl.
|
||||
.SH AUTHOR
|
||||
L. Peter Deutsch <ghost@aladdin.com> wrote the original ansi2knr and
|
||||
continues to maintain the current version; most of the code in the current
|
||||
version is his work. ansi2knr also includes contributions by Francois
|
||||
Pinard <pinard@iro.umontreal.ca> and Jim Avera <jima@netcom.com>.
|
@ -1,3 +1,20 @@
|
||||
2005-06-19 Hrvoje Niksic <hniksic@xemacs.org>
|
||||
|
||||
* all: Don't declare errno. Include both time.h and sys/time.h,
|
||||
as long as sys/time.h exists. Don't dereference function pointers
|
||||
when invoking the functions they point to.
|
||||
|
||||
* cmpt.c (memmove): Remove function mandated by C89.
|
||||
(strerror): Ditto.
|
||||
(strstr): Ditto.
|
||||
|
||||
* all: Undo the K&R-ization changes from 2005-05-03.
|
||||
|
||||
* all: Remove support for K&R compilers: use C89 function
|
||||
declarations, remove definition of PARAMS, remove support for
|
||||
varargs, and remove ansi2knr. Assume the presence of time.h,
|
||||
string.h, and other headers mandated by C89.
|
||||
|
||||
2005-06-19 Hrvoje Niksic <hniksic@xemacs.org>
|
||||
|
||||
* init.c (cmd_lockable_boolean): Don't recognize literal "2" and
|
||||
|
105
src/Makefile.in
105
src/Makefile.in
@ -36,8 +36,6 @@ top_builddir = ..
|
||||
top_srcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
ANSI2KNR = @ANSI2KNR@
|
||||
o = .@U@o
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
@ -73,43 +71,24 @@ NTLM_OBJ = @NTLM_OBJ@
|
||||
SSL_OBJ = @SSL_OBJ@
|
||||
GETOPT_OBJ = @GETOPT_OBJ@
|
||||
|
||||
OBJ = $(ALLOCA) cmpt$o connect$o convert$o cookies$o \
|
||||
ftp$o ftp-basic$o ftp-ls$o $(OPIE_OBJ) $(GETOPT_OBJ) hash$o \
|
||||
host$o html-parse$o html-url$o http$o $(NTLM_OBJ) init$o \
|
||||
log$o main$o $(MD5_OBJ) netrc$o progress$o ptimer$o recur$o \
|
||||
res$o retr$o safe-ctype$o snprintf$o $(SSL_OBJ) url$o \
|
||||
utils$o version$o xmalloc$o
|
||||
OBJ = $(ALLOCA) cmpt.o connect.o convert.o cookies.o \
|
||||
ftp.o ftp-basic.o ftp-ls.o $(OPIE_OBJ) $(GETOPT_OBJ) hash.o \
|
||||
host.o html-parse.o html-url.o http.o $(NTLM_OBJ) init.o \
|
||||
log.o main.o $(MD5_OBJ) netrc.o progress.o ptimer.o recur.o \
|
||||
res.o retr.o safe-ctype.o snprintf.o $(SSL_OBJ) url.o \
|
||||
utils.o version.o xmalloc.o
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .o ._c ._o
|
||||
.SUFFIXES: .c .o
|
||||
|
||||
.c.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.c._c: $(ANSI2KNR)
|
||||
$(ANSI2KNR) $< > $*.tmp && mv $*.tmp $@
|
||||
|
||||
._c._o:
|
||||
@echo $(COMPILE) -c $<
|
||||
@rm -f _$*.c
|
||||
@ln $< _$*.c && $(COMPILE) -c _$*.c && mv _$*.o $@ && rm _$*.c
|
||||
|
||||
.c._o: $(ANSI2KNR)
|
||||
$(ANSI2KNR) $< > $*.tmp && mv $*.tmp $*._c
|
||||
@echo $(COMPILE) -c $*._c
|
||||
@rm -f _$*.c
|
||||
@ln $*._c _$*.c && $(COMPILE) -c _$*.c && mv _$*.o $@ && rm _$*.c
|
||||
|
||||
# Dependencies for building
|
||||
|
||||
wget$(exeext): $(OBJ)
|
||||
$(LINK) $(OBJ) $(LIBS)
|
||||
|
||||
ansi2knr: ansi2knr.o
|
||||
$(CC) -o ansi2knr ansi2knr.o $(LIBS)
|
||||
|
||||
$(OBJ): $(ANSI2KNR)
|
||||
|
||||
#
|
||||
# Dependencies for installing
|
||||
#
|
||||
@ -130,7 +109,7 @@ uninstall.bin:
|
||||
#
|
||||
|
||||
clean:
|
||||
$(RM) *.o wget$(exeext) *~ *.bak core core.[0-9]* $(ANSI2KNR) *._o *._c
|
||||
$(RM) *.o wget$(exeext) *~ *.bak core core.[0-9]*
|
||||
$(RM) -r .libs
|
||||
|
||||
distclean: clean
|
||||
@ -153,47 +132,47 @@ TAGS: *.c *.h
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
alloca$o:
|
||||
cmpt$o: wget.h sysdep.h options.h safe-ctype.h
|
||||
connect$o: wget.h sysdep.h options.h safe-ctype.h utils.h connect.h host.h
|
||||
convert$o: wget.h convert.h url.h recur.h utils.h hash.h
|
||||
cookies$o: wget.h sysdep.h options.h safe-ctype.h cookies.h hash.h url.h utils.h
|
||||
ftp-basic$o: wget.h sysdep.h options.h safe-ctype.h utils.h connect.h \
|
||||
alloca.o:
|
||||
cmpt.o: wget.h sysdep.h options.h safe-ctype.h
|
||||
connect.o: wget.h sysdep.h options.h safe-ctype.h utils.h connect.h host.h
|
||||
convert.o: wget.h convert.h url.h recur.h utils.h hash.h
|
||||
cookies.o: wget.h sysdep.h options.h safe-ctype.h cookies.h hash.h url.h utils.h
|
||||
ftp-basic.o: wget.h sysdep.h options.h safe-ctype.h utils.h connect.h \
|
||||
host.h ftp.h
|
||||
ftp-ls$o: wget.h sysdep.h options.h safe-ctype.h utils.h ftp.h host.h \
|
||||
ftp-ls.o: wget.h sysdep.h options.h safe-ctype.h utils.h ftp.h host.h \
|
||||
url.h
|
||||
ftp-opie$o: wget.h sysdep.h options.h safe-ctype.h gen-md5.h
|
||||
ftp$o: wget.h sysdep.h options.h safe-ctype.h utils.h url.h retr.h \
|
||||
ftp-opie.o: wget.h sysdep.h options.h safe-ctype.h gen-md5.h
|
||||
ftp.o: wget.h sysdep.h options.h safe-ctype.h utils.h url.h retr.h \
|
||||
ftp.h host.h connect.h netrc.h
|
||||
gen-md5$o: wget.h sysdep.h options.h safe-ctype.h gen-md5.h
|
||||
openssl$o: wget.h sysdep.h options.h safe-ctype.h utils.h connect.h host.h \
|
||||
gen-md5.o: wget.h sysdep.h options.h safe-ctype.h gen-md5.h
|
||||
openssl.o: wget.h sysdep.h options.h safe-ctype.h utils.h connect.h host.h \
|
||||
url.h
|
||||
getopt$o: wget.h sysdep.h options.h safe-ctype.h getopt.h
|
||||
gnu-md5$o: wget.h sysdep.h options.h safe-ctype.h gnu-md5.h
|
||||
hash$o: wget.h sysdep.h options.h safe-ctype.h utils.h hash.h
|
||||
host$o: wget.h sysdep.h options.h safe-ctype.h utils.h host.h url.h hash.h
|
||||
html-parse$o: wget.h sysdep.h options.h safe-ctype.h html-parse.h
|
||||
html-url$o: wget.h sysdep.h options.h safe-ctype.h html-parse.h url.h utils.h
|
||||
http$o: wget.h sysdep.h options.h safe-ctype.h utils.h url.h host.h \
|
||||
getopt.o: wget.h sysdep.h options.h safe-ctype.h getopt.h
|
||||
gnu-md5.o: wget.h sysdep.h options.h safe-ctype.h gnu-md5.h
|
||||
hash.o: wget.h sysdep.h options.h safe-ctype.h utils.h hash.h
|
||||
host.o: wget.h sysdep.h options.h safe-ctype.h utils.h host.h url.h hash.h
|
||||
html-parse.o: wget.h sysdep.h options.h safe-ctype.h html-parse.h
|
||||
html-url.o: wget.h sysdep.h options.h safe-ctype.h html-parse.h url.h utils.h
|
||||
http.o: wget.h sysdep.h options.h safe-ctype.h utils.h url.h host.h \
|
||||
retr.h connect.h host.h netrc.h ssl.h \
|
||||
cookies.h gen-md5.h
|
||||
init$o: wget.h sysdep.h options.h safe-ctype.h utils.h init.h host.h recur.h \
|
||||
init.o: wget.h sysdep.h options.h safe-ctype.h utils.h init.h host.h recur.h \
|
||||
netrc.h cookies.h progress.h
|
||||
log$o: wget.h sysdep.h options.h safe-ctype.h utils.h
|
||||
main$o: wget.h sysdep.h options.h safe-ctype.h utils.h init.h retr.h \
|
||||
log.o: wget.h sysdep.h options.h safe-ctype.h utils.h
|
||||
main.o: wget.h sysdep.h options.h safe-ctype.h utils.h init.h retr.h \
|
||||
recur.h host.h cookies.h url.h progress.h ssl.h getopt.h
|
||||
gnu-md5$o: wget.h sysdep.h options.h safe-ctype.h gnu-md5.h
|
||||
mswindows$o: wget.h sysdep.h options.h safe-ctype.h utils.h url.h
|
||||
netrc$o: wget.h sysdep.h options.h safe-ctype.h utils.h netrc.h init.h
|
||||
progress$o: wget.h sysdep.h options.h safe-ctype.h progress.h utils.h retr.h
|
||||
recur$o: wget.h sysdep.h options.h safe-ctype.h url.h recur.h utils.h retr.h \
|
||||
gnu-md5.o: wget.h sysdep.h options.h safe-ctype.h gnu-md5.h
|
||||
mswindows.o: wget.h sysdep.h options.h safe-ctype.h utils.h url.h
|
||||
netrc.o: wget.h sysdep.h options.h safe-ctype.h utils.h netrc.h init.h
|
||||
progress.o: wget.h sysdep.h options.h safe-ctype.h progress.h utils.h retr.h
|
||||
recur.o: wget.h sysdep.h options.h safe-ctype.h url.h recur.h utils.h retr.h \
|
||||
ftp.h host.h hash.h
|
||||
res$o: wget.h sysdep.h options.h safe-ctype.h utils.h hash.h url.h retr.h res.h
|
||||
retr$o: wget.h sysdep.h options.h safe-ctype.h utils.h retr.h url.h \
|
||||
res.o: wget.h sysdep.h options.h safe-ctype.h utils.h hash.h url.h retr.h res.h
|
||||
retr.o: wget.h sysdep.h options.h safe-ctype.h utils.h retr.h url.h \
|
||||
recur.h ftp.h host.h connect.h hash.h
|
||||
safe-ctype$o: safe-ctype.h
|
||||
snprintf$o: safe-ctype.h
|
||||
url$o: wget.h sysdep.h options.h safe-ctype.h utils.h url.h host.h hash.h
|
||||
utils$o: wget.h sysdep.h options.h safe-ctype.h utils.h hash.h
|
||||
version$o:
|
||||
xmalloc$o: wget.h xmalloc.h
|
||||
safe-ctype.o: safe-ctype.h
|
||||
snprintf.o: safe-ctype.h
|
||||
url.o: wget.h sysdep.h options.h safe-ctype.h utils.h url.h host.h hash.h
|
||||
utils.o: wget.h sysdep.h options.h safe-ctype.h utils.h hash.h
|
||||
version.o:
|
||||
xmalloc.o: wget.h xmalloc.h
|
||||
|
678
src/ansi2knr.c
678
src/ansi2knr.c
@ -1,678 +0,0 @@
|
||||
/* Copyright (C) 1989, 1997, 1998, 1999 Aladdin Enterprises. All rights reserved. */
|
||||
|
||||
/*$Id: ansi2knr.c 1002 2003-10-04 10:34:10Z hniksic $*/
|
||||
/* Convert ANSI C function definitions to K&R ("traditional C") syntax */
|
||||
|
||||
/*
|
||||
ansi2knr is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY. No author or distributor accepts responsibility to anyone for the
|
||||
consequences of using it or for whether it serves any particular purpose or
|
||||
works at all, unless he says so in writing. Refer to the GNU General Public
|
||||
License (the "GPL") for full details.
|
||||
|
||||
Everyone is granted permission to copy, modify and redistribute ansi2knr,
|
||||
but only under the conditions described in the GPL. A copy of this license
|
||||
is supposed to have been given to you along with ansi2knr so you can know
|
||||
your rights and responsibilities. It should be in a file named COPYLEFT,
|
||||
or, if there is no file named COPYLEFT, a file named COPYING. Among other
|
||||
things, the copyright notice and this notice must be preserved on all
|
||||
copies.
|
||||
|
||||
We explicitly state here what we believe is already implied by the GPL: if
|
||||
the ansi2knr program is distributed as a separate set of sources and a
|
||||
separate executable file which are aggregated on a storage medium together
|
||||
with another program, this in itself does not bring the other program under
|
||||
the GPL, nor does the mere fact that such a program or the procedures for
|
||||
constructing it invoke the ansi2knr executable bring any other part of the
|
||||
program under the GPL.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Usage:
|
||||
ansi2knr [--filename FILENAME] [INPUT_FILE [OUTPUT_FILE]]
|
||||
* --filename provides the file name for the #line directive in the output,
|
||||
* overriding input_file (if present).
|
||||
* If no input_file is supplied, input is read from stdin.
|
||||
* If no output_file is supplied, output goes to stdout.
|
||||
* There are no error messages.
|
||||
*
|
||||
* ansi2knr recognizes function definitions by seeing a non-keyword
|
||||
* identifier at the left margin, followed by a left parenthesis,
|
||||
* with a right parenthesis as the last character on the line,
|
||||
* and with a left brace as the first token on the following line
|
||||
* (ignoring possible intervening comments), except that a line
|
||||
* consisting of only
|
||||
* identifier1(identifier2)
|
||||
* will not be considered a function definition unless identifier2 is
|
||||
* the word "void", and a line consisting of
|
||||
* identifier1(identifier2, <<arbitrary>>)
|
||||
* will not be considered a function definition.
|
||||
* ansi2knr will recognize a multi-line header provided
|
||||
* that no intervening line ends with a left or right brace or a semicolon.
|
||||
* These algorithms ignore whitespace and comments, except that
|
||||
* the function name must be the first thing on the line.
|
||||
* The following constructs will confuse it:
|
||||
* - Any other construct that starts at the left margin and
|
||||
* follows the above syntax (such as a macro or function call).
|
||||
* - Some macros that tinker with the syntax of function headers.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The original and principal author of ansi2knr is L. Peter Deutsch
|
||||
* <ghost@aladdin.com>. Other authors are noted in the change history
|
||||
* that follows (in reverse chronological order):
|
||||
lpd 1999-04-12 added minor fixes from Pavel Roskin
|
||||
<pavel_roskin@geocities.com> for clean compilation with
|
||||
gcc -W -Wall
|
||||
lpd 1999-03-22 added hack to recognize lines consisting of
|
||||
identifier1(identifier2, xxx) as *not* being procedures
|
||||
lpd 1999-02-03 made indentation of preprocessor commands consistent
|
||||
lpd 1999-01-28 fixed two bugs: a '/' in an argument list caused an
|
||||
endless loop; quoted strings within an argument list
|
||||
confused the parser
|
||||
lpd 1999-01-24 added a check for write errors on the output,
|
||||
suggested by Jim Meyering <meyering@ascend.com>
|
||||
lpd 1998-11-09 added further hack to recognize identifier(void)
|
||||
as being a procedure
|
||||
lpd 1998-10-23 added hack to recognize lines consisting of
|
||||
identifier1(identifier2) as *not* being procedures
|
||||
lpd 1997-12-08 made input_file optional; only closes input and/or
|
||||
output file if not stdin or stdout respectively; prints
|
||||
usage message on stderr rather than stdout; adds
|
||||
--filename switch (changes suggested by
|
||||
<ceder@lysator.liu.se>)
|
||||
lpd 1996-01-21 added code to cope with not HAVE_CONFIG_H and with
|
||||
compilers that don't understand void, as suggested by
|
||||
Tom Lane
|
||||
lpd 1996-01-15 changed to require that the first non-comment token
|
||||
on the line following a function header be a left brace,
|
||||
to reduce sensitivity to macros, as suggested by Tom Lane
|
||||
<tgl@sss.pgh.pa.us>
|
||||
lpd 1995-06-22 removed #ifndefs whose sole purpose was to define
|
||||
undefined preprocessor symbols as 0; changed all #ifdefs
|
||||
for configuration symbols to #ifs
|
||||
lpd 1995-04-05 changed copyright notice to make it clear that
|
||||
including ansi2knr in a program does not bring the entire
|
||||
program under the GPL
|
||||
lpd 1994-12-18 added conditionals for systems where ctype macros
|
||||
don't handle 8-bit characters properly, suggested by
|
||||
Francois Pinard <pinard@iro.umontreal.ca>;
|
||||
removed --varargs switch (this is now the default)
|
||||
lpd 1994-10-10 removed CONFIG_BROKETS conditional
|
||||
lpd 1994-07-16 added some conditionals to help GNU `configure',
|
||||
suggested by Francois Pinard <pinard@iro.umontreal.ca>;
|
||||
properly erase prototype args in function parameters,
|
||||
contributed by Jim Avera <jima@netcom.com>;
|
||||
correct error in writeblanks (it shouldn't erase EOLs)
|
||||
lpd 1989-xx-xx original version
|
||||
*/
|
||||
|
||||
/* Most of the conditionals here are to make ansi2knr work with */
|
||||
/* or without the GNU configure machinery. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
|
||||
/*
|
||||
For properly autoconfiguring ansi2knr, use AC_CONFIG_HEADER(config.h).
|
||||
This will define HAVE_CONFIG_H and so, activate the following lines.
|
||||
*/
|
||||
|
||||
# if STDC_HEADERS || HAVE_STRING_H
|
||||
# include <string.h>
|
||||
# else
|
||||
# include <strings.h>
|
||||
# endif
|
||||
|
||||
#else /* not HAVE_CONFIG_H */
|
||||
|
||||
/* Otherwise do it the hard way */
|
||||
|
||||
# ifdef BSD
|
||||
# include <strings.h>
|
||||
# else
|
||||
# ifdef VMS
|
||||
extern int strlen(), strncmp();
|
||||
# else
|
||||
# include <string.h>
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif /* not HAVE_CONFIG_H */
|
||||
|
||||
#if STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
/*
|
||||
malloc and free should be declared in stdlib.h,
|
||||
but if you've got a K&R compiler, they probably aren't.
|
||||
*/
|
||||
# ifdef MSDOS
|
||||
# include <malloc.h>
|
||||
# else
|
||||
# ifdef VMS
|
||||
extern char *malloc();
|
||||
extern void free();
|
||||
# else
|
||||
extern char *malloc();
|
||||
extern int free();
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
/* Define NULL (for *very* old compilers). */
|
||||
#ifndef NULL
|
||||
# define NULL (0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The ctype macros don't always handle 8-bit characters correctly.
|
||||
* Compensate for this here.
|
||||
*/
|
||||
#ifdef isascii
|
||||
# undef HAVE_ISASCII /* just in case */
|
||||
# define HAVE_ISASCII 1
|
||||
#else
|
||||
#endif
|
||||
#if STDC_HEADERS || !HAVE_ISASCII
|
||||
# define is_ascii(c) 1
|
||||
#else
|
||||
# define is_ascii(c) isascii(c)
|
||||
#endif
|
||||
|
||||
#define is_space(c) (is_ascii(c) && isspace(c))
|
||||
#define is_alpha(c) (is_ascii(c) && isalpha(c))
|
||||
#define is_alnum(c) (is_ascii(c) && isalnum(c))
|
||||
|
||||
/* Scanning macros */
|
||||
#define isidchar(ch) (is_alnum(ch) || (ch) == '_')
|
||||
#define isidfirstchar(ch) (is_alpha(ch) || (ch) == '_')
|
||||
|
||||
/* Forward references */
|
||||
char *skipspace();
|
||||
char *scanstring();
|
||||
int writeblanks();
|
||||
int test1();
|
||||
int convert1();
|
||||
|
||||
/* The main program */
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{ FILE *in = stdin;
|
||||
FILE *out = stdout;
|
||||
char *filename = 0;
|
||||
char *program_name = argv[0];
|
||||
char *output_name = 0;
|
||||
#define bufsize 5000 /* arbitrary size */
|
||||
char *buf;
|
||||
char *line;
|
||||
char *more;
|
||||
char *usage =
|
||||
"Usage: ansi2knr [--filename FILENAME] [INPUT_FILE [OUTPUT_FILE]]\n";
|
||||
/*
|
||||
* In previous versions, ansi2knr recognized a --varargs switch.
|
||||
* If this switch was supplied, ansi2knr would attempt to convert
|
||||
* a ... argument to va_alist and va_dcl; if this switch was not
|
||||
* supplied, ansi2knr would simply drop any such arguments.
|
||||
* Now, ansi2knr always does this conversion, and we only
|
||||
* check for this switch for backward compatibility.
|
||||
*/
|
||||
int convert_varargs = 1;
|
||||
int output_error;
|
||||
|
||||
while ( argc > 1 && argv[1][0] == '-' ) {
|
||||
if ( !strcmp(argv[1], "--varargs") ) {
|
||||
convert_varargs = 1;
|
||||
argc--;
|
||||
argv++;
|
||||
continue;
|
||||
}
|
||||
if ( !strcmp(argv[1], "--filename") && argc > 2 ) {
|
||||
filename = argv[2];
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
continue;
|
||||
}
|
||||
fprintf(stderr, "%s: Unrecognized switch: %s\n", program_name,
|
||||
argv[1]);
|
||||
fprintf(stderr, usage);
|
||||
exit(1);
|
||||
}
|
||||
switch ( argc )
|
||||
{
|
||||
default:
|
||||
fprintf(stderr, usage);
|
||||
exit(0);
|
||||
case 3:
|
||||
output_name = argv[2];
|
||||
out = fopen(output_name, "w");
|
||||
if ( out == NULL ) {
|
||||
fprintf(stderr, "%s: Cannot open output file %s\n",
|
||||
program_name, output_name);
|
||||
exit(1);
|
||||
}
|
||||
/* falls through */
|
||||
case 2:
|
||||
in = fopen(argv[1], "r");
|
||||
if ( in == NULL ) {
|
||||
fprintf(stderr, "%s: Cannot open input file %s\n",
|
||||
program_name, argv[1]);
|
||||
exit(1);
|
||||
}
|
||||
if ( filename == 0 )
|
||||
filename = argv[1];
|
||||
/* falls through */
|
||||
case 1:
|
||||
break;
|
||||
}
|
||||
if ( filename )
|
||||
fprintf(out, "#line 1 \"%s\"\n", filename);
|
||||
buf = malloc(bufsize);
|
||||
if ( buf == NULL )
|
||||
{
|
||||
fprintf(stderr, "Unable to allocate read buffer!\n");
|
||||
exit(1);
|
||||
}
|
||||
line = buf;
|
||||
while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL )
|
||||
{
|
||||
test: line += strlen(line);
|
||||
switch ( test1(buf) )
|
||||
{
|
||||
case 2: /* a function header */
|
||||
convert1(buf, out, 1, convert_varargs);
|
||||
break;
|
||||
case 1: /* a function */
|
||||
/* Check for a { at the start of the next line. */
|
||||
more = ++line;
|
||||
f: if ( line >= buf + (bufsize - 1) ) /* overflow check */
|
||||
goto wl;
|
||||
if ( fgets(line, (unsigned)(buf + bufsize - line), in) == NULL )
|
||||
goto wl;
|
||||
switch ( *skipspace(more, 1) )
|
||||
{
|
||||
case '{':
|
||||
/* Definitely a function header. */
|
||||
convert1(buf, out, 0, convert_varargs);
|
||||
fputs(more, out);
|
||||
break;
|
||||
case 0:
|
||||
/* The next line was blank or a comment: */
|
||||
/* keep scanning for a non-comment. */
|
||||
line += strlen(line);
|
||||
goto f;
|
||||
default:
|
||||
/* buf isn't a function header, but */
|
||||
/* more might be. */
|
||||
fputs(buf, out);
|
||||
strcpy(buf, more);
|
||||
line = buf;
|
||||
goto test;
|
||||
}
|
||||
break;
|
||||
case -1: /* maybe the start of a function */
|
||||
if ( line != buf + (bufsize - 1) ) /* overflow check */
|
||||
continue;
|
||||
/* falls through */
|
||||
default: /* not a function */
|
||||
wl: fputs(buf, out);
|
||||
break;
|
||||
}
|
||||
line = buf;
|
||||
}
|
||||
if ( line != buf )
|
||||
fputs(buf, out);
|
||||
free(buf);
|
||||
if ( output_name ) {
|
||||
output_error = ferror(out);
|
||||
output_error |= fclose(out);
|
||||
} else { /* out == stdout */
|
||||
fflush(out);
|
||||
output_error = ferror(out);
|
||||
}
|
||||
if ( output_error ) {
|
||||
fprintf(stderr, "%s: error writing to %s\n", program_name,
|
||||
(output_name ? output_name : "stdout"));
|
||||
exit(1);
|
||||
}
|
||||
if ( in != stdin )
|
||||
fclose(in);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Skip over whitespace and comments, in either direction. */
|
||||
char *
|
||||
skipspace(p, dir)
|
||||
register char *p;
|
||||
register int dir; /* 1 for forward, -1 for backward */
|
||||
{ for ( ; ; )
|
||||
{ while ( is_space(*p) )
|
||||
p += dir;
|
||||
if ( !(*p == '/' && p[dir] == '*') )
|
||||
break;
|
||||
p += dir; p += dir;
|
||||
while ( !(*p == '*' && p[dir] == '/') )
|
||||
{ if ( *p == 0 )
|
||||
return p; /* multi-line comment?? */
|
||||
p += dir;
|
||||
}
|
||||
p += dir; p += dir;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Scan over a quoted string, in either direction. */
|
||||
char *
|
||||
scanstring(p, dir)
|
||||
register char *p;
|
||||
register int dir;
|
||||
{
|
||||
for (p += dir; ; p += dir)
|
||||
if (*p == '"' && p[-dir] != '\\')
|
||||
return p + dir;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write blanks over part of a string.
|
||||
* Don't overwrite end-of-line characters.
|
||||
*/
|
||||
int
|
||||
writeblanks(start, end)
|
||||
char *start;
|
||||
char *end;
|
||||
{ char *p;
|
||||
for ( p = start; p < end; p++ )
|
||||
if ( *p != '\r' && *p != '\n' )
|
||||
*p = ' ';
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Test whether the string in buf is a function definition.
|
||||
* The string may contain and/or end with a newline.
|
||||
* Return as follows:
|
||||
* 0 - definitely not a function definition;
|
||||
* 1 - definitely a function definition;
|
||||
* 2 - definitely a function prototype (NOT USED);
|
||||
* -1 - may be the beginning of a function definition,
|
||||
* append another line and look again.
|
||||
* The reason we don't attempt to convert function prototypes is that
|
||||
* Ghostscript's declaration-generating macros look too much like
|
||||
* prototypes, and confuse the algorithms.
|
||||
*/
|
||||
int
|
||||
test1(buf)
|
||||
char *buf;
|
||||
{ register char *p = buf;
|
||||
char *bend;
|
||||
char *endfn;
|
||||
int contin;
|
||||
|
||||
if ( !isidfirstchar(*p) )
|
||||
return 0; /* no name at left margin */
|
||||
bend = skipspace(buf + strlen(buf) - 1, -1);
|
||||
switch ( *bend )
|
||||
{
|
||||
case ';': contin = 0 /*2*/; break;
|
||||
case ')': contin = 1; break;
|
||||
case '{': return 0; /* not a function */
|
||||
case '}': return 0; /* not a function */
|
||||
default: contin = -1;
|
||||
}
|
||||
while ( isidchar(*p) )
|
||||
p++;
|
||||
endfn = p;
|
||||
p = skipspace(p, 1);
|
||||
if ( *p++ != '(' )
|
||||
return 0; /* not a function */
|
||||
p = skipspace(p, 1);
|
||||
if ( *p == ')' )
|
||||
return 0; /* no parameters */
|
||||
/* Check that the apparent function name isn't a keyword. */
|
||||
/* We only need to check for keywords that could be followed */
|
||||
/* by a left parenthesis (which, unfortunately, is most of them). */
|
||||
{ static char *words[] =
|
||||
{ "asm", "auto", "case", "char", "const", "double",
|
||||
"extern", "float", "for", "if", "int", "long",
|
||||
"register", "return", "short", "signed", "sizeof",
|
||||
"static", "switch", "typedef", "unsigned",
|
||||
"void", "volatile", "while", 0
|
||||
};
|
||||
char **key = words;
|
||||
char *kp;
|
||||
unsigned len = endfn - buf;
|
||||
|
||||
while ( (kp = *key) != 0 )
|
||||
{ if ( strlen(kp) == len && !strncmp(kp, buf, len) )
|
||||
return 0; /* name is a keyword */
|
||||
key++;
|
||||
}
|
||||
}
|
||||
{
|
||||
char *id = p;
|
||||
int len;
|
||||
/*
|
||||
* Check for identifier1(identifier2) and not
|
||||
* identifier1(void), or identifier1(identifier2, xxxx).
|
||||
*/
|
||||
|
||||
while ( isidchar(*p) )
|
||||
p++;
|
||||
len = p - id;
|
||||
p = skipspace(p, 1);
|
||||
if (*p == ',' ||
|
||||
(*p == ')' && (len != 4 || strncmp(id, "void", 4)))
|
||||
)
|
||||
return 0; /* not a function */
|
||||
}
|
||||
/*
|
||||
* If the last significant character was a ), we need to count
|
||||
* parentheses, because it might be part of a formal parameter
|
||||
* that is a procedure.
|
||||
*/
|
||||
if (contin > 0) {
|
||||
int level = 0;
|
||||
|
||||
for (p = skipspace(buf, 1); *p; p = skipspace(p + 1, 1))
|
||||
level += (*p == '(' ? 1 : *p == ')' ? -1 : 0);
|
||||
if (level > 0)
|
||||
contin = -1;
|
||||
}
|
||||
return contin;
|
||||
}
|
||||
|
||||
/* Convert a recognized function definition or header to K&R syntax. */
|
||||
int
|
||||
convert1(buf, out, header, convert_varargs)
|
||||
char *buf;
|
||||
FILE *out;
|
||||
int header; /* Boolean */
|
||||
int convert_varargs; /* Boolean */
|
||||
{ char *endfn;
|
||||
register char *p;
|
||||
/*
|
||||
* The breaks table contains pointers to the beginning and end
|
||||
* of each argument.
|
||||
*/
|
||||
char **breaks;
|
||||
unsigned num_breaks = 2; /* for testing */
|
||||
char **btop;
|
||||
char **bp;
|
||||
char **ap;
|
||||
char *vararg = 0;
|
||||
|
||||
/* Pre-ANSI implementations don't agree on whether strchr */
|
||||
/* is called strchr or index, so we open-code it here. */
|
||||
for ( endfn = buf; *(endfn++) != '('; )
|
||||
;
|
||||
top: p = endfn;
|
||||
breaks = (char **)malloc(sizeof(char *) * num_breaks * 2);
|
||||
if ( breaks == NULL )
|
||||
{ /* Couldn't allocate break table, give up */
|
||||
fprintf(stderr, "Unable to allocate break table!\n");
|
||||
fputs(buf, out);
|
||||
return -1;
|
||||
}
|
||||
btop = breaks + num_breaks * 2 - 2;
|
||||
bp = breaks;
|
||||
/* Parse the argument list */
|
||||
do
|
||||
{ int level = 0;
|
||||
char *lp = NULL;
|
||||
char *rp = NULL;
|
||||
char *end = NULL;
|
||||
|
||||
if ( bp >= btop )
|
||||
{ /* Filled up break table. */
|
||||
/* Allocate a bigger one and start over. */
|
||||
free((char *)breaks);
|
||||
num_breaks <<= 1;
|
||||
goto top;
|
||||
}
|
||||
*bp++ = p;
|
||||
/* Find the end of the argument */
|
||||
for ( ; end == NULL; p++ )
|
||||
{ switch(*p)
|
||||
{
|
||||
case ',':
|
||||
if ( !level ) end = p;
|
||||
break;
|
||||
case '(':
|
||||
if ( !level ) lp = p;
|
||||
level++;
|
||||
break;
|
||||
case ')':
|
||||
if ( --level < 0 ) end = p;
|
||||
else rp = p;
|
||||
break;
|
||||
case '/':
|
||||
if (p[1] == '*')
|
||||
p = skipspace(p, 1) - 1;
|
||||
break;
|
||||
case '"':
|
||||
p = scanstring(p, 1) - 1;
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
/* Erase any embedded prototype parameters. */
|
||||
if ( lp && rp )
|
||||
writeblanks(lp + 1, rp);
|
||||
p--; /* back up over terminator */
|
||||
/* Find the name being declared. */
|
||||
/* This is complicated because of procedure and */
|
||||
/* array modifiers. */
|
||||
for ( ; ; )
|
||||
{ p = skipspace(p - 1, -1);
|
||||
switch ( *p )
|
||||
{
|
||||
case ']': /* skip array dimension(s) */
|
||||
case ')': /* skip procedure args OR name */
|
||||
{ int level = 1;
|
||||
while ( level )
|
||||
switch ( *--p )
|
||||
{
|
||||
case ']': case ')':
|
||||
level++;
|
||||
break;
|
||||
case '[': case '(':
|
||||
level--;
|
||||
break;
|
||||
case '/':
|
||||
if (p > buf && p[-1] == '*')
|
||||
p = skipspace(p, -1) + 1;
|
||||
break;
|
||||
case '"':
|
||||
p = scanstring(p, -1) + 1;
|
||||
break;
|
||||
default: ;
|
||||
}
|
||||
}
|
||||
if ( *p == '(' && *skipspace(p + 1, 1) == '*' )
|
||||
{ /* We found the name being declared */
|
||||
while ( !isidfirstchar(*p) )
|
||||
p = skipspace(p, 1) + 1;
|
||||
goto found;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
goto found;
|
||||
}
|
||||
}
|
||||
found: if ( *p == '.' && p[-1] == '.' && p[-2] == '.' )
|
||||
{ if ( convert_varargs )
|
||||
{ *bp++ = "va_alist";
|
||||
vararg = p-2;
|
||||
}
|
||||
else
|
||||
{ p++;
|
||||
if ( bp == breaks + 1 ) /* sole argument */
|
||||
writeblanks(breaks[0], p);
|
||||
else
|
||||
writeblanks(bp[-1] - 1, p);
|
||||
bp--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ while ( isidchar(*p) ) p--;
|
||||
*bp++ = p+1;
|
||||
}
|
||||
p = end;
|
||||
}
|
||||
while ( *p++ == ',' );
|
||||
*bp = p;
|
||||
/* Make a special check for 'void' arglist */
|
||||
if ( bp == breaks+2 )
|
||||
{ p = skipspace(breaks[0], 1);
|
||||
if ( !strncmp(p, "void", 4) )
|
||||
{ p = skipspace(p+4, 1);
|
||||
if ( p == breaks[2] - 1 )
|
||||
{ bp = breaks; /* yup, pretend arglist is empty */
|
||||
writeblanks(breaks[0], p + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Put out the function name and left parenthesis. */
|
||||
p = buf;
|
||||
while ( p != endfn ) putc(*p, out), p++;
|
||||
/* Put out the declaration. */
|
||||
if ( header )
|
||||
{ fputs(");", out);
|
||||
for ( p = breaks[0]; *p; p++ )
|
||||
if ( *p == '\r' || *p == '\n' )
|
||||
putc(*p, out);
|
||||
}
|
||||
else
|
||||
{ for ( ap = breaks+1; ap < bp; ap += 2 )
|
||||
{ p = *ap;
|
||||
while ( isidchar(*p) )
|
||||
putc(*p, out), p++;
|
||||
if ( ap < bp - 1 )
|
||||
fputs(", ", out);
|
||||
}
|
||||
fputs(") ", out);
|
||||
/* Put out the argument declarations */
|
||||
for ( ap = breaks+2; ap <= bp; ap += 2 )
|
||||
(*ap)[-1] = ';';
|
||||
if ( vararg != 0 )
|
||||
{ *vararg = 0;
|
||||
fputs(breaks[0], out); /* any prior args */
|
||||
fputs("va_dcl", out); /* the final arg */
|
||||
fputs(bp[0], out);
|
||||
}
|
||||
else
|
||||
fputs(breaks[0], out);
|
||||
}
|
||||
free((char *)breaks);
|
||||
return 0;
|
||||
}
|
161
src/cmpt.c
161
src/cmpt.c
@ -31,36 +31,16 @@ so, delete this exception statement from your version. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif /* HAVE_STRING_H */
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <limits.h>
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#include "wget.h"
|
||||
|
||||
#ifndef HAVE_STRERROR
|
||||
/* A strerror() clone, for systems that don't have it. */
|
||||
char *
|
||||
strerror (int err)
|
||||
{
|
||||
/* This loses on a system without `sys_errlist'. */
|
||||
extern char *sys_errlist[];
|
||||
return sys_errlist[err];
|
||||
}
|
||||
#endif /* not HAVE_STRERROR */
|
||||
|
||||
/* Some systems don't have some str* functions in libc. Here we
|
||||
define them. The same goes for strptime. */
|
||||
|
||||
@ -120,104 +100,6 @@ strncasecmp (const char *s1, const char *s2, size_t n)
|
||||
}
|
||||
#endif /* not HAVE_STRNCASECMP */
|
||||
|
||||
#ifndef HAVE_STRSTR
|
||||
/* From GNU libc 2.3.5. */
|
||||
|
||||
/*
|
||||
* My personal strstr() implementation that beats most other algorithms.
|
||||
* Until someone tells me otherwise, I assume that this is the
|
||||
* fastest implementation of strstr() in C.
|
||||
* I deliberately chose not to comment it. You should have at least
|
||||
* as much fun trying to understand it, as I had to write it :-).
|
||||
*
|
||||
* Stephen R. van den Berg, berg@pool.informatik.rwth-aachen.de */
|
||||
|
||||
typedef unsigned chartype;
|
||||
|
||||
#undef strstr
|
||||
|
||||
char *
|
||||
strstr (const char *phaystack, const char *pneedle)
|
||||
{
|
||||
const unsigned char *haystack, *needle;
|
||||
chartype b;
|
||||
const unsigned char *rneedle;
|
||||
|
||||
haystack = (const unsigned char *) phaystack;
|
||||
|
||||
if ((b = *(needle = (const unsigned char *) pneedle)))
|
||||
{
|
||||
chartype c;
|
||||
haystack--; /* possible ANSI violation */
|
||||
|
||||
{
|
||||
chartype a;
|
||||
do
|
||||
if (!(a = *++haystack))
|
||||
goto ret0;
|
||||
while (a != b);
|
||||
}
|
||||
|
||||
if (!(c = *++needle))
|
||||
goto foundneedle;
|
||||
++needle;
|
||||
goto jin;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
{
|
||||
chartype a;
|
||||
if (0)
|
||||
jin:{
|
||||
if ((a = *++haystack) == c)
|
||||
goto crest;
|
||||
}
|
||||
else
|
||||
a = *++haystack;
|
||||
do
|
||||
{
|
||||
for (; a != b; a = *++haystack)
|
||||
{
|
||||
if (!a)
|
||||
goto ret0;
|
||||
if ((a = *++haystack) == b)
|
||||
break;
|
||||
if (!a)
|
||||
goto ret0;
|
||||
}
|
||||
}
|
||||
while ((a = *++haystack) != c);
|
||||
}
|
||||
crest:
|
||||
{
|
||||
chartype a;
|
||||
{
|
||||
const unsigned char *rhaystack;
|
||||
if (*(rhaystack = haystack-- + 1) == (a = *(rneedle = needle)))
|
||||
do
|
||||
{
|
||||
if (!a)
|
||||
goto foundneedle;
|
||||
if (*++rhaystack != (a = *++needle))
|
||||
break;
|
||||
if (!a)
|
||||
goto foundneedle;
|
||||
}
|
||||
while (*++rhaystack == (a = *++needle));
|
||||
needle = rneedle; /* took the register-poor aproach */
|
||||
}
|
||||
if (!a)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
foundneedle:
|
||||
return (char *) haystack;
|
||||
ret0:
|
||||
return 0;
|
||||
}
|
||||
#endif /* not HAVE_STRSTR */
|
||||
|
||||
#ifndef HAVE_STRPBRK
|
||||
/* Find the first ocurrence in S of any character in ACCEPT. */
|
||||
char *
|
||||
@ -257,7 +139,7 @@ strpbrk (const char *s, const char *accept)
|
||||
#endif
|
||||
|
||||
#ifndef __P
|
||||
# define __P(args) PARAMS (args)
|
||||
# define __P(args) args
|
||||
#endif /* Not __P. */
|
||||
|
||||
#ifndef CHAR_BIT
|
||||
@ -525,7 +407,7 @@ weak_alias (mktime, timelocal)
|
||||
this is enough information for determining the date. */
|
||||
|
||||
#ifndef __P
|
||||
# define __P(args) PARAMS (args)
|
||||
# define __P(args) args
|
||||
#endif /* not __P */
|
||||
|
||||
#if ! HAVE_LOCALTIME_R && ! defined localtime_r
|
||||
@ -1433,30 +1315,17 @@ const unsigned short int __mon_yday[2][13] =
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MEMMOVE
|
||||
void *
|
||||
memmove (char *dest, const char *source, unsigned length)
|
||||
{
|
||||
char *d0 = dest;
|
||||
if (source < dest)
|
||||
/* Moving from low mem to hi mem; start at end. */
|
||||
for (source += length, dest += length; length; --length)
|
||||
*--dest = *--source;
|
||||
else if (source != dest)
|
||||
{
|
||||
/* Moving from hi mem to low mem; start at beginning. */
|
||||
for (; length; --length)
|
||||
*dest++ = *source++;
|
||||
}
|
||||
return (void *) d0;
|
||||
}
|
||||
#endif /* not HAVE_MEMMOVE */
|
||||
/* fnmatch is defined by POSIX, but we include an implementation for
|
||||
the sake of systems that don't have it. Some systems do have
|
||||
fnmatch, but Apache installs its own fnmatch.h (incompatible with
|
||||
the system one) in a system include directory, effectively
|
||||
rendering fnmatch unusable.
|
||||
|
||||
/* fnmatch is a POSIX function, but we include an implementation for
|
||||
the sake of systems that don't have it. Furthermore, according to
|
||||
anecdotal evidence, historical implementations of fnmatch are buggy
|
||||
and unreliable. So we use our version, except when compiling under
|
||||
systems where fnmatch is known to work (currently glibc.) */
|
||||
Additionally according to anecdotal evidence and conventional
|
||||
wisdom I lack courage to challenge, many implementations of fnmatch
|
||||
are notoriously buggy and unreliable. So we use our version by
|
||||
default, except when compiling under systems where fnmatch is known
|
||||
to work (currently on GNU libc-based systems and Solaris.) */
|
||||
|
||||
#ifndef SYSTEM_FNMATCH
|
||||
|
||||
@ -1465,8 +1334,8 @@ memmove (char *dest, const char *source, unsigned length)
|
||||
/* Match STRING against the filename pattern PATTERN, returning zero
|
||||
if it matches, FNM_NOMATCH if not. This implementation comes from
|
||||
an earlier version of GNU Bash. (It doesn't make sense to update
|
||||
it with a newer version because it adds a lot of features Wget
|
||||
doesn't use or care about.) */
|
||||
it with a newer version because those versions add a lot of
|
||||
features Wget doesn't use or care about.) */
|
||||
|
||||
int
|
||||
fnmatch (const char *pattern, const char *string, int flags)
|
||||
|
@ -60,16 +60,3 @@ void *alloca ();
|
||||
#define _BSD_SOURCE
|
||||
|
||||
#endif /* NAMESPACE_TWEAKS */
|
||||
|
||||
/* Determine whether to use stdarg. Use it only if the compiler
|
||||
supports ANSI C and stdarg.h is present. We check for both because
|
||||
there are configurations where stdarg.h exists, but doesn't work.
|
||||
This check cannot be in sysdep.h because we use it to choose which
|
||||
system headers to include. */
|
||||
#ifndef WGET_USE_STDARG
|
||||
# ifdef __STDC__
|
||||
# ifdef HAVE_STDARG_H
|
||||
# define WGET_USE_STDARG
|
||||
# endif
|
||||
# endif
|
||||
#endif /* not WGET_USE_STDARG */
|
||||
|
@ -31,7 +31,6 @@ so, delete this exception statement from your version. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
@ -47,11 +46,7 @@ so, delete this exception statement from your version. */
|
||||
#endif /* not WINDOWS */
|
||||
|
||||
#include <errno.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif /* HAVE_STRING_H */
|
||||
#include <string.h>
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
# include <sys/select.h>
|
||||
#endif /* HAVE_SYS_SELECT_H */
|
||||
@ -62,10 +57,6 @@ so, delete this exception statement from your version. */
|
||||
#include "connect.h"
|
||||
#include "hash.h"
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
/* Define sockaddr_storage where unavailable (presumably on IPv4-only
|
||||
hosts). */
|
||||
|
||||
|
@ -38,40 +38,39 @@ so, delete this exception statement from your version. */
|
||||
enum {
|
||||
E_HOST = -100
|
||||
};
|
||||
int connect_to_host PARAMS ((const char *, int));
|
||||
int connect_to_ip PARAMS ((const ip_address *, int, const char *));
|
||||
int connect_to_host (const char *, int);
|
||||
int connect_to_ip (const ip_address *, int, const char *);
|
||||
|
||||
int bind_local PARAMS ((const ip_address *, int *));
|
||||
int accept_connection PARAMS ((int));
|
||||
int bind_local (const ip_address *, int *);
|
||||
int accept_connection (int);
|
||||
|
||||
enum {
|
||||
ENDPOINT_LOCAL,
|
||||
ENDPOINT_PEER
|
||||
};
|
||||
int socket_ip_address PARAMS ((int, ip_address *, int));
|
||||
int socket_ip_address (int, ip_address *, int);
|
||||
|
||||
int retryable_socket_connect_error PARAMS ((int));
|
||||
int retryable_socket_connect_error (int);
|
||||
|
||||
/* Flags for select_fd's WAIT_FOR argument. */
|
||||
enum {
|
||||
WAIT_FOR_READ = 1,
|
||||
WAIT_FOR_WRITE = 2
|
||||
};
|
||||
int select_fd PARAMS ((int, double, int));
|
||||
int test_socket_open PARAMS ((int));
|
||||
int select_fd (int, double, int);
|
||||
int test_socket_open (int);
|
||||
|
||||
typedef int (*fd_reader_t) PARAMS ((int, char *, int, void *));
|
||||
typedef int (*fd_writer_t) PARAMS ((int, char *, int, void *));
|
||||
typedef int (*fd_poller_t) PARAMS ((int, double, int, void *));
|
||||
typedef int (*fd_peeker_t) PARAMS ((int, char *, int, void *));
|
||||
typedef void (*fd_closer_t) PARAMS ((int, void *));
|
||||
void fd_register_transport PARAMS ((int, fd_reader_t, fd_writer_t,
|
||||
fd_poller_t, fd_peeker_t, fd_closer_t,
|
||||
void *));
|
||||
void *fd_transport_context PARAMS ((int));
|
||||
typedef int (*fd_reader_t) (int, char *, int, void *);
|
||||
typedef int (*fd_writer_t) (int, char *, int, void *);
|
||||
typedef int (*fd_poller_t) (int, double, int, void *);
|
||||
typedef int (*fd_peeker_t) (int, char *, int, void *);
|
||||
typedef void (*fd_closer_t) (int, void *);
|
||||
void fd_register_transport (int, fd_reader_t, fd_writer_t,
|
||||
fd_poller_t, fd_peeker_t, fd_closer_t, void *);
|
||||
void *fd_transport_context (int);
|
||||
|
||||
int fd_read PARAMS ((int, char *, int, double));
|
||||
int fd_write PARAMS ((int, char *, int, double));
|
||||
int fd_peek PARAMS ((int, char *, int, double));
|
||||
void fd_close PARAMS ((int));
|
||||
int fd_read (int, char *, int, double);
|
||||
int fd_write (int, char *, int, double);
|
||||
int fd_peek (int, char *, int, double);
|
||||
void fd_close (int);
|
||||
#endif /* CONNECT_H */
|
||||
|
@ -31,17 +31,12 @@ so, delete this exception statement from your version. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif /* HAVE_STRING_H */
|
||||
#include <string.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "wget.h"
|
||||
#include "convert.h"
|
||||
@ -58,7 +53,7 @@ struct hash_table *dl_url_file_map;
|
||||
conversion after Wget is done. */
|
||||
struct hash_table *downloaded_html_set;
|
||||
|
||||
static void convert_links PARAMS ((const char *, struct urlpos *));
|
||||
static void convert_links (const char *, struct urlpos *);
|
||||
|
||||
/* This function is called when the retrieval is done to convert the
|
||||
links that have been downloaded. It has to be called at the end of
|
||||
@ -177,13 +172,12 @@ convert_all_links (void)
|
||||
file_count, secs < 10 ? 3 : 1, secs);
|
||||
}
|
||||
|
||||
static void write_backup_file PARAMS ((const char *, downloaded_file_t));
|
||||
static const char *replace_attr PARAMS ((const char *, int, FILE *,
|
||||
const char *));
|
||||
static const char *replace_attr_refresh_hack PARAMS ((const char *, int, FILE *,
|
||||
const char *, int));
|
||||
static char *local_quote_string PARAMS ((const char *));
|
||||
static char *construct_relative PARAMS ((const char *, const char *));
|
||||
static void write_backup_file (const char *, downloaded_file_t);
|
||||
static const char *replace_attr (const char *, int, FILE *, const char *);
|
||||
static const char *replace_attr_refresh_hack (const char *, int, FILE *,
|
||||
const char *, int);
|
||||
static char *local_quote_string (const char *);
|
||||
static char *construct_relative (const char *, const char *);
|
||||
|
||||
/* Change the links in one HTML file. LINKS is a list of links in the
|
||||
document, along with their positions and the desired direction of
|
||||
@ -468,8 +462,7 @@ write_backup_file (const char *file, downloaded_file_t downloaded_file_return)
|
||||
}
|
||||
}
|
||||
|
||||
static int find_fragment PARAMS ((const char *, int, const char **,
|
||||
const char **));
|
||||
static int find_fragment (const char *, int, const char **, const char **);
|
||||
|
||||
/* Replace an attribute's original text with NEW_TEXT. */
|
||||
|
||||
@ -837,7 +830,7 @@ register_html (const char *url, const char *file)
|
||||
string_set_add (downloaded_html_set, file);
|
||||
}
|
||||
|
||||
static void downloaded_files_free PARAMS ((void));
|
||||
static void downloaded_files_free (void);
|
||||
|
||||
/* Cleanup the data structures associated with this file. */
|
||||
|
||||
|
@ -92,15 +92,15 @@ typedef enum
|
||||
CHECK_FOR_FILE
|
||||
} downloaded_file_t;
|
||||
|
||||
downloaded_file_t downloaded_file PARAMS ((downloaded_file_t, const char *));
|
||||
downloaded_file_t downloaded_file (downloaded_file_t, const char *);
|
||||
|
||||
void register_download PARAMS ((const char *, const char *));
|
||||
void register_redirection PARAMS ((const char *, const char *));
|
||||
void register_html PARAMS ((const char *, const char *));
|
||||
void register_delete_file PARAMS ((const char *));
|
||||
void convert_all_links PARAMS ((void));
|
||||
void convert_cleanup PARAMS ((void));
|
||||
void register_download (const char *, const char *);
|
||||
void register_redirection (const char *, const char *);
|
||||
void register_html (const char *, const char *);
|
||||
void register_delete_file (const char *);
|
||||
void convert_all_links (void);
|
||||
void convert_cleanup (void);
|
||||
|
||||
char *html_quote_string PARAMS ((const char *));
|
||||
char *html_quote_string (const char *);
|
||||
|
||||
#endif /* CONVERT_H */
|
||||
|
@ -45,14 +45,11 @@ so, delete this exception statement from your version. */
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "wget.h"
|
||||
#include "utils.h"
|
||||
@ -60,7 +57,7 @@ so, delete this exception statement from your version. */
|
||||
#include "cookies.h"
|
||||
|
||||
/* This should *really* be in a .h file! */
|
||||
time_t http_atotm PARAMS ((const char *));
|
||||
time_t http_atotm (const char *);
|
||||
|
||||
/* Declarations of `struct cookie' and the most basic functions. */
|
||||
|
||||
@ -818,7 +815,7 @@ check_domain_match (const char *cookie_domain, const char *host)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int path_matches PARAMS ((const char *, const char *));
|
||||
static int path_matches (const char *, const char *);
|
||||
|
||||
/* Check whether PATH begins with COOKIE_PATH. */
|
||||
|
||||
|
@ -32,15 +32,14 @@ so, delete this exception statement from your version. */
|
||||
|
||||
struct cookie_jar;
|
||||
|
||||
struct cookie_jar *cookie_jar_new PARAMS ((void));
|
||||
void cookie_jar_delete PARAMS ((struct cookie_jar *));
|
||||
struct cookie_jar *cookie_jar_new (void);
|
||||
void cookie_jar_delete (struct cookie_jar *);
|
||||
|
||||
void cookie_handle_set_cookie PARAMS ((struct cookie_jar *, const char *,
|
||||
int, const char *, const char *));
|
||||
char *cookie_header PARAMS ((struct cookie_jar *,
|
||||
const char *, int, const char *, int));
|
||||
void cookie_handle_set_cookie (struct cookie_jar *, const char *, int,
|
||||
const char *, const char *);
|
||||
char *cookie_header (struct cookie_jar *, const char *, int, const char *, int);
|
||||
|
||||
void cookie_jar_load PARAMS ((struct cookie_jar *, const char *));
|
||||
void cookie_jar_save PARAMS ((struct cookie_jar *, const char *));
|
||||
void cookie_jar_load (struct cookie_jar *, const char *);
|
||||
void cookie_jar_save (struct cookie_jar *, const char *);
|
||||
|
||||
#endif /* COOKIES_H */
|
||||
|
@ -34,15 +34,10 @@ so, delete this exception statement from your version. */
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "wget.h"
|
||||
#include "utils.h"
|
||||
@ -164,7 +159,7 @@ ftp_login (int csock, const char *acc, const char *pass)
|
||||
xfree (respline);
|
||||
/* Send USER username. */
|
||||
request = ftp_request ("USER", acc);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1.0);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1);
|
||||
if (nwritten < 0)
|
||||
{
|
||||
xfree (request);
|
||||
@ -228,7 +223,7 @@ ftp_login (int csock, const char *acc, const char *pass)
|
||||
xfree (respline);
|
||||
/* Send PASS password. */
|
||||
request = ftp_request ("PASS", pass);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1.0);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1);
|
||||
if (nwritten < 0)
|
||||
{
|
||||
xfree (request);
|
||||
@ -300,7 +295,7 @@ ftp_port (int csock, int *local_sock)
|
||||
|
||||
/* Send PORT request. */
|
||||
request = ftp_request ("PORT", bytes);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1.0);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1);
|
||||
if (nwritten < 0)
|
||||
{
|
||||
xfree (request);
|
||||
@ -393,7 +388,7 @@ ftp_lprt (int csock, int *local_sock)
|
||||
|
||||
/* Send PORT request. */
|
||||
request = ftp_request ("LPRT", bytes);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1.0);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1);
|
||||
if (nwritten < 0)
|
||||
{
|
||||
xfree (request);
|
||||
@ -473,7 +468,7 @@ ftp_eprt (int csock, int *local_sock)
|
||||
|
||||
/* Send PORT request. */
|
||||
request = ftp_request ("EPRT", bytes);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1.0);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1);
|
||||
if (nwritten < 0)
|
||||
{
|
||||
xfree (request);
|
||||
@ -518,7 +513,7 @@ ftp_pasv (int csock, ip_address *addr, int *port)
|
||||
/* Form the request. */
|
||||
request = ftp_request ("PASV", NULL);
|
||||
/* And send it. */
|
||||
nwritten = fd_write (csock, request, strlen (request), -1.0);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1);
|
||||
if (nwritten < 0)
|
||||
{
|
||||
xfree (request);
|
||||
@ -584,7 +579,7 @@ ftp_lpsv (int csock, ip_address *addr, int *port)
|
||||
request = ftp_request ("LPSV", NULL);
|
||||
|
||||
/* And send it. */
|
||||
nwritten = fd_write (csock, request, strlen (request), -1.0);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1);
|
||||
if (nwritten < 0)
|
||||
{
|
||||
xfree (request);
|
||||
@ -746,7 +741,7 @@ ftp_epsv (int csock, ip_address *ip, int *port)
|
||||
request = ftp_request ("EPSV", (ip->type == IPV4_ADDRESS ? "1" : "2"));
|
||||
|
||||
/* And send it. */
|
||||
nwritten = fd_write (csock, request, strlen (request), -1.0);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1);
|
||||
if (nwritten < 0)
|
||||
{
|
||||
xfree (request);
|
||||
@ -843,7 +838,7 @@ ftp_type (int csock, int type)
|
||||
stype[1] = 0;
|
||||
/* Send TYPE request. */
|
||||
request = ftp_request ("TYPE", stype);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1.0);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1);
|
||||
if (nwritten < 0)
|
||||
{
|
||||
xfree (request);
|
||||
@ -875,7 +870,7 @@ ftp_cwd (int csock, const char *dir)
|
||||
|
||||
/* Send CWD request. */
|
||||
request = ftp_request ("CWD", dir);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1.0);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1);
|
||||
if (nwritten < 0)
|
||||
{
|
||||
xfree (request);
|
||||
@ -910,7 +905,7 @@ ftp_rest (int csock, wgint offset)
|
||||
uerr_t err;
|
||||
|
||||
request = ftp_request ("REST", number_to_static_string (offset));
|
||||
nwritten = fd_write (csock, request, strlen (request), -1.0);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1);
|
||||
if (nwritten < 0)
|
||||
{
|
||||
xfree (request);
|
||||
@ -941,7 +936,7 @@ ftp_retr (int csock, const char *file)
|
||||
|
||||
/* Send RETR request. */
|
||||
request = ftp_request ("RETR", file);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1.0);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1);
|
||||
if (nwritten < 0)
|
||||
{
|
||||
xfree (request);
|
||||
@ -978,7 +973,7 @@ ftp_list (int csock, const char *file)
|
||||
|
||||
/* Send LIST request. */
|
||||
request = ftp_request ("LIST", file);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1.0);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1);
|
||||
if (nwritten < 0)
|
||||
{
|
||||
xfree (request);
|
||||
@ -1014,7 +1009,7 @@ ftp_syst (int csock, enum stype *server_type)
|
||||
|
||||
/* Send SYST request. */
|
||||
request = ftp_request ("SYST", NULL);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1.0);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1);
|
||||
if (nwritten < 0)
|
||||
{
|
||||
xfree (request);
|
||||
@ -1068,7 +1063,7 @@ ftp_pwd (int csock, char **pwd)
|
||||
|
||||
/* Send PWD request. */
|
||||
request = ftp_request ("PWD", NULL);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1.0);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1);
|
||||
if (nwritten < 0)
|
||||
{
|
||||
xfree (request);
|
||||
@ -1116,7 +1111,7 @@ ftp_size (int csock, const char *file, wgint *size)
|
||||
|
||||
/* Send PWD request. */
|
||||
request = ftp_request ("SIZE", file);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1.0);
|
||||
nwritten = fd_write (csock, request, strlen (request), -1);
|
||||
if (nwritten < 0)
|
||||
{
|
||||
xfree (request);
|
||||
|
@ -32,16 +32,12 @@ so, delete this exception statement from your version. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "wget.h"
|
||||
#include "utils.h"
|
||||
|
@ -31,11 +31,7 @@ so, delete this exception statement from your version. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
#include "wget.h"
|
||||
#include "gen-md5.h"
|
||||
|
21
src/ftp.c
21
src/ftp.c
@ -32,15 +32,10 @@ so, delete this exception statement from your version. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
@ -55,10 +50,6 @@ so, delete this exception statement from your version. */
|
||||
#include "convert.h" /* for downloaded_file */
|
||||
#include "recur.h" /* for INFINITE_RECURSION */
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
extern LARGE_INT total_downloaded_bytes;
|
||||
|
||||
/* File where the "ls -al" listing will be saved. */
|
||||
@ -1355,12 +1346,10 @@ ftp_get_listing (struct url *u, ccon *con, struct fileinfo **f)
|
||||
return err;
|
||||
}
|
||||
|
||||
static uerr_t ftp_retrieve_dirs PARAMS ((struct url *, struct fileinfo *,
|
||||
ccon *));
|
||||
static uerr_t ftp_retrieve_glob PARAMS ((struct url *, ccon *, int));
|
||||
static struct fileinfo *delelement PARAMS ((struct fileinfo *,
|
||||
struct fileinfo **));
|
||||
static void freefileinfo PARAMS ((struct fileinfo *f));
|
||||
static uerr_t ftp_retrieve_dirs (struct url *, struct fileinfo *, ccon *);
|
||||
static uerr_t ftp_retrieve_glob (struct url *, ccon *, int);
|
||||
static struct fileinfo *delelement (struct fileinfo *, struct fileinfo **);
|
||||
static void freefileinfo (struct fileinfo *f);
|
||||
|
||||
/* Retrieve a list of files given in struct fileinfo linked list. If
|
||||
a file is a symbolic link, do not retrieve it, but rather try to
|
||||
|
42
src/ftp.h
42
src/ftp.h
@ -43,27 +43,27 @@ enum stype
|
||||
ST_OTHER
|
||||
};
|
||||
|
||||
uerr_t ftp_response PARAMS ((int, char **));
|
||||
uerr_t ftp_login PARAMS ((int, const char *, const char *));
|
||||
uerr_t ftp_port PARAMS ((int, int *));
|
||||
uerr_t ftp_pasv PARAMS ((int, ip_address *, int *));
|
||||
uerr_t ftp_response (int, char **);
|
||||
uerr_t ftp_login (int, const char *, const char *);
|
||||
uerr_t ftp_port (int, int *);
|
||||
uerr_t ftp_pasv (int, ip_address *, int *);
|
||||
#ifdef ENABLE_IPV6
|
||||
uerr_t ftp_lprt PARAMS ((int, int *));
|
||||
uerr_t ftp_lpsv PARAMS ((int, ip_address *, int *));
|
||||
uerr_t ftp_eprt PARAMS ((int, int *));
|
||||
uerr_t ftp_epsv PARAMS ((int, ip_address *, int *));
|
||||
uerr_t ftp_lprt (int, int *);
|
||||
uerr_t ftp_lpsv (int, ip_address *, int *);
|
||||
uerr_t ftp_eprt (int, int *);
|
||||
uerr_t ftp_epsv (int, ip_address *, int *);
|
||||
#endif
|
||||
uerr_t ftp_type PARAMS ((int, int));
|
||||
uerr_t ftp_cwd PARAMS ((int, const char *));
|
||||
uerr_t ftp_retr PARAMS ((int, const char *));
|
||||
uerr_t ftp_rest PARAMS ((int, wgint));
|
||||
uerr_t ftp_list PARAMS ((int, const char *));
|
||||
uerr_t ftp_syst PARAMS ((int, enum stype *));
|
||||
uerr_t ftp_pwd PARAMS ((int, char **));
|
||||
uerr_t ftp_size PARAMS ((int, const char *, wgint *));
|
||||
uerr_t ftp_type (int, int);
|
||||
uerr_t ftp_cwd (int, const char *);
|
||||
uerr_t ftp_retr (int, const char *);
|
||||
uerr_t ftp_rest (int, wgint);
|
||||
uerr_t ftp_list (int, const char *);
|
||||
uerr_t ftp_syst (int, enum stype *);
|
||||
uerr_t ftp_pwd (int, char **);
|
||||
uerr_t ftp_size (int, const char *, wgint *);
|
||||
|
||||
#ifdef ENABLE_OPIE
|
||||
const char *skey_response PARAMS ((int, const char *, const char *));
|
||||
const char *skey_response (int, const char *, const char *);
|
||||
#endif
|
||||
|
||||
struct url;
|
||||
@ -116,12 +116,12 @@ enum wget_ftp_fstatus
|
||||
correct. */
|
||||
};
|
||||
|
||||
struct fileinfo *ftp_parse_ls PARAMS ((const char *, const enum stype));
|
||||
uerr_t ftp_loop PARAMS ((struct url *, int *, struct url *));
|
||||
struct fileinfo *ftp_parse_ls (const char *, const enum stype);
|
||||
uerr_t ftp_loop (struct url *, int *, struct url *);
|
||||
|
||||
uerr_t ftp_index PARAMS ((const char *, struct url *, struct fileinfo *));
|
||||
uerr_t ftp_index (const char *, struct url *, struct fileinfo *);
|
||||
|
||||
char ftp_process_type PARAMS ((const char *));
|
||||
char ftp_process_type (const char *);
|
||||
|
||||
|
||||
#endif /* FTP_H */
|
||||
|
@ -42,9 +42,9 @@ struct gen_md5_context;
|
||||
gen_md5_context *var_name = \
|
||||
(gen_md5_context *) alloca (gen_md5_context_size ())
|
||||
|
||||
int gen_md5_context_size PARAMS ((void));
|
||||
void gen_md5_init PARAMS ((gen_md5_context *));
|
||||
void gen_md5_update PARAMS ((const unsigned char *, int, gen_md5_context *));
|
||||
void gen_md5_finish PARAMS ((gen_md5_context *, unsigned char *));
|
||||
int gen_md5_context_size (void);
|
||||
void gen_md5_init (gen_md5_context *);
|
||||
void gen_md5_update (const unsigned char *, int, gen_md5_context *);
|
||||
void gen_md5_finish (gen_md5_context *, unsigned char *);
|
||||
|
||||
#endif /* GEN_MD5_H */
|
||||
|
@ -196,11 +196,7 @@ static char *posixly_correct;
|
||||
# define my_index strchr
|
||||
#else
|
||||
|
||||
# if HAVE_STRING_H
|
||||
# include <string.h>
|
||||
# else
|
||||
# include <strings.h>
|
||||
# endif
|
||||
#include <string.h>
|
||||
|
||||
/* Avoid depending on library functions or files
|
||||
whose names are inconsistent. */
|
||||
|
@ -24,19 +24,9 @@
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
/* Wget */
|
||||
/*#if STDC_HEADERS || defined _LIBC*/
|
||||
# include <stdlib.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
/*#else*/
|
||||
/*# ifndef HAVE_MEMCPY*/
|
||||
/*# define memcpy(d, s, n) bcopy ((s), (d), (n))*/
|
||||
/*# endif*/
|
||||
/*#endif*/
|
||||
/* modified for Wget: depend on C89 */
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "wget.h"
|
||||
#include "gnu-md5.h"
|
||||
|
@ -88,21 +88,21 @@ struct md5_ctx
|
||||
|
||||
/* Initialize structure containing state of computation.
|
||||
(RFC 1321, 3.3: Step 3) */
|
||||
extern void md5_init_ctx PARAMS ((struct md5_ctx *ctx));
|
||||
extern void md5_init_ctx (struct md5_ctx *ctx);
|
||||
|
||||
/* Starting with the result of former calls of this function (or the
|
||||
initialization function update the context for the next LEN bytes
|
||||
starting at BUFFER.
|
||||
It is necessary that LEN is a multiple of 64!!! */
|
||||
extern void md5_process_block PARAMS ((const void *buffer, size_t len,
|
||||
struct md5_ctx *ctx));
|
||||
extern void md5_process_block (const void *buffer, size_t len,
|
||||
struct md5_ctx *ctx);
|
||||
|
||||
/* Starting with the result of former calls of this function (or the
|
||||
initialization function update the context for the next LEN bytes
|
||||
starting at BUFFER.
|
||||
It is NOT required that LEN is a multiple of 64. */
|
||||
extern void md5_process_bytes PARAMS ((const void *buffer, size_t len,
|
||||
struct md5_ctx *ctx));
|
||||
extern void md5_process_bytes (const void *buffer, size_t len,
|
||||
struct md5_ctx *ctx);
|
||||
|
||||
/* Process the remaining bytes in the buffer and put result from CTX
|
||||
in first 16 bytes following RESBUF. The result is always in little
|
||||
@ -111,7 +111,7 @@ extern void md5_process_bytes PARAMS ((const void *buffer, size_t len,
|
||||
|
||||
IMPORTANT: On some systems it is required that RESBUF is correctly
|
||||
aligned for a 32 bits value. */
|
||||
extern void *md5_finish_ctx PARAMS ((struct md5_ctx *ctx, void *resbuf));
|
||||
extern void *md5_finish_ctx (struct md5_ctx *ctx, void *resbuf);
|
||||
|
||||
|
||||
/* Put result from CTX in first 16 bytes following RESBUF. The result is
|
||||
@ -120,21 +120,20 @@ extern void *md5_finish_ctx PARAMS ((struct md5_ctx *ctx, void *resbuf));
|
||||
|
||||
IMPORTANT: On some systems it is required that RESBUF is correctly
|
||||
aligned for a 32 bits value. */
|
||||
extern void *md5_read_ctx PARAMS ((const struct md5_ctx *ctx, void *resbuf));
|
||||
extern void *md5_read_ctx (const struct md5_ctx *ctx, void *resbuf);
|
||||
|
||||
|
||||
#if 0 /* Unused in Wget */
|
||||
/* Compute MD5 message digest for bytes read from STREAM. The
|
||||
resulting message digest number will be written into the 16 bytes
|
||||
beginning at RESBLOCK. */
|
||||
extern int md5_stream PARAMS ((FILE *stream, void *resblock));
|
||||
extern int md5_stream (FILE *stream, void *resblock);
|
||||
#endif
|
||||
|
||||
/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
|
||||
result is always in little endian byte order, so that a byte-wise
|
||||
output yields to the wanted ASCII representation of the message
|
||||
digest. */
|
||||
extern void *md5_buffer PARAMS ((const char *buffer, size_t len,
|
||||
void *resblock));
|
||||
extern void *md5_buffer (const char *buffer, size_t len, void *resblock);
|
||||
|
||||
#endif
|
||||
|
24
src/hash.c
24
src/hash.c
@ -32,24 +32,13 @@ so, delete this exception statement from your version. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
# ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
# else
|
||||
# include <strings.h>
|
||||
# endif
|
||||
# ifdef HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
# endif
|
||||
#else
|
||||
/* If running without Autoconf, go ahead and assume presence of
|
||||
standard C89 headers. */
|
||||
# include <string.h>
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifndef STANDALONE
|
||||
/* Get Wget's utility headers. */
|
||||
@ -64,7 +53,6 @@ so, delete this exception statement from your version. */
|
||||
# define xfree free
|
||||
# define countof(x) (sizeof (x) / sizeof ((x)[0]))
|
||||
# define TOLOWER(x) ('A' <= (x) && (x) <= 'Z' ? (x) - 32 : (x))
|
||||
# define PARAMS(x) x
|
||||
#endif
|
||||
|
||||
#include "hash.h"
|
||||
@ -152,8 +140,8 @@ struct mapping {
|
||||
void *value;
|
||||
};
|
||||
|
||||
typedef unsigned long (*hashfun_t) PARAMS ((const void *));
|
||||
typedef int (*testfun_t) PARAMS ((const void *, const void *));
|
||||
typedef unsigned long (*hashfun_t) (const void *);
|
||||
typedef int (*testfun_t) (const void *, const void *);
|
||||
|
||||
struct hash_table {
|
||||
hashfun_t hash_function;
|
||||
@ -180,7 +168,7 @@ struct hash_table {
|
||||
-1. This is acceptable because it still allows the use of
|
||||
nonnegative integer keys. */
|
||||
|
||||
#define INVALID_PTR ((void *) ~(unsigned long)0)
|
||||
#define INVALID_PTR ((void *) ~0UL)
|
||||
#ifndef UCHAR_MAX
|
||||
# define UCHAR_MAX 0xff
|
||||
#endif
|
||||
@ -242,7 +230,7 @@ prime_size (int size, int *prime_offset)
|
||||
abort ();
|
||||
}
|
||||
|
||||
static int cmp_pointer PARAMS ((const void *, const void *));
|
||||
static int cmp_pointer (const void *, const void *);
|
||||
|
||||
/* Create a hash table with hash function HASH_FUNCTION and test
|
||||
function TEST_FUNCTION. The table is empty (its count is 0), but
|
||||
|
47
src/hash.h
47
src/hash.h
@ -32,41 +32,26 @@ so, delete this exception statement from your version. */
|
||||
|
||||
struct hash_table;
|
||||
|
||||
struct hash_table *hash_table_new PARAMS ((int,
|
||||
unsigned long (*) (const void *),
|
||||
int (*) (const void *,
|
||||
const void *)));
|
||||
void hash_table_destroy PARAMS ((struct hash_table *));
|
||||
struct hash_table *hash_table_new (int, unsigned long (*) (const void *),
|
||||
int (*) (const void *, const void *));
|
||||
void hash_table_destroy (struct hash_table *);
|
||||
|
||||
void *hash_table_get PARAMS ((const struct hash_table *, const void *));
|
||||
int hash_table_get_pair PARAMS ((const struct hash_table *, const void *,
|
||||
void *, void *));
|
||||
int hash_table_contains PARAMS ((const struct hash_table *, const void *));
|
||||
void *hash_table_get (const struct hash_table *, const void *);
|
||||
int hash_table_get_pair (const struct hash_table *, const void *,
|
||||
void *, void *);
|
||||
int hash_table_contains (const struct hash_table *, const void *);
|
||||
|
||||
void hash_table_put PARAMS ((struct hash_table *, const void *, void *));
|
||||
int hash_table_remove PARAMS ((struct hash_table *, const void *));
|
||||
void hash_table_clear PARAMS ((struct hash_table *));
|
||||
void hash_table_put (struct hash_table *, const void *, void *);
|
||||
int hash_table_remove (struct hash_table *, const void *);
|
||||
void hash_table_clear (struct hash_table *);
|
||||
|
||||
void hash_table_map PARAMS ((struct hash_table *,
|
||||
int (*) (void *, void *, void *),
|
||||
void *));
|
||||
int hash_table_count PARAMS ((const struct hash_table *));
|
||||
void hash_table_map (struct hash_table *,
|
||||
int (*) (void *, void *, void *), void *);
|
||||
int hash_table_count (const struct hash_table *);
|
||||
|
||||
struct hash_table *make_string_hash_table PARAMS ((int));
|
||||
struct hash_table *make_nocase_string_hash_table PARAMS ((int));
|
||||
struct hash_table *make_string_hash_table (int);
|
||||
struct hash_table *make_nocase_string_hash_table (int);
|
||||
|
||||
unsigned long hash_pointer PARAMS ((const void *));
|
||||
|
||||
/* From XEmacs, and hence from Dragon book. */
|
||||
|
||||
#define GOOD_HASH 65599 /* prime number just over 2^16; Dragon book, p. 435 */
|
||||
#define HASH2(a,b) (GOOD_HASH * (a) + (b))
|
||||
#define HASH3(a,b,c) (GOOD_HASH * HASH2 (a,b) + (c))
|
||||
#define HASH4(a,b,c,d) (GOOD_HASH * HASH3 (a,b,c) + (d))
|
||||
#define HASH5(a,b,c,d,e) (GOOD_HASH * HASH4 (a,b,c,d) + (e))
|
||||
#define HASH6(a,b,c,d,e,f) (GOOD_HASH * HASH5 (a,b,c,d,e) + (f))
|
||||
#define HASH7(a,b,c,d,e,f,g) (GOOD_HASH * HASH6 (a,b,c,d,e,f) + (g))
|
||||
#define HASH8(a,b,c,d,e,f,g,h) (GOOD_HASH * HASH7 (a,b,c,d,e,f,g) + (h))
|
||||
#define HASH9(a,b,c,d,e,f,g,h,i) (GOOD_HASH * HASH8 (a,b,c,d,e,f,g,h) + (i))
|
||||
unsigned long hash_pointer (const void *);
|
||||
|
||||
#endif /* HASH_H */
|
||||
|
17
src/host.c
17
src/host.c
@ -35,13 +35,8 @@ so, delete this exception statement from your version. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef WINDOWS
|
||||
# include <sys/socket.h>
|
||||
@ -64,16 +59,6 @@ so, delete this exception statement from your version. */
|
||||
#include "hash.h"
|
||||
#include "connect.h" /* for socket_has_inet6 */
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#ifndef h_errno
|
||||
# ifndef __CYGWIN__
|
||||
extern int h_errno;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef NO_ADDRESS
|
||||
# define NO_ADDRESS NO_DATA
|
||||
#endif
|
||||
|
28
src/host.h
28
src/host.h
@ -95,26 +95,24 @@ enum {
|
||||
LH_BIND = 2,
|
||||
LH_REFRESH = 4
|
||||
};
|
||||
struct address_list *lookup_host PARAMS ((const char *, int));
|
||||
struct address_list *lookup_host (const char *, int);
|
||||
|
||||
void address_list_get_bounds PARAMS ((const struct address_list *,
|
||||
int *, int *));
|
||||
const ip_address *address_list_address_at PARAMS ((const struct address_list *,
|
||||
int));
|
||||
int address_list_contains PARAMS ((const struct address_list *, const ip_address *));
|
||||
void address_list_set_faulty PARAMS ((struct address_list *, int));
|
||||
void address_list_set_connected PARAMS ((struct address_list *));
|
||||
int address_list_connected_p PARAMS ((const struct address_list *));
|
||||
void address_list_release PARAMS ((struct address_list *));
|
||||
void address_list_get_bounds (const struct address_list *, int *, int *);
|
||||
const ip_address *address_list_address_at (const struct address_list *, int);
|
||||
int address_list_contains (const struct address_list *, const ip_address *);
|
||||
void address_list_set_faulty (struct address_list *, int);
|
||||
void address_list_set_connected (struct address_list *);
|
||||
int address_list_connected_p (const struct address_list *);
|
||||
void address_list_release (struct address_list *);
|
||||
|
||||
const char *pretty_print_address PARAMS ((const ip_address *));
|
||||
const char *pretty_print_address (const ip_address *);
|
||||
#ifdef ENABLE_IPV6
|
||||
int is_valid_ipv6_address PARAMS ((const char *, const char *));
|
||||
int is_valid_ipv6_address (const char *, const char *);
|
||||
#endif
|
||||
|
||||
int accept_domain PARAMS ((struct url *));
|
||||
int sufmatch PARAMS ((const char **, const char *));
|
||||
int accept_domain (struct url *);
|
||||
int sufmatch (const char **, const char *);
|
||||
|
||||
void host_cleanup PARAMS ((void));
|
||||
void host_cleanup (void);
|
||||
|
||||
#endif /* HOST_H */
|
||||
|
@ -96,11 +96,7 @@ so, delete this exception statement from your version. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "wget.h"
|
||||
@ -1014,8 +1010,7 @@ map_html_tags (const char *text, int size,
|
||||
taginfo.attrs = pairs;
|
||||
taginfo.start_position = tag_start_position;
|
||||
taginfo.end_position = p + 1;
|
||||
/* Ta-dam! */
|
||||
(*mapfun) (&taginfo, maparg);
|
||||
mapfun (&taginfo, maparg);
|
||||
ADVANCE (p);
|
||||
}
|
||||
goto look_for_tag;
|
||||
|
@ -60,9 +60,8 @@ struct hash_table; /* forward declaration */
|
||||
#define MHT_TRIM_VALUES 2 /* trim attribute values, e.g. interpret
|
||||
<a href=" foo "> as "foo" */
|
||||
|
||||
void map_html_tags PARAMS ((const char *, int,
|
||||
void (*) (struct taginfo *, void *), void *, int,
|
||||
const struct hash_table *,
|
||||
const struct hash_table *));
|
||||
void map_html_tags (const char *, int,
|
||||
void (*) (struct taginfo *, void *), void *, int,
|
||||
const struct hash_table *, const struct hash_table *);
|
||||
|
||||
#endif /* HTML_PARSE_H */
|
||||
|
@ -30,11 +30,7 @@ so, delete this exception statement from your version. */
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
@ -47,17 +43,12 @@ so, delete this exception statement from your version. */
|
||||
#include "convert.h"
|
||||
#include "recur.h" /* declaration of get_urls_html */
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
struct map_context;
|
||||
|
||||
typedef void (*tag_handler_t) PARAMS ((int, struct taginfo *,
|
||||
struct map_context *));
|
||||
typedef void (*tag_handler_t) (int, struct taginfo *, struct map_context *);
|
||||
|
||||
#define DECLARE_TAG_HANDLER(fun) \
|
||||
static void fun PARAMS ((int, struct taginfo *, struct map_context *))
|
||||
#define DECLARE_TAG_HANDLER(fun) \
|
||||
static void fun (int, struct taginfo *, struct map_context *)
|
||||
|
||||
DECLARE_TAG_HANDLER (tag_find_urls);
|
||||
DECLARE_TAG_HANDLER (tag_handle_base);
|
||||
|
195
src/http-ntlm.c
195
src/http-ntlm.c
@ -39,11 +39,7 @@ so, delete this exception statement from your version. */
|
||||
|
||||
/* -- WIN32 approved -- */
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <openssl/des.h>
|
||||
@ -348,41 +344,38 @@ ntlm_output (struct ntlmdata *ntlm, const char *user, const char *passwd,
|
||||
24 Supplied Workstation security buffer(*)
|
||||
32 start of data block
|
||||
|
||||
Format string (merged for pre-ANSI compilers):
|
||||
"NTLMSSP%c"
|
||||
"\x01%c%c%c" 32-bit type = 1
|
||||
"%c%c%c%c" 32-bit NTLM flag field
|
||||
"%c%c" domain length
|
||||
"%c%c" domain allocated space
|
||||
"%c%c" domain name offset
|
||||
"%c%c" 2 zeroes
|
||||
"%c%c" host length
|
||||
"%c%c" host allocated space
|
||||
"%c%c" host name offset
|
||||
"%c%c" 2 zeroes
|
||||
"%s" host name
|
||||
"%s" domain string
|
||||
*/
|
||||
|
||||
snprintf(ntlmbuf, sizeof(ntlmbuf),
|
||||
"NTLMSSP%c\001%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%s%s",
|
||||
0, /* trailing zero */
|
||||
0,0,0, /* part of type-1 long */
|
||||
snprintf (ntlmbuf, sizeof(ntlmbuf), "NTLMSSP%c"
|
||||
"\x01%c%c%c" /* 32-bit type = 1 */
|
||||
"%c%c%c%c" /* 32-bit NTLM flag field */
|
||||
"%c%c" /* domain length */
|
||||
"%c%c" /* domain allocated space */
|
||||
"%c%c" /* domain name offset */
|
||||
"%c%c" /* 2 zeroes */
|
||||
"%c%c" /* host length */
|
||||
"%c%c" /* host allocated space */
|
||||
"%c%c" /* host name offset */
|
||||
"%c%c" /* 2 zeroes */
|
||||
"%s" /* host name */
|
||||
"%s", /* domain string */
|
||||
0, /* trailing zero */
|
||||
0,0,0, /* part of type-1 long */
|
||||
|
||||
LONGQUARTET(
|
||||
NTLMFLAG_NEGOTIATE_OEM| /* 2 */
|
||||
NTLMFLAG_NEGOTIATE_NTLM_KEY /* 200 */
|
||||
/* equals 0x0202 */
|
||||
),
|
||||
SHORTPAIR(domlen),
|
||||
SHORTPAIR(domlen),
|
||||
SHORTPAIR(domoff),
|
||||
0,0,
|
||||
SHORTPAIR(hostlen),
|
||||
SHORTPAIR(hostlen),
|
||||
SHORTPAIR(hostoff),
|
||||
0,0,
|
||||
host, domain);
|
||||
LONGQUARTET(
|
||||
NTLMFLAG_NEGOTIATE_OEM| /* 2 */
|
||||
NTLMFLAG_NEGOTIATE_NTLM_KEY /* 200 */
|
||||
/* equals 0x0202 */
|
||||
),
|
||||
SHORTPAIR(domlen),
|
||||
SHORTPAIR(domlen),
|
||||
SHORTPAIR(domoff),
|
||||
0,0,
|
||||
SHORTPAIR(hostlen),
|
||||
SHORTPAIR(hostlen),
|
||||
SHORTPAIR(hostoff),
|
||||
0,0,
|
||||
host, domain);
|
||||
|
||||
/* initial packet length */
|
||||
size = 32 + hostlen + domlen;
|
||||
@ -449,78 +442,84 @@ ntlm_output (struct ntlmdata *ntlm, const char *user, const char *passwd,
|
||||
lmrespoff = hostoff + hostlen;
|
||||
ntrespoff = lmrespoff + 0x18;
|
||||
|
||||
/* Create the big type-3 message binary blob:
|
||||
"NTLMSSP%c"
|
||||
"\x03%c%c%c" type-3, 32 bits
|
||||
/* Create the big type-3 message binary blob */
|
||||
|
||||
"%c%c%c%c" LanManager length + allocated space
|
||||
"%c%c" LanManager offset
|
||||
"%c%c" 2 zeroes
|
||||
size = snprintf (ntlmbuf, sizeof(ntlmbuf),
|
||||
"NTLMSSP%c"
|
||||
"\x03%c%c%c" /* type-3, 32 bits */
|
||||
|
||||
"%c%c" NT-response length
|
||||
"%c%c" NT-response allocated space
|
||||
"%c%c" NT-response offset
|
||||
"%c%c" 2 zeroes
|
||||
"%c%c%c%c" /* LanManager length + allocated space */
|
||||
"%c%c" /* LanManager offset */
|
||||
"%c%c" /* 2 zeroes */
|
||||
|
||||
"%c%c" domain length
|
||||
"%c%c" domain allocated space
|
||||
"%c%c" domain name offset
|
||||
"%c%c" 2 zeroes
|
||||
"%c%c" /* NT-response length */
|
||||
"%c%c" /* NT-response allocated space */
|
||||
"%c%c" /* NT-response offset */
|
||||
"%c%c" /* 2 zeroes */
|
||||
|
||||
"%c%c" user length
|
||||
"%c%c" user allocated space
|
||||
"%c%c" user offset
|
||||
"%c%c" 2 zeroes
|
||||
|
||||
"%c%c" host length
|
||||
"%c%c" host allocated space
|
||||
"%c%c" host offset
|
||||
"%c%c%c%c%c%c" 6 zeroes
|
||||
|
||||
"\xff\xff" message length
|
||||
"%c%c" 2 zeroes
|
||||
|
||||
"\x01\x82" flags
|
||||
"%c%c" 2 zeroes */
|
||||
|
||||
size = snprintf(ntlmbuf, sizeof(ntlmbuf),
|
||||
"NTLMSSP%c\003%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\377\377%c%c\001\202%c%c",
|
||||
0, /* zero termination */
|
||||
0,0,0, /* type-3 long, the 24 upper bits */
|
||||
|
||||
SHORTPAIR(0x18), /* LanManager response length, twice */
|
||||
SHORTPAIR(0x18),
|
||||
SHORTPAIR(lmrespoff),
|
||||
0x0, 0x0,
|
||||
"%c%c" /* domain length */
|
||||
"%c%c" /* domain allocated space */
|
||||
"%c%c" /* domain name offset */
|
||||
"%c%c" /* 2 zeroes */
|
||||
|
||||
"%c%c" /* user length */
|
||||
"%c%c" /* user allocated space */
|
||||
"%c%c" /* user offset */
|
||||
"%c%c" /* 2 zeroes */
|
||||
|
||||
"%c%c" /* host length */
|
||||
"%c%c" /* host allocated space */
|
||||
"%c%c" /* host offset */
|
||||
"%c%c%c%c%c%c" /* 6 zeroes */
|
||||
|
||||
"\xff\xff" /* message length */
|
||||
"%c%c" /* 2 zeroes */
|
||||
|
||||
"\x01\x82" /* flags */
|
||||
"%c%c" /* 2 zeroes */
|
||||
|
||||
/* domain string */
|
||||
/* user string */
|
||||
/* host string */
|
||||
/* LanManager response */
|
||||
/* NT response */
|
||||
,
|
||||
0, /* zero termination */
|
||||
0,0,0, /* type-3 long, the 24 upper bits */
|
||||
|
||||
SHORTPAIR(0x18), /* LanManager response length, twice */
|
||||
SHORTPAIR(0x18),
|
||||
SHORTPAIR(lmrespoff),
|
||||
0x0, 0x0,
|
||||
|
||||
#ifdef USE_NTRESPONSES
|
||||
SHORTPAIR(0x18), /* NT-response length, twice */
|
||||
SHORTPAIR(0x18),
|
||||
SHORTPAIR(0x18), /* NT-response length, twice */
|
||||
SHORTPAIR(0x18),
|
||||
#else
|
||||
0x0, 0x0,
|
||||
0x0, 0x0,
|
||||
0x0, 0x0,
|
||||
0x0, 0x0,
|
||||
#endif
|
||||
SHORTPAIR(ntrespoff),
|
||||
0x0, 0x0,
|
||||
SHORTPAIR(ntrespoff),
|
||||
0x0, 0x0,
|
||||
|
||||
SHORTPAIR(domlen),
|
||||
SHORTPAIR(domlen),
|
||||
SHORTPAIR(domoff),
|
||||
0x0, 0x0,
|
||||
SHORTPAIR(domlen),
|
||||
SHORTPAIR(domlen),
|
||||
SHORTPAIR(domoff),
|
||||
0x0, 0x0,
|
||||
|
||||
SHORTPAIR(userlen),
|
||||
SHORTPAIR(userlen),
|
||||
SHORTPAIR(useroff),
|
||||
0x0, 0x0,
|
||||
|
||||
SHORTPAIR(hostlen),
|
||||
SHORTPAIR(hostlen),
|
||||
SHORTPAIR(hostoff),
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
|
||||
0x0, 0x0,
|
||||
SHORTPAIR(userlen),
|
||||
SHORTPAIR(userlen),
|
||||
SHORTPAIR(useroff),
|
||||
0x0, 0x0,
|
||||
|
||||
0x0, 0x0);
|
||||
SHORTPAIR(hostlen),
|
||||
SHORTPAIR(hostlen),
|
||||
SHORTPAIR(hostoff),
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
|
||||
0x0, 0x0,
|
||||
|
||||
0x0, 0x0);
|
||||
|
||||
/* size is now 64 */
|
||||
size=64;
|
||||
|
@ -44,9 +44,8 @@ struct ntlmdata {
|
||||
};
|
||||
|
||||
/* this is for ntlm header input */
|
||||
int ntlm_input PARAMS ((struct ntlmdata *, const char *));
|
||||
int ntlm_input (struct ntlmdata *, const char *);
|
||||
|
||||
/* this is for creating ntlm header output */
|
||||
char *ntlm_output PARAMS ((struct ntlmdata *,
|
||||
const char *, const char *, int *));
|
||||
char *ntlm_output (struct ntlmdata *, const char *, const char *, int *);
|
||||
#endif
|
||||
|
41
src/http.c
41
src/http.c
@ -31,30 +31,13 @@ so, delete this exception statement from your version. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#if TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else
|
||||
# if HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# else
|
||||
# include <time.h>
|
||||
# endif
|
||||
#endif
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
#include <time.h>
|
||||
|
||||
#include "wget.h"
|
||||
#include "utils.h"
|
||||
@ -368,7 +351,7 @@ request_send (const struct request *req, int fd)
|
||||
|
||||
/* Send the request to the server. */
|
||||
|
||||
write_error = fd_write (fd, request_string, size - 1, -1.0);
|
||||
write_error = fd_write (fd, request_string, size - 1, -1);
|
||||
if (write_error < 0)
|
||||
logprintf (LOG_VERBOSE, _("Failed writing HTTP request: %s.\n"),
|
||||
strerror (errno));
|
||||
@ -412,7 +395,7 @@ post_file (int sock, const char *file_name, wgint promised_size)
|
||||
if (length == 0)
|
||||
break;
|
||||
towrite = MIN (promised_size - written, length);
|
||||
write_error = fd_write (sock, chunk, towrite, -1.0);
|
||||
write_error = fd_write (sock, chunk, towrite, -1);
|
||||
if (write_error < 0)
|
||||
{
|
||||
fclose (fp);
|
||||
@ -840,7 +823,7 @@ skip_short_body (int fd, wgint contlen)
|
||||
|
||||
while (contlen > 0)
|
||||
{
|
||||
int ret = fd_read (fd, dlbuf, MIN (contlen, SKIP_SIZE), -1.0);
|
||||
int ret = fd_read (fd, dlbuf, MIN (contlen, SKIP_SIZE), -1);
|
||||
if (ret <= 0)
|
||||
{
|
||||
/* Don't normally report the error since this is an
|
||||
@ -1100,13 +1083,13 @@ free_hstat (struct http_stat *hs)
|
||||
hs->error = NULL;
|
||||
}
|
||||
|
||||
static char *create_authorization_line PARAMS ((const char *, const char *,
|
||||
const char *, const char *,
|
||||
const char *, int *));
|
||||
static char *basic_authentication_encode PARAMS ((const char *, const char *));
|
||||
static int known_authentication_scheme_p PARAMS ((const char *, const char *));
|
||||
static char *create_authorization_line (const char *, const char *,
|
||||
const char *, const char *,
|
||||
const char *, int *);
|
||||
static char *basic_authentication_encode (const char *, const char *);
|
||||
static int known_authentication_scheme_p (const char *, const char *);
|
||||
|
||||
time_t http_atotm PARAMS ((const char *));
|
||||
time_t http_atotm (const char *);
|
||||
|
||||
#define BEGINS_WITH(line, string_constant) \
|
||||
(!strncasecmp (line, string_constant, sizeof (string_constant) - 1) \
|
||||
@ -1544,7 +1527,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy)
|
||||
if (opt.post_data)
|
||||
{
|
||||
DEBUGP (("[POST data: %s]\n", opt.post_data));
|
||||
write_error = fd_write (sock, opt.post_data, post_data_size, -1.0);
|
||||
write_error = fd_write (sock, opt.post_data, post_data_size, -1);
|
||||
}
|
||||
else if (opt.post_file_name && post_data_size != 0)
|
||||
write_error = post_file (sock, opt.post_file_name, post_data_size);
|
||||
|
36
src/init.c
36
src/init.c
@ -30,16 +30,11 @@ so, delete this exception statement from your version. */
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef HAVE_PWD_H
|
||||
@ -57,10 +52,6 @@ so, delete this exception statement from your version. */
|
||||
#include "convert.h" /* for convert_cleanup */
|
||||
#include "res.h" /* for res_cleanup */
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
/* We want tilde expansion enabled only when reading `.wgetrc' lines;
|
||||
otherwise, it will be performed by the shell. This variable will
|
||||
be set by the wgetrc-reading function. */
|
||||
@ -68,8 +59,7 @@ extern int errno;
|
||||
static int enable_tilde_expansion;
|
||||
|
||||
|
||||
#define CMD_DECLARE(func) static int func \
|
||||
PARAMS ((const char *, const char *, void *))
|
||||
#define CMD_DECLARE(func) static int func (const char *, const char *, void *)
|
||||
|
||||
CMD_DECLARE (cmd_boolean);
|
||||
CMD_DECLARE (cmd_bytes);
|
||||
@ -111,7 +101,7 @@ CMD_DECLARE (cmd_spec_useragent);
|
||||
static struct {
|
||||
const char *name;
|
||||
void *place;
|
||||
int (*action) PARAMS ((const char *, const char *, void *));
|
||||
int (*action) (const char *, const char *, void *);
|
||||
} commands[] = {
|
||||
{ "accept", &opt.accepts, cmd_vector },
|
||||
{ "addhostdir", &opt.add_hostdir, cmd_boolean },
|
||||
@ -412,9 +402,8 @@ enum parse_line {
|
||||
line_unknown_command
|
||||
};
|
||||
|
||||
static enum parse_line parse_line PARAMS ((const char *, char **,
|
||||
char **, int *));
|
||||
static int setval_internal PARAMS ((int, const char *, const char *));
|
||||
static enum parse_line parse_line (const char *, char **, char **, int *);
|
||||
static int setval_internal (int, const char *, const char *);
|
||||
|
||||
/* Initialize variables from a wgetrc file. Returns zero (failure) if
|
||||
there were errors in the file. */
|
||||
@ -613,7 +602,7 @@ setval_internal (int comind, const char *com, const char *val)
|
||||
{
|
||||
assert (0 <= comind && comind < countof (commands));
|
||||
DEBUGP (("Setting %s (%s) to %s\n", com, commands[comind].name, val));
|
||||
return ((*commands[comind].action) (com, val, commands[comind].place));
|
||||
return commands[comind].action (com, val, commands[comind].place);
|
||||
}
|
||||
|
||||
/* Run command COM with value VAL. If running the command produces an
|
||||
@ -671,10 +660,9 @@ struct decode_item {
|
||||
const char *name;
|
||||
int code;
|
||||
};
|
||||
static int decode_string PARAMS ((const char *, const struct decode_item *,
|
||||
int, int *));
|
||||
static int simple_atoi PARAMS ((const char *, const char *, int *));
|
||||
static int simple_atof PARAMS ((const char *, const char *, double *));
|
||||
static int decode_string (const char *, const struct decode_item *, int, int *);
|
||||
static int simple_atoi (const char *, const char *, int *);
|
||||
static int simple_atof (const char *, const char *, double *);
|
||||
|
||||
#define CMP1(p, c0) (TOLOWER((p)[0]) == (c0) && (p)[1] == '\0')
|
||||
|
||||
@ -1111,7 +1099,7 @@ cmd_cert_type (const char *com, const char *val, void *place)
|
||||
/* Specialized helper functions, used by `commands' to handle some
|
||||
options specially. */
|
||||
|
||||
static int check_user_specified_header PARAMS ((const char *));
|
||||
static int check_user_specified_header (const char *);
|
||||
|
||||
static int
|
||||
cmd_spec_dirstruct (const char *com, const char *val, void *place_ignored)
|
||||
@ -1463,8 +1451,8 @@ decode_string (const char *val, const struct decode_item *items, int itemcount,
|
||||
}
|
||||
|
||||
|
||||
void cleanup_html_url PARAMS ((void));
|
||||
void http_cleanup PARAMS ((void));
|
||||
void cleanup_html_url (void);
|
||||
void http_cleanup (void);
|
||||
|
||||
|
||||
/* Free the memory allocated by global variables. */
|
||||
|
10
src/init.h
10
src/init.h
@ -30,10 +30,10 @@ so, delete this exception statement from your version. */
|
||||
#ifndef INIT_H
|
||||
#define INIT_H
|
||||
|
||||
void initialize PARAMS ((void));
|
||||
void run_command PARAMS ((const char *));
|
||||
void setoptval PARAMS ((const char *, const char *, const char *));
|
||||
char *home_dir PARAMS ((void));
|
||||
void cleanup PARAMS ((void));
|
||||
void initialize (void);
|
||||
void run_command (const char *);
|
||||
void setoptval (const char *, const char *, const char *);
|
||||
char *home_dir (void);
|
||||
void cleanup (void);
|
||||
|
||||
#endif /* INIT_H */
|
||||
|
32
src/log.c
32
src/log.c
@ -30,17 +30,9 @@ so, delete this exception statement from your version. */
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef WGET_USE_STDARG
|
||||
# include <stdarg.h>
|
||||
#else
|
||||
# include <varargs.h>
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
@ -51,10 +43,6 @@ so, delete this exception statement from your version. */
|
||||
#include "utils.h"
|
||||
#include "log.h"
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
/* This file impplement support for "logging". Logging means printing
|
||||
output, plus several additional features:
|
||||
|
||||
@ -137,7 +125,7 @@ static int log_line_current = -1;
|
||||
than create new ones. */
|
||||
static int trailing_line;
|
||||
|
||||
static void check_redirect_output PARAMS ((void));
|
||||
static void check_redirect_output (void);
|
||||
|
||||
#define ROT_ADVANCE(num) do { \
|
||||
if (++num >= SAVED_LOG_LINES) \
|
||||
@ -466,16 +454,6 @@ log_set_save_context (int savep)
|
||||
return old;
|
||||
}
|
||||
|
||||
/* Handle difference in va_start between pre-ANSI and ANSI C. Note
|
||||
that we always use `...' in function definitions and let ansi2knr
|
||||
convert it for us. */
|
||||
|
||||
#ifdef WGET_USE_STDARG
|
||||
# define VA_START(args, arg1) va_start (args, arg1)
|
||||
#else
|
||||
# define VA_START(args, ignored) va_start (args)
|
||||
#endif
|
||||
|
||||
/* Print a message to the screen or to the log. The first argument
|
||||
defines the verbosity of the message, and the rest are as in
|
||||
printf(3). */
|
||||
@ -495,7 +473,7 @@ logprintf (enum log_options o, const char *fmt, ...)
|
||||
xzero (lpstate);
|
||||
do
|
||||
{
|
||||
VA_START (args, fmt);
|
||||
va_start (args, fmt);
|
||||
done = log_vprintf_internal (&lpstate, fmt, args);
|
||||
va_end (args);
|
||||
}
|
||||
@ -521,7 +499,7 @@ debug_logprintf (const char *fmt, ...)
|
||||
xzero (lpstate);
|
||||
do
|
||||
{
|
||||
VA_START (args, fmt);
|
||||
va_start (args, fmt);
|
||||
done = log_vprintf_internal (&lpstate, fmt, args);
|
||||
va_end (args);
|
||||
}
|
||||
|
29
src/log.h
29
src/log.h
@ -35,25 +35,20 @@ so, delete this exception statement from your version. */
|
||||
|
||||
enum log_options { LOG_VERBOSE, LOG_NOTQUIET, LOG_NONVERBOSE, LOG_ALWAYS };
|
||||
|
||||
#ifdef HAVE_STDARG_H
|
||||
void logprintf PARAMS ((enum log_options, const char *, ...))
|
||||
void logprintf (enum log_options, const char *, ...)
|
||||
GCC_FORMAT_ATTR (2, 3);
|
||||
void debug_logprintf PARAMS ((const char *, ...)) GCC_FORMAT_ATTR (1, 2);
|
||||
#else /* not HAVE_STDARG_H */
|
||||
void logprintf ();
|
||||
void debug_logprintf ();
|
||||
#endif /* not HAVE_STDARG_H */
|
||||
void logputs PARAMS ((enum log_options, const char *));
|
||||
void logflush PARAMS ((void));
|
||||
void log_set_flush PARAMS ((int));
|
||||
int log_set_save_context PARAMS ((int));
|
||||
void debug_logprintf (const char *, ...) GCC_FORMAT_ATTR (1, 2);
|
||||
void logputs (enum log_options, const char *);
|
||||
void logflush (void);
|
||||
void log_set_flush (int);
|
||||
int log_set_save_context (int);
|
||||
|
||||
void log_init PARAMS ((const char *, int));
|
||||
void log_close PARAMS ((void));
|
||||
void log_cleanup PARAMS ((void));
|
||||
void log_request_redirect_output PARAMS ((const char *));
|
||||
void log_init (const char *, int);
|
||||
void log_close (void);
|
||||
void log_cleanup (void);
|
||||
void log_request_redirect_output (const char *);
|
||||
|
||||
const char *escnonprint PARAMS ((const char *));
|
||||
const char *escnonprint_uri PARAMS ((const char *));
|
||||
const char *escnonprint (const char *);
|
||||
const char *escnonprint_uri (const char *);
|
||||
|
||||
#endif /* LOG_H */
|
||||
|
19
src/main.c
19
src/main.c
@ -34,12 +34,7 @@ so, delete this exception statement from your version. */
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif /* HAVE_STRING_H */
|
||||
#include <string.h>
|
||||
#ifdef HAVE_SIGNAL_H
|
||||
# include <signal.h>
|
||||
#endif
|
||||
@ -49,11 +44,7 @@ so, delete this exception statement from your version. */
|
||||
#endif /* HAVE_LOCALE_H */
|
||||
#endif /* HAVE_NLS */
|
||||
#include <assert.h>
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#include "wget.h"
|
||||
#include "utils.h"
|
||||
@ -79,7 +70,7 @@ extern char *version_string;
|
||||
|
||||
extern struct cookie_jar *wget_cookie_jar;
|
||||
|
||||
static RETSIGTYPE redirect_output_signal PARAMS ((int));
|
||||
static RETSIGTYPE redirect_output_signal (int);
|
||||
|
||||
const char *exec_name;
|
||||
|
||||
@ -115,8 +106,8 @@ i18n_initialize (void)
|
||||
|
||||
/* Definition of command-line options. */
|
||||
|
||||
static void print_help PARAMS ((void));
|
||||
static void print_version PARAMS ((void));
|
||||
static void print_help (void);
|
||||
static void print_version (void);
|
||||
|
||||
#ifdef HAVE_SSL
|
||||
# define IF_SSL(x) x
|
||||
@ -738,7 +729,7 @@ main (int argc, char *const *argv)
|
||||
break;
|
||||
case OPT_FUNCALL:
|
||||
{
|
||||
void (*func) PARAMS ((void)) = (void (*) PARAMS ((void))) opt->data;
|
||||
void (*func) (void) = (void (*) (void)) opt->data;
|
||||
func ();
|
||||
}
|
||||
break;
|
||||
|
@ -54,10 +54,6 @@ so, delete this exception statement from your version. */
|
||||
#include "utils.h"
|
||||
#include "url.h"
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#ifndef ES_SYSTEM_REQUIRED
|
||||
#define ES_SYSTEM_REQUIRED 0x00000001
|
||||
#endif
|
||||
@ -68,7 +64,7 @@ extern int errno;
|
||||
|
||||
|
||||
/* Defined in log.c. */
|
||||
void log_request_redirect_output PARAMS ((const char *));
|
||||
void log_request_redirect_output (const char *);
|
||||
|
||||
/* Windows version of xsleep in utils.c. */
|
||||
|
||||
|
13
src/netrc.c
13
src/netrc.c
@ -36,12 +36,7 @@ so, delete this exception statement from your version. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "wget.h"
|
||||
@ -49,15 +44,11 @@ so, delete this exception statement from your version. */
|
||||
#include "netrc.h"
|
||||
#include "init.h"
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#define NETRC_FILE_NAME ".netrc"
|
||||
|
||||
acc_t *netrc_list;
|
||||
|
||||
static acc_t *parse_netrc PARAMS ((const char *));
|
||||
static acc_t *parse_netrc (const char *);
|
||||
|
||||
/* Return the correct user and password, given the host, user (as
|
||||
given in the URL), and password (as given in the URL). May return
|
||||
|
@ -39,7 +39,7 @@ typedef struct _acc_t
|
||||
struct _acc_t *next;
|
||||
} acc_t;
|
||||
|
||||
void search_netrc PARAMS((const char *, const char **, const char **, int));
|
||||
void free_netrc PARAMS((acc_t *l));
|
||||
void search_netrc (const char *, const char **, const char **, int);
|
||||
void free_netrc (acc_t *l);
|
||||
|
||||
#endif /* NETRC_H */
|
||||
|
@ -35,11 +35,7 @@ so, delete this exception statement from your version. */
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/x509.h>
|
||||
@ -52,10 +48,6 @@ so, delete this exception statement from your version. */
|
||||
#include "url.h"
|
||||
#include "ssl.h"
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
/* Application-wide SSL context. This is common to all SSL
|
||||
connections. */
|
||||
SSL_CTX *ssl_ctx;
|
||||
|
@ -31,11 +31,7 @@ so, delete this exception statement from your version. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif /* HAVE_STRING_H */
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
@ -52,23 +48,23 @@ so, delete this exception statement from your version. */
|
||||
struct progress_implementation {
|
||||
const char *name;
|
||||
int interactive;
|
||||
void *(*create) PARAMS ((wgint, wgint));
|
||||
void (*update) PARAMS ((void *, wgint, double));
|
||||
void (*finish) PARAMS ((void *, double));
|
||||
void (*set_params) PARAMS ((const char *));
|
||||
void *(*create) (wgint, wgint);
|
||||
void (*update) (void *, wgint, double);
|
||||
void (*finish) (void *, double);
|
||||
void (*set_params) (const char *);
|
||||
};
|
||||
|
||||
/* Necessary forward declarations. */
|
||||
|
||||
static void *dot_create PARAMS ((wgint, wgint));
|
||||
static void dot_update PARAMS ((void *, wgint, double));
|
||||
static void dot_finish PARAMS ((void *, double));
|
||||
static void dot_set_params PARAMS ((const char *));
|
||||
static void *dot_create (wgint, wgint);
|
||||
static void dot_update (void *, wgint, double);
|
||||
static void dot_finish (void *, double);
|
||||
static void dot_set_params (const char *);
|
||||
|
||||
static void *bar_create PARAMS ((wgint, wgint));
|
||||
static void bar_update PARAMS ((void *, wgint, double));
|
||||
static void bar_finish PARAMS ((void *, double));
|
||||
static void bar_set_params PARAMS ((const char *));
|
||||
static void *bar_create (wgint, wgint);
|
||||
static void bar_update (void *, wgint, double);
|
||||
static void bar_finish (void *, double);
|
||||
static void bar_set_params (const char *);
|
||||
|
||||
static struct progress_implementation implementations[] = {
|
||||
{ "dot", 0, dot_create, dot_update, dot_finish, dot_set_params },
|
||||
@ -495,8 +491,8 @@ struct bar_progress {
|
||||
wgint last_eta_value;
|
||||
};
|
||||
|
||||
static void create_image PARAMS ((struct bar_progress *, double));
|
||||
static void display_image PARAMS ((char *));
|
||||
static void create_image (struct bar_progress *, double);
|
||||
static void display_image (char *);
|
||||
|
||||
static void *
|
||||
bar_create (wgint initial, wgint total)
|
||||
@ -530,13 +526,13 @@ bar_create (wgint initial, wgint total)
|
||||
|
||||
logputs (LOG_VERBOSE, "\n");
|
||||
|
||||
create_image (bp, 0.0);
|
||||
create_image (bp, 0);
|
||||
display_image (bp->buffer);
|
||||
|
||||
return bp;
|
||||
}
|
||||
|
||||
static void update_speed_ring PARAMS ((struct bar_progress *, wgint, double));
|
||||
static void update_speed_ring (struct bar_progress *, wgint, double);
|
||||
|
||||
static void
|
||||
bar_update (void *progress, wgint howmuch, double dltime)
|
||||
|
@ -30,15 +30,15 @@ so, delete this exception statement from your version. */
|
||||
#ifndef PROGRESS_H
|
||||
#define PROGRESS_H
|
||||
|
||||
int valid_progress_implementation_p PARAMS ((const char *));
|
||||
void set_progress_implementation PARAMS ((const char *));
|
||||
void progress_schedule_redirect PARAMS ((void));
|
||||
int valid_progress_implementation_p (const char *);
|
||||
void set_progress_implementation (const char *);
|
||||
void progress_schedule_redirect (void);
|
||||
|
||||
void *progress_create PARAMS ((wgint, wgint));
|
||||
int progress_interactive_p PARAMS ((void *));
|
||||
void progress_update PARAMS ((void *, wgint, double));
|
||||
void progress_finish PARAMS ((void *, double));
|
||||
void *progress_create (wgint, wgint);
|
||||
int progress_interactive_p (void *);
|
||||
void progress_update (void *, wgint, double);
|
||||
void progress_finish (void *, double);
|
||||
|
||||
RETSIGTYPE progress_handle_sigwinch PARAMS ((int));
|
||||
RETSIGTYPE progress_handle_sigwinch (int);
|
||||
|
||||
#endif /* PROGRESS_H */
|
||||
|
12
src/ptimer.c
12
src/ptimer.c
@ -54,17 +54,13 @@ so, delete this exception statement from your version. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else /* not HAVE_STRING_H */
|
||||
# include <strings.h>
|
||||
#endif /* not HAVE_STRING_H */
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <assert.h>
|
||||
#include <time.h>
|
||||
|
||||
/* Cygwin currently (as of 2005-04-08, Cygwin 1.5.14) lacks clock_getres,
|
||||
but still defines _POSIX_TIMERS! Because of that we simply use the
|
||||
@ -76,10 +72,6 @@ so, delete this exception statement from your version. */
|
||||
#include "wget.h"
|
||||
#include "ptimer.h"
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
/* Depending on the OS and availability of gettimeofday(), one and
|
||||
only one of PTIMER_POSIX, PTIMER_GETTIMEOFDAY, PTIMER_WINDOWS, or
|
||||
PTIMER_TIME will be defined. */
|
||||
|
12
src/ptimer.h
12
src/ptimer.h
@ -33,13 +33,13 @@ so, delete this exception statement from your version. */
|
||||
struct ptimer; /* forward declaration; all struct
|
||||
members are private */
|
||||
|
||||
struct ptimer *ptimer_new PARAMS ((void));
|
||||
void ptimer_destroy PARAMS ((struct ptimer *));
|
||||
struct ptimer *ptimer_new (void);
|
||||
void ptimer_destroy (struct ptimer *);
|
||||
|
||||
void ptimer_reset PARAMS ((struct ptimer *));
|
||||
double ptimer_measure PARAMS ((struct ptimer *));
|
||||
double ptimer_read PARAMS ((const struct ptimer *));
|
||||
void ptimer_reset (struct ptimer *);
|
||||
double ptimer_measure (struct ptimer *);
|
||||
double ptimer_read (const struct ptimer *);
|
||||
|
||||
double ptimer_resolution PARAMS ((void));
|
||||
double ptimer_resolution (void);
|
||||
|
||||
#endif /* PTIMER_H */
|
||||
|
19
src/recur.c
19
src/recur.c
@ -31,17 +31,12 @@ so, delete this exception statement from your version. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif /* HAVE_STRING_H */
|
||||
#include <string.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "wget.h"
|
||||
#include "url.h"
|
||||
@ -54,10 +49,6 @@ so, delete this exception statement from your version. */
|
||||
#include "res.h"
|
||||
#include "convert.h"
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
extern char *version_string;
|
||||
extern LARGE_INT total_downloaded_bytes;
|
||||
|
||||
@ -160,10 +151,10 @@ url_dequeue (struct url_queue *queue,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int download_child_p PARAMS ((const struct urlpos *, struct url *, int,
|
||||
struct url *, struct hash_table *));
|
||||
static int descend_redirect_p PARAMS ((const char *, const char *, int,
|
||||
struct url *, struct hash_table *));
|
||||
static int download_child_p (const struct urlpos *, struct url *, int,
|
||||
struct url *, struct hash_table *);
|
||||
static int descend_redirect_p (const char *, const char *, int,
|
||||
struct url *, struct hash_table *);
|
||||
|
||||
|
||||
/* Retrieve a part of the web beginning with START_URL. This used to
|
||||
|
10
src/recur.h
10
src/recur.h
@ -40,12 +40,12 @@ so, delete this exception statement from your version. */
|
||||
|
||||
struct urlpos;
|
||||
|
||||
void recursive_cleanup PARAMS ((void));
|
||||
uerr_t retrieve_tree PARAMS ((const char *));
|
||||
void recursive_cleanup (void);
|
||||
uerr_t retrieve_tree (const char *);
|
||||
|
||||
/* These are really in html-url.c. */
|
||||
struct urlpos *get_urls_file PARAMS ((const char *));
|
||||
struct urlpos *get_urls_html PARAMS ((const char *, const char *, int *));
|
||||
void free_urlpos PARAMS ((struct urlpos *));
|
||||
struct urlpos *get_urls_file (const char *);
|
||||
struct urlpos *get_urls_html (const char *, const char *, int *);
|
||||
void free_urlpos (struct urlpos *);
|
||||
|
||||
#endif /* RECUR_H */
|
||||
|
@ -73,11 +73,7 @@ so, delete this exception statement from your version. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif /* HAVE_STRING_H */
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
14
src/res.h
14
src/res.h
@ -32,16 +32,16 @@ so, delete this exception statement from your version. */
|
||||
|
||||
struct robot_specs;
|
||||
|
||||
struct robot_specs *res_parse PARAMS ((const char *, int));
|
||||
struct robot_specs *res_parse_from_file PARAMS ((const char *));
|
||||
struct robot_specs *res_parse (const char *, int);
|
||||
struct robot_specs *res_parse_from_file (const char *);
|
||||
|
||||
int res_match_path PARAMS ((const struct robot_specs *, const char *));
|
||||
int res_match_path (const struct robot_specs *, const char *);
|
||||
|
||||
void res_register_specs PARAMS ((const char *, int, struct robot_specs *));
|
||||
struct robot_specs *res_get_specs PARAMS ((const char *, int));
|
||||
void res_register_specs (const char *, int, struct robot_specs *);
|
||||
struct robot_specs *res_get_specs (const char *, int);
|
||||
|
||||
int res_retrieve_file PARAMS ((const char *, char **));
|
||||
int res_retrieve_file (const char *, char **);
|
||||
|
||||
void res_cleanup PARAMS ((void));
|
||||
void res_cleanup (void);
|
||||
|
||||
#endif /* RES_H */
|
||||
|
25
src/retr.c
25
src/retr.c
@ -31,16 +31,11 @@ so, delete this exception statement from your version. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
#include <errno.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif /* HAVE_STRING_H */
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "wget.h"
|
||||
@ -56,10 +51,6 @@ so, delete this exception statement from your version. */
|
||||
#include "convert.h"
|
||||
#include "ptimer.h"
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
/* Total size of downloaded files. Used to enforce quota. */
|
||||
LARGE_INT total_downloaded_bytes;
|
||||
|
||||
@ -306,7 +297,7 @@ fd_read_body (int fd, FILE *out, wgint toread, wgint startpos,
|
||||
if (!write_data (out, dlbuf, ret, &skip, &sum_written))
|
||||
{
|
||||
ret = -2;
|
||||
goto out_;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
@ -324,7 +315,7 @@ fd_read_body (int fd, FILE *out, wgint toread, wgint startpos,
|
||||
if (ret < -1)
|
||||
ret = -1;
|
||||
|
||||
out_:
|
||||
out:
|
||||
if (progress)
|
||||
progress_finish (progress, ptimer_read (timer));
|
||||
|
||||
@ -395,7 +386,7 @@ fd_read_hunk (int fd, hunk_terminator_t terminator, long sizehint, long maxsize)
|
||||
|
||||
/* First, peek at the available data. */
|
||||
|
||||
pklen = fd_peek (fd, hunk + tail, bufsize - 1 - tail, -1.0);
|
||||
pklen = fd_peek (fd, hunk + tail, bufsize - 1 - tail, -1);
|
||||
if (pklen < 0)
|
||||
{
|
||||
xfree (hunk);
|
||||
@ -428,7 +419,7 @@ fd_read_hunk (int fd, hunk_terminator_t terminator, long sizehint, long maxsize)
|
||||
how much data we'll get. (Some TCP stacks are notorious for
|
||||
read returning less data than the previous MSG_PEEK.) */
|
||||
|
||||
rdlen = fd_read (fd, hunk + tail, remain, 0.0);
|
||||
rdlen = fd_read (fd, hunk + tail, remain, 0);
|
||||
if (rdlen < 0)
|
||||
{
|
||||
xfree_null (hunk);
|
||||
@ -580,7 +571,7 @@ calc_rate (wgint bytes, double msecs, int *units)
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
static char *getproxy PARAMS ((struct url *));
|
||||
static char *getproxy (struct url *);
|
||||
|
||||
/* Retrieve the given URL. Decides which loop to call -- HTTP, FTP,
|
||||
FTP, proxy, etc. */
|
||||
@ -886,7 +877,7 @@ sleep_between_retrievals (int count)
|
||||
/* If opt.waitretry is specified and this is a retry, wait for
|
||||
COUNT-1 number of seconds, or for opt.waitretry seconds. */
|
||||
if (count <= opt.waitretry)
|
||||
xsleep (count - 1.0);
|
||||
xsleep (count - 1);
|
||||
else
|
||||
xsleep (opt.waitretry);
|
||||
}
|
||||
@ -950,7 +941,7 @@ rotate_backups(const char *fname)
|
||||
rename(fname, to);
|
||||
}
|
||||
|
||||
static int no_proxy_match PARAMS ((const char *, const char **));
|
||||
static int no_proxy_match (const char *, const char **);
|
||||
|
||||
/* Return the URL of the proxy appropriate for url U. */
|
||||
|
||||
|
30
src/retr.h
30
src/retr.h
@ -36,33 +36,31 @@ enum {
|
||||
rb_skip_startpos = 2
|
||||
};
|
||||
|
||||
int fd_read_body PARAMS ((int, FILE *, wgint, wgint, wgint *, wgint *, double *,
|
||||
int));
|
||||
int fd_read_body (int, FILE *, wgint, wgint, wgint *, wgint *, double *, int);
|
||||
|
||||
typedef const char *(*hunk_terminator_t) PARAMS ((const char *, int, int));
|
||||
typedef const char *(*hunk_terminator_t) (const char *, int, int);
|
||||
|
||||
char *fd_read_hunk PARAMS ((int, hunk_terminator_t, long, long));
|
||||
char *fd_read_line PARAMS ((int));
|
||||
char *fd_read_hunk (int, hunk_terminator_t, long, long);
|
||||
char *fd_read_line (int);
|
||||
|
||||
uerr_t retrieve_url PARAMS ((const char *, char **, char **,
|
||||
const char *, int *));
|
||||
uerr_t retrieve_from_file PARAMS ((const char *, int, int *));
|
||||
uerr_t retrieve_url (const char *, char **, char **, const char *, int *);
|
||||
uerr_t retrieve_from_file (const char *, int, int *);
|
||||
|
||||
char *retr_rate PARAMS ((wgint, double, int));
|
||||
double calc_rate PARAMS ((wgint, double, int *));
|
||||
void printwhat PARAMS ((int, int));
|
||||
char *retr_rate (wgint, double, int);
|
||||
double calc_rate (wgint, double, int *);
|
||||
void printwhat (int, int);
|
||||
|
||||
void sleep_between_retrievals PARAMS ((int));
|
||||
void sleep_between_retrievals (int);
|
||||
|
||||
void rotate_backups PARAMS ((const char *));
|
||||
void rotate_backups (const char *);
|
||||
|
||||
/* Because there's no http.h. */
|
||||
|
||||
struct url;
|
||||
|
||||
uerr_t http_loop PARAMS ((struct url *, char **, char **, const char *,
|
||||
int *, struct url *));
|
||||
void save_cookies PARAMS ((void));
|
||||
uerr_t http_loop (struct url *, char **, char **, const char *, int *,
|
||||
struct url *);
|
||||
void save_cookies (void);
|
||||
|
||||
|
||||
#endif /* RETR_H */
|
||||
|
@ -78,7 +78,6 @@
|
||||
* actually print args for %g and %e
|
||||
*
|
||||
* Hrvoje Niksic <hniksic@xemacs.org> 2005-04-15
|
||||
* use the PARAMS macro to handle prototypes.
|
||||
* write function definitions in the ansi2knr-friendly way.
|
||||
* if string precision is specified, don't read VALUE past it.
|
||||
* fix bug in fmtfp that caused 0.01 to be printed as 0.1.
|
||||
@ -105,31 +104,11 @@
|
||||
|
||||
#if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF)
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h> /* for NULL */
|
||||
|
||||
/* varargs declarations: */
|
||||
|
||||
#if defined(HAVE_STDARG_H)
|
||||
# include <stdarg.h>
|
||||
# define HAVE_STDARGS /* let's hope that works everywhere (mj) */
|
||||
# define VA_LOCAL_DECL va_list ap
|
||||
# define VA_START(f) va_start(ap, f)
|
||||
# define VA_SHIFT(v,t) ; /* no-op for ANSI */
|
||||
# define VA_END va_end(ap)
|
||||
#else
|
||||
# include <varargs.h>
|
||||
# undef HAVE_STDARGS
|
||||
# define VA_LOCAL_DECL va_list ap
|
||||
# define VA_START(f) va_start(ap) /* f is ignored! */
|
||||
# define VA_SHIFT(v,t) v = va_arg(ap,t)
|
||||
# define VA_END va_end(ap)
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef HAVE_LONG_DOUBLE
|
||||
#define LDOUBLE long double
|
||||
@ -150,28 +129,17 @@
|
||||
# define vsnprintf test_vsnprintf
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDARGS
|
||||
int snprintf (char *str, size_t count, const char *fmt, ...);
|
||||
int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
|
||||
#else
|
||||
int snprintf ();
|
||||
int vsnprintf ();
|
||||
#endif
|
||||
|
||||
#ifndef PARAMS
|
||||
# define PARAMS(x) x
|
||||
#endif
|
||||
|
||||
static int dopr PARAMS ((char *buffer, size_t maxlen, const char *format,
|
||||
va_list args));
|
||||
static int fmtstr PARAMS ((char *buffer, size_t *currlen, size_t maxlen,
|
||||
const char *value, int flags, int min, int max));
|
||||
static int fmtint PARAMS ((char *buffer, size_t *currlen, size_t maxlen,
|
||||
LLONG value, int base, int min, int max, int flags));
|
||||
static int fmtfp PARAMS ((char *buffer, size_t *currlen, size_t maxlen,
|
||||
LDOUBLE fvalue, int min, int max, int flags));
|
||||
static int dopr_outch PARAMS ((char *buffer, size_t *currlen, size_t maxlen,
|
||||
char c));
|
||||
static int dopr (char *buffer, size_t maxlen, const char *format, va_list args);
|
||||
static int fmtstr (char *buffer, size_t *currlen, size_t maxlen,
|
||||
const char *value, int flags, int min, int max);
|
||||
static int fmtint (char *buffer, size_t *currlen, size_t maxlen,
|
||||
LLONG value, int base, int min, int max, int flags);
|
||||
static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
|
||||
LDOUBLE fvalue, int min, int max, int flags);
|
||||
static int dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c);
|
||||
|
||||
/*
|
||||
* dopr(): poor man's version of doprintf
|
||||
@ -896,22 +864,14 @@ vsnprintf (char *str, size_t count, const char *fmt, va_list args)
|
||||
|
||||
#ifndef HAVE_SNPRINTF
|
||||
int
|
||||
snprintf (char *str, size_t count,const char *fmt,...)
|
||||
snprintf (char *str, size_t count, const char *fmt,...)
|
||||
{
|
||||
#ifndef HAVE_STDARGS
|
||||
char *str;
|
||||
size_t count;
|
||||
char *fmt;
|
||||
#endif
|
||||
VA_LOCAL_DECL;
|
||||
va_list ap;
|
||||
int total;
|
||||
|
||||
VA_START (fmt);
|
||||
VA_SHIFT (str, char *);
|
||||
VA_SHIFT (count, size_t );
|
||||
VA_SHIFT (fmt, char *);
|
||||
total = vsnprintf(str, count, fmt, ap);
|
||||
VA_END;
|
||||
|
||||
va_start (ap, fmt);
|
||||
total = vsnprintf (str, count, fmt, ap);
|
||||
va_end (ap);
|
||||
return total;
|
||||
}
|
||||
#endif /* !HAVE_SNPRINTF */
|
||||
|
@ -31,8 +31,8 @@ so, delete this exception statement from your version. */
|
||||
#ifndef GEN_SSLFUNC_H
|
||||
#define GEN_SSLFUNC_H
|
||||
|
||||
int ssl_init PARAMS ((void));
|
||||
int ssl_connect PARAMS ((int));
|
||||
int ssl_check_certificate PARAMS ((int, const char *));
|
||||
int ssl_init (void);
|
||||
int ssl_connect (int);
|
||||
int ssl_check_certificate (int, const char *);
|
||||
|
||||
#endif /* GEN_SSLFUNC_H */
|
||||
|
81
src/sysdep.h
81
src/sysdep.h
@ -33,18 +33,8 @@ so, delete this exception statement from your version. */
|
||||
#ifndef SYSDEP_H
|
||||
#define SYSDEP_H
|
||||
|
||||
/* We need these to be playing with various stuff. */
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else /* not TIME_WITH_SYS_TIME_H */
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
#else /* not HAVE_SYS_TIME_H */
|
||||
# include <time.h>
|
||||
#endif /* HAVE_SYS_TIME_H */
|
||||
#endif /* TIME_WITH_SYS_TIME_H */
|
||||
|
||||
/* Must include these, so we can test for the missing stat macros and
|
||||
define them as necessary. */
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@ -75,12 +65,12 @@ so, delete this exception statement from your version. */
|
||||
|
||||
/* Needed for compilation under OS/2: */
|
||||
#ifdef __EMX__
|
||||
#ifndef S_ISLNK
|
||||
# define S_ISLNK(m) 0
|
||||
#endif
|
||||
#ifndef lstat
|
||||
# define lstat stat
|
||||
#endif
|
||||
# ifndef S_ISLNK
|
||||
# define S_ISLNK(m) 0
|
||||
# endif
|
||||
# ifndef lstat
|
||||
# define lstat stat
|
||||
# endif
|
||||
#endif /* __EMX__ */
|
||||
|
||||
/* Reportedly, stat() macros are broken on some old systems. Those
|
||||
@ -88,7 +78,7 @@ so, delete this exception statement from your version. */
|
||||
new code to handle it.
|
||||
|
||||
However, I will add code for *missing* macros, and the following
|
||||
are missing from many systems. */
|
||||
are reportedly missing from many systems. */
|
||||
#ifndef S_ISLNK
|
||||
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
|
||||
#endif
|
||||
@ -99,15 +89,6 @@ so, delete this exception statement from your version. */
|
||||
# define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
|
||||
#endif
|
||||
|
||||
/* Bletch! SPARC compiler doesn't define sparc (needed by
|
||||
arpa/nameser.h) when in -Xc mode. Luckily, it always defines
|
||||
__sparc. */
|
||||
#ifdef __sparc
|
||||
#ifndef sparc
|
||||
#define sparc
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Define a large integral type useful for storing large sizes that
|
||||
exceed sizes of one download, such as when printing the sum of all
|
||||
downloads. Note that this has nothing to do with large file
|
||||
@ -146,14 +127,14 @@ typedef double LARGE_INT;
|
||||
# define struct_stat struct stat
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
/* For CHAR_BIT, LONG_MAX, etc. */
|
||||
#include <limits.h>
|
||||
|
||||
#ifndef CHAR_BIT
|
||||
# define CHAR_BIT 8
|
||||
#endif
|
||||
|
||||
/* Used by wget.h to define SIZEOF_WGINT. */
|
||||
#ifndef LONG_MAX
|
||||
# define LONG_MAX ((long) ~((unsigned long)1 << (CHAR_BIT * sizeof (long) - 1)))
|
||||
#endif
|
||||
@ -161,54 +142,26 @@ typedef double LARGE_INT;
|
||||
# define LLONG_MAX ((long long) ~((unsigned long long)1 << (CHAR_BIT * sizeof (long long) - 1)))
|
||||
#endif
|
||||
|
||||
/* These are defined in cmpt.c if missing, therefore it's generally
|
||||
safe to declare their parameters. */
|
||||
#ifndef HAVE_STRERROR
|
||||
char *strerror ();
|
||||
#endif
|
||||
/* These are defined in cmpt.c if missing, so we must declare
|
||||
them. */
|
||||
#ifndef HAVE_STRCASECMP
|
||||
int strcasecmp ();
|
||||
#endif
|
||||
#ifndef HAVE_STRNCASECMP
|
||||
int strncasecmp ();
|
||||
#endif
|
||||
#ifndef HAVE_STRSTR
|
||||
char *strstr ();
|
||||
#endif
|
||||
#ifndef HAVE_STRPTIME
|
||||
char *strptime ();
|
||||
#endif
|
||||
|
||||
/* These are defined in snprintf.c. It would be nice to have an
|
||||
snprintf.h, though. */
|
||||
#ifndef HAVE_SNPRINTF
|
||||
int snprintf ();
|
||||
#endif
|
||||
#ifndef HAVE_VSNPRINTF
|
||||
int vsnprintf ();
|
||||
#endif
|
||||
#ifndef HAVE_MEMMOVE
|
||||
void *memmove ();
|
||||
#endif
|
||||
|
||||
/* SunOS brain damage -- for some reason, SunOS header files fail to
|
||||
declare the functions below, which causes all kinds of problems,
|
||||
most notably compilation errors when using pointer arithmetic on
|
||||
their return values.
|
||||
|
||||
This used to be only within `#ifdef STDC_HEADERS', but it got
|
||||
tripped on other systems (AIX), thus causing havoc. Fortunately,
|
||||
SunOS appears to be the only system braindamaged that badly, so I
|
||||
added an extra `#ifdef sun' guard. */
|
||||
#ifndef STDC_HEADERS
|
||||
#ifdef sun
|
||||
#ifndef __SVR4 /* exclude Solaris */
|
||||
char *strstr ();
|
||||
char *strchr ();
|
||||
char *strrchr ();
|
||||
char *strtok ();
|
||||
char *strdup ();
|
||||
void *memcpy ();
|
||||
#endif /* not __SVR4 */
|
||||
#endif /* sun */
|
||||
#endif /* not STDC_HEADERS */
|
||||
|
||||
/* Some systems (Linux libc5, "NCR MP-RAS 3.0", and others) don't
|
||||
provide MAP_FAILED, a symbolic constant for the value returned by
|
||||
|
33
src/url.c
33
src/url.c
@ -31,12 +31,7 @@ so, delete this exception statement from your version. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
@ -48,10 +43,6 @@ so, delete this exception statement from your version. */
|
||||
#include "url.h"
|
||||
#include "host.h" /* for is_valid_ipv6_address */
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
struct scheme_data
|
||||
{
|
||||
const char *name;
|
||||
@ -75,7 +66,7 @@ static struct scheme_data supported_schemes[] =
|
||||
|
||||
/* Forward declarations: */
|
||||
|
||||
static int path_simplify PARAMS ((char *));
|
||||
static int path_simplify (char *);
|
||||
|
||||
/* Support for escaping and unescaping of URL strings. */
|
||||
|
||||
@ -570,7 +561,7 @@ rewrite_shorthand_url (const char *url)
|
||||
}
|
||||
}
|
||||
|
||||
static void split_path PARAMS ((const char *, char **, char **));
|
||||
static void split_path (const char *, char **, char **);
|
||||
|
||||
/* Like strpbrk, with the exception that it returns the pointer to the
|
||||
terminating zero (end-of-string aka "eos") if no matching character
|
||||
@ -672,7 +663,7 @@ url_parse (const char *url, int *error)
|
||||
if (scheme == SCHEME_INVALID)
|
||||
{
|
||||
error_code = PE_UNSUPPORTED_SCHEME;
|
||||
goto err;
|
||||
goto error;
|
||||
}
|
||||
|
||||
url_encoded = reencode_escapes (url);
|
||||
@ -710,7 +701,7 @@ url_parse (const char *url, int *error)
|
||||
if (!host_e)
|
||||
{
|
||||
error_code = PE_UNTERMINATED_IPV6_ADDRESS;
|
||||
goto err;
|
||||
goto error;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_IPV6
|
||||
@ -718,14 +709,14 @@ url_parse (const char *url, int *error)
|
||||
if (!is_valid_ipv6_address(host_b, host_e))
|
||||
{
|
||||
error_code = PE_INVALID_IPV6_ADDRESS;
|
||||
goto err;
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Continue parsing after the closing ']'. */
|
||||
p = host_e + 1;
|
||||
#else
|
||||
error_code = PE_IPV6_NOT_SUPPORTED;
|
||||
goto err;
|
||||
goto error;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
@ -737,7 +728,7 @@ url_parse (const char *url, int *error)
|
||||
if (host_b == host_e)
|
||||
{
|
||||
error_code = PE_EMPTY_HOST;
|
||||
goto err;
|
||||
goto error;
|
||||
}
|
||||
|
||||
port = scheme_default_port (scheme);
|
||||
@ -762,7 +753,7 @@ url_parse (const char *url, int *error)
|
||||
/* http://host:12randomgarbage/blah */
|
||||
/* ^ */
|
||||
error_code = PE_BAD_PORT_NUMBER;
|
||||
goto err;
|
||||
goto error;
|
||||
}
|
||||
port = 10 * port + (*pp - '0');
|
||||
/* Check for too large port numbers here, before we have
|
||||
@ -770,7 +761,7 @@ url_parse (const char *url, int *error)
|
||||
if (port > 65535)
|
||||
{
|
||||
error_code = PE_BAD_PORT_NUMBER;
|
||||
goto err;
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -829,7 +820,7 @@ url_parse (const char *url, int *error)
|
||||
if (!parse_credentials (uname_b, uname_e - 1, &user, &passwd))
|
||||
{
|
||||
error_code = PE_INVALID_USER_NAME;
|
||||
goto err;
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
@ -883,7 +874,7 @@ url_parse (const char *url, int *error)
|
||||
|
||||
return u;
|
||||
|
||||
err:
|
||||
error:
|
||||
/* Cleanup in case of error: */
|
||||
if (url_encoded && url_encoded != url)
|
||||
xfree (url_encoded);
|
||||
|
34
src/url.h
34
src/url.h
@ -73,28 +73,28 @@ struct url
|
||||
|
||||
/* Function declarations */
|
||||
|
||||
char *url_escape PARAMS ((const char *));
|
||||
char *url_escape (const char *);
|
||||
|
||||
struct url *url_parse PARAMS ((const char *, int *));
|
||||
const char *url_error PARAMS ((int));
|
||||
char *url_full_path PARAMS ((const struct url *));
|
||||
void url_set_dir PARAMS ((struct url *, const char *));
|
||||
void url_set_file PARAMS ((struct url *, const char *));
|
||||
void url_free PARAMS ((struct url *));
|
||||
struct url *url_parse (const char *, int *);
|
||||
const char *url_error (int);
|
||||
char *url_full_path (const struct url *);
|
||||
void url_set_dir (struct url *, const char *);
|
||||
void url_set_file (struct url *, const char *);
|
||||
void url_free (struct url *);
|
||||
|
||||
enum url_scheme url_scheme PARAMS ((const char *));
|
||||
int url_has_scheme PARAMS ((const char *));
|
||||
int scheme_default_port PARAMS ((enum url_scheme));
|
||||
void scheme_disable PARAMS ((enum url_scheme));
|
||||
enum url_scheme url_scheme (const char *);
|
||||
int url_has_scheme (const char *);
|
||||
int scheme_default_port (enum url_scheme);
|
||||
void scheme_disable (enum url_scheme);
|
||||
|
||||
char *url_string PARAMS ((const struct url *, int));
|
||||
char *url_file_name PARAMS ((const struct url *));
|
||||
char *url_string (const struct url *, int);
|
||||
char *url_file_name (const struct url *);
|
||||
|
||||
char *uri_merge PARAMS ((const char *, const char *));
|
||||
char *uri_merge (const char *, const char *);
|
||||
|
||||
int mkalldirs PARAMS ((const char *));
|
||||
int mkalldirs (const char *);
|
||||
|
||||
char *rewrite_shorthand_url PARAMS ((const char *));
|
||||
int schemes_are_similar_p PARAMS ((enum url_scheme a, enum url_scheme b));
|
||||
char *rewrite_shorthand_url (const char *);
|
||||
int schemes_are_similar_p (enum url_scheme a, enum url_scheme b);
|
||||
|
||||
#endif /* URL_H */
|
||||
|
47
src/utils.c
47
src/utils.c
@ -31,12 +31,11 @@ so, delete this exception statement from your version. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else /* not HAVE_STRING_H */
|
||||
# include <strings.h>
|
||||
#endif /* not HAVE_STRING_H */
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
@ -61,11 +60,7 @@ so, delete this exception statement from your version. */
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
#ifdef WGET_USE_STDARG
|
||||
# include <stdarg.h>
|
||||
#else
|
||||
# include <varargs.h>
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
|
||||
/* For TIOCGWINSZ and friends: */
|
||||
#ifdef HAVE_SYS_IOCTL_H
|
||||
@ -104,10 +99,6 @@ so, delete this exception statement from your version. */
|
||||
#include "utils.h"
|
||||
#include "hash.h"
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
/* Utility function: like xstrdup(), but also lowercases S. */
|
||||
|
||||
char *
|
||||
@ -168,12 +159,6 @@ sepstring (const char *s)
|
||||
return res;
|
||||
}
|
||||
|
||||
#ifdef WGET_USE_STDARG
|
||||
# define VA_START(args, arg1) va_start (args, arg1)
|
||||
#else
|
||||
# define VA_START(args, ignored) va_start (args)
|
||||
#endif
|
||||
|
||||
/* Like sprintf, but allocates a string of sufficient size with malloc
|
||||
and returns it. GNU libc has a similar function named asprintf,
|
||||
which requires the pointer to the string to be passed. */
|
||||
@ -196,7 +181,7 @@ aprintf (const char *fmt, ...)
|
||||
/* See log_vprintf_internal for explanation why it's OK to rely
|
||||
on the return value of vsnprintf. */
|
||||
|
||||
VA_START (args, fmt);
|
||||
va_start (args, fmt);
|
||||
n = vsnprintf (str, size, fmt, args);
|
||||
va_end (args);
|
||||
|
||||
@ -230,7 +215,7 @@ concat_strings (const char *str0, ...)
|
||||
/* Calculate the length of and allocate the resulting string. */
|
||||
|
||||
argcount = 0;
|
||||
VA_START (args, str0);
|
||||
va_start (args, str0);
|
||||
for (next_str = str0; next_str != NULL; next_str = va_arg (args, char *))
|
||||
{
|
||||
int len = strlen (next_str);
|
||||
@ -244,7 +229,7 @@ concat_strings (const char *str0, ...)
|
||||
/* Copy the strings into the allocated space. */
|
||||
|
||||
argcount = 0;
|
||||
VA_START (args, str0);
|
||||
va_start (args, str0);
|
||||
for (next_str = str0; next_str != NULL; next_str = va_arg (args, char *))
|
||||
{
|
||||
int len;
|
||||
@ -639,7 +624,7 @@ file_merge (const char *base, const char *file)
|
||||
return result;
|
||||
}
|
||||
|
||||
static int in_acclist PARAMS ((const char *const *, const char *, int));
|
||||
static int in_acclist (const char *const *, const char *, int);
|
||||
|
||||
/* Determine whether a file is acceptable to be followed, according to
|
||||
lists of patterns to accept/reject. */
|
||||
@ -1456,10 +1441,10 @@ number_to_string (char *buffer, wgint number)
|
||||
/* wgint is 32 bits wide: no number has more than 10 digits. */
|
||||
else DIGITS_10 (1000000000);
|
||||
#else
|
||||
/* wgint is 64 bits wide: handle numbers with more than 9 decimal
|
||||
digits. Constants are constructed by compile-time multiplication
|
||||
to avoid dealing with different notations for 64-bit constants
|
||||
(nnnL, nnnLL, and nnnI64, depending on the compiler). */
|
||||
/* wgint is 64 bits wide: handle numbers with 9-19 decimal digits.
|
||||
Constants are constructed by compile-time multiplication to avoid
|
||||
dealing with different notations for 64-bit constants
|
||||
(nL/nLL/nI64, depending on the compiler and architecture). */
|
||||
else if (n < 10*(W)1000000000) DIGITS_10 (1000000000);
|
||||
else if (n < 100*(W)1000000000) DIGITS_11 (10*(W)1000000000);
|
||||
else if (n < 1000*(W)1000000000) DIGITS_12 (100*(W)1000000000);
|
||||
@ -2010,7 +1995,7 @@ base64_decode (const char *base64, char *to)
|
||||
|
||||
static void
|
||||
mergesort_internal (void *base, void *temp, size_t size, size_t from, size_t to,
|
||||
int (*cmpfun) PARAMS ((const void *, const void *)))
|
||||
int (*cmpfun) (const void *, const void *))
|
||||
{
|
||||
#define ELT(array, pos) ((char *)(array) + (pos) * size)
|
||||
if (from < to)
|
||||
@ -2042,7 +2027,7 @@ mergesort_internal (void *base, void *temp, size_t size, size_t from, size_t to,
|
||||
|
||||
void
|
||||
stable_sort (void *base, size_t nmemb, size_t size,
|
||||
int (*cmpfun) PARAMS ((const void *, const void *)))
|
||||
int (*cmpfun) (const void *, const void *))
|
||||
{
|
||||
if (size > 1)
|
||||
{
|
||||
|
107
src/utils.h
107
src/utils.h
@ -44,83 +44,76 @@ struct file_memory {
|
||||
|
||||
#define HYPHENP(x) (*(x) == '-' && !*((x) + 1))
|
||||
|
||||
char *time_str PARAMS ((time_t *));
|
||||
char *datetime_str PARAMS ((time_t *));
|
||||
char *time_str (time_t *);
|
||||
char *datetime_str (time_t *);
|
||||
|
||||
#ifdef DEBUG_MALLOC
|
||||
void print_malloc_debug_stats ();
|
||||
#endif
|
||||
|
||||
char *xstrdup_lower PARAMS ((const char *));
|
||||
char *xstrdup_lower (const char *);
|
||||
|
||||
char *strdupdelim PARAMS ((const char *, const char *));
|
||||
char **sepstring PARAMS ((const char *));
|
||||
int frontcmp PARAMS ((const char *, const char *));
|
||||
void fork_to_background PARAMS ((void));
|
||||
char *strdupdelim (const char *, const char *);
|
||||
char **sepstring (const char *);
|
||||
int frontcmp (const char *, const char *);
|
||||
void fork_to_background (void);
|
||||
|
||||
#ifdef WGET_USE_STDARG
|
||||
char *aprintf PARAMS ((const char *, ...))
|
||||
GCC_FORMAT_ATTR (1, 2);
|
||||
char *concat_strings PARAMS ((const char *, ...));
|
||||
#else /* not WGET_USE_STDARG */
|
||||
char *aprintf ();
|
||||
char *concat_strings ();
|
||||
#endif /* not WGET_USE_STDARG */
|
||||
char *aprintf (const char *, ...) GCC_FORMAT_ATTR (1, 2);
|
||||
char *concat_strings (const char *, ...);
|
||||
|
||||
void touch PARAMS ((const char *, time_t));
|
||||
int remove_link PARAMS ((const char *));
|
||||
int file_exists_p PARAMS ((const char *));
|
||||
int file_non_directory_p PARAMS ((const char *));
|
||||
wgint file_size PARAMS ((const char *));
|
||||
int make_directory PARAMS ((const char *));
|
||||
char *unique_name PARAMS ((const char *, int));
|
||||
FILE *unique_create PARAMS ((const char *, int, char **));
|
||||
FILE *fopen_excl PARAMS ((const char *, int));
|
||||
char *file_merge PARAMS ((const char *, const char *));
|
||||
void touch (const char *, time_t);
|
||||
int remove_link (const char *);
|
||||
int file_exists_p (const char *);
|
||||
int file_non_directory_p (const char *);
|
||||
wgint file_size (const char *);
|
||||
int make_directory (const char *);
|
||||
char *unique_name (const char *, int);
|
||||
FILE *unique_create (const char *, int, char **);
|
||||
FILE *fopen_excl (const char *, int);
|
||||
char *file_merge (const char *, const char *);
|
||||
|
||||
int acceptable PARAMS ((const char *));
|
||||
int accdir PARAMS ((const char *s, enum accd));
|
||||
char *suffix PARAMS ((const char *s));
|
||||
int match_tail PARAMS ((const char *, const char *, int));
|
||||
int has_wildcards_p PARAMS ((const char *));
|
||||
int acceptable (const char *);
|
||||
int accdir (const char *s, enum accd);
|
||||
char *suffix (const char *s);
|
||||
int match_tail (const char *, const char *, int);
|
||||
int has_wildcards_p (const char *);
|
||||
|
||||
int has_html_suffix_p PARAMS ((const char *));
|
||||
int has_html_suffix_p (const char *);
|
||||
|
||||
char *read_whole_line PARAMS ((FILE *));
|
||||
struct file_memory *read_file PARAMS ((const char *));
|
||||
void read_file_free PARAMS ((struct file_memory *));
|
||||
char *read_whole_line (FILE *);
|
||||
struct file_memory *read_file (const char *);
|
||||
void read_file_free (struct file_memory *);
|
||||
|
||||
void free_vec PARAMS ((char **));
|
||||
char **merge_vecs PARAMS ((char **, char **));
|
||||
char **vec_append PARAMS ((char **, const char *));
|
||||
void free_vec (char **);
|
||||
char **merge_vecs (char **, char **);
|
||||
char **vec_append (char **, const char *);
|
||||
|
||||
void string_set_add PARAMS ((struct hash_table *, const char *));
|
||||
int string_set_contains PARAMS ((struct hash_table *, const char *));
|
||||
void string_set_to_array PARAMS ((struct hash_table *, char **));
|
||||
void string_set_free PARAMS ((struct hash_table *));
|
||||
void free_keys_and_values PARAMS ((struct hash_table *));
|
||||
void string_set_add (struct hash_table *, const char *);
|
||||
int string_set_contains (struct hash_table *, const char *);
|
||||
void string_set_to_array (struct hash_table *, char **);
|
||||
void string_set_free (struct hash_table *);
|
||||
void free_keys_and_values (struct hash_table *);
|
||||
|
||||
char *with_thousand_seps PARAMS ((wgint));
|
||||
char *with_thousand_seps_large PARAMS ((LARGE_INT));
|
||||
char *human_readable PARAMS ((wgint));
|
||||
int numdigit PARAMS ((wgint));
|
||||
char *number_to_string PARAMS ((char *, wgint));
|
||||
char *number_to_static_string PARAMS ((wgint));
|
||||
char *with_thousand_seps (wgint);
|
||||
char *with_thousand_seps_large (LARGE_INT);
|
||||
char *human_readable (wgint);
|
||||
int numdigit (wgint);
|
||||
char *number_to_string (char *, wgint);
|
||||
char *number_to_static_string (wgint);
|
||||
|
||||
int determine_screen_width PARAMS ((void));
|
||||
int random_number PARAMS ((int));
|
||||
double random_float PARAMS ((void));
|
||||
int determine_screen_width (void);
|
||||
int random_number (int);
|
||||
double random_float (void);
|
||||
|
||||
int run_with_timeout PARAMS ((double, void (*) (void *), void *));
|
||||
void xsleep PARAMS ((double));
|
||||
int run_with_timeout (double, void (*) (void *), void *);
|
||||
void xsleep (double);
|
||||
|
||||
/* How many bytes it will take to store LEN bytes in base64. */
|
||||
#define BASE64_LENGTH(len) (4 * (((len) + 2) / 3))
|
||||
|
||||
int base64_encode PARAMS ((const char *, int, char *));
|
||||
int base64_decode PARAMS ((const char *, char *));
|
||||
int base64_encode (const char *, int, char *);
|
||||
int base64_decode (const char *, char *);
|
||||
|
||||
void stable_sort PARAMS ((void *, size_t, size_t,
|
||||
int (*) (const void *, const void *)));
|
||||
void stable_sort (void *, size_t, size_t, int (*) (const void *, const void *));
|
||||
|
||||
#endif /* UTILS_H */
|
||||
|
@ -40,14 +40,6 @@ so, delete this exception statement from your version. */
|
||||
# define NDEBUG
|
||||
#endif
|
||||
|
||||
#ifndef PARAMS
|
||||
# if PROTOTYPES
|
||||
# define PARAMS(args) args
|
||||
# else
|
||||
# define PARAMS(args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* `gettext (FOO)' is long to write, so we use `_(FOO)'. If NLS is
|
||||
unavailable, _(STRING) simply returns STRING. */
|
||||
#ifdef HAVE_NLS
|
||||
|
@ -31,12 +31,7 @@ so, delete this exception statement from your version. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else /* not HAVE_STRING_H */
|
||||
# include <strings.h>
|
||||
#endif /* not HAVE_STRING_H */
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
@ -44,10 +39,6 @@ so, delete this exception statement from your version. */
|
||||
#include "xmalloc.h"
|
||||
#include "hash.h" /* for hash_pointer */
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
/* This file implements several wrappers around the basic allocation
|
||||
routines. This is done for two reasons: first, so that the callers
|
||||
of these functions need not check for errors, which is easy to
|
||||
|
@ -56,11 +56,11 @@ so, delete this exception statement from your version. */
|
||||
#define xstrdup checking_strdup
|
||||
#define xfree checking_free
|
||||
|
||||
void *checking_malloc PARAMS ((size_t));
|
||||
void *checking_malloc0 PARAMS ((size_t));
|
||||
void *checking_realloc PARAMS ((void *, size_t));
|
||||
char *checking_strdup PARAMS ((const char *));
|
||||
void checking_free PARAMS ((void *));
|
||||
void *checking_malloc (size_t);
|
||||
void *checking_malloc0 (size_t);
|
||||
void *checking_realloc (void *, size_t);
|
||||
char *checking_strdup (const char *);
|
||||
void checking_free (void *);
|
||||
|
||||
#else /* DEBUG_MALLOC */
|
||||
|
||||
@ -70,11 +70,11 @@ void checking_free PARAMS ((void *));
|
||||
#define xstrdup(p) debugging_strdup (p, __FILE__, __LINE__)
|
||||
#define xfree(p) debugging_free (p, __FILE__, __LINE__)
|
||||
|
||||
void *debugging_malloc PARAMS ((size_t, const char *, int));
|
||||
void *debugging_malloc0 PARAMS ((size_t, const char *, int));
|
||||
void *debugging_realloc PARAMS ((void *, size_t, const char *, int));
|
||||
char *debugging_strdup PARAMS ((const char *, const char *, int));
|
||||
void debugging_free PARAMS ((void *, const char *, int));
|
||||
void *debugging_malloc (size_t, const char *, int);
|
||||
void *debugging_malloc0 (size_t, const char *, int);
|
||||
void *debugging_realloc (void *, size_t, const char *, int);
|
||||
char *debugging_strdup (const char *, const char *, int);
|
||||
void debugging_free (void *, const char *, int);
|
||||
|
||||
#endif /* DEBUG_MALLOC */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user