From 7736d5dc98f281f052c6ce9e3badde03f42363cf Mon Sep 17 00:00:00 2001 From: hniksic Date: Fri, 21 Nov 2003 00:48:45 -0800 Subject: [PATCH] [svn] Remove headers.c and headers.h. --- src/ChangeLog | 6 ++ src/Makefile.in | 6 +- src/headers.c | 138 ------------------------------------- src/headers.h | 50 -------------- src/http.c | 75 +++++++++++++++++++- windows/Makefile.src | 4 +- windows/Makefile.src.bor | 3 +- windows/Makefile.src.mingw | 2 +- windows/Makefile.watcom | 2 +- windows/wget.dep | 3 +- 10 files changed, 88 insertions(+), 201 deletions(-) delete mode 100644 src/headers.c delete mode 100644 src/headers.h diff --git a/src/ChangeLog b/src/ChangeLog index f27a486f..6a5a9912 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2003-11-21 Hrvoje Niksic + + * headers.c: Removed. The file is no longer relevant, now that no + special handling of headers is done by the rbuf code. Moved + portions to http.c. + 2003-11-21 Hrvoje Niksic * rbuf.c: Removed. diff --git a/src/Makefile.in b/src/Makefile.in index 789f3477..185b14be 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -74,7 +74,7 @@ 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 \ - headers$o host$o html-parse$o html-url$o http$o init$o \ + host$o html-parse$o html-url$o http$o init$o \ log$o main$o $(MD5_OBJ) netrc$o progress$o recur$o \ res$o retr$o safe-ctype$o snprintf$o $(SSL_OBJ) url$o \ utils$o version$o xmalloc$o @@ -170,13 +170,11 @@ gen_sslfunc$o: wget.h sysdep.h options.h safe-ctype.h utils.h connect.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 -headers$o: wget.h sysdep.h options.h safe-ctype.h connect.h host.h \ - headers.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 headers.h connect.h host.h netrc.h gen_sslfunc.h \ + retr.h connect.h host.h netrc.h gen_sslfunc.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 \ netrc.h cookies.h progress.h diff --git a/src/headers.c b/src/headers.c deleted file mode 100644 index c942ca3f..00000000 --- a/src/headers.c +++ /dev/null @@ -1,138 +0,0 @@ -/* Generic support for headers. - Copyright (C) 1997, 1998 Free Software Foundation, Inc. - -This file is part of GNU Wget. - -GNU Wget is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -GNU Wget is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -In addition, as a special exception, the Free Software Foundation -gives permission to link the code of its release of Wget with the -OpenSSL project's "OpenSSL" library (or with modified versions of it -that use the same license as the "OpenSSL" library), and distribute -the linked executables. You must obey the GNU General Public License -in all respects for all of the code used other than "OpenSSL". If you -modify this file, you may extend this exception to your version of the -file, but you are not obligated to do so. If you do not wish to do -so, delete this exception statement from your version. */ - -#include - -#include -#include -#ifdef HAVE_STRING_H -# include -#else -# include -#endif - -#include "wget.h" -#include "connect.h" -#include "headers.h" - -/* This file contains the generic routines for work with headers. - Currently they are used only by HTTP in http.c, but they can be - used by anything that cares about RFC822-style headers. - - Header is defined in RFC2068, as quoted below. Note that this - definition is not HTTP-specific -- it is virtually - indistinguishable from the one given in RFC822 or RFC1036. - - message-header = field-name ":" [ field-value ] CRLF - - field-name = token - field-value = *( field-content | LWS ) - - field-content = - - The public functions are header_get() and header_process(), which - see. */ - - -/* Check whether HEADER begins with NAME and, if yes, skip the `:' and - the whitespace, and call PROCFUN with the arguments of HEADER's - contents (after the `:' and space) and ARG. Otherwise, return 0. */ -int -header_process (const char *header, const char *name, - int (*procfun) (const char *, void *), - void *arg) -{ - /* Check whether HEADER matches NAME. */ - while (*name && (TOLOWER (*name) == TOLOWER (*header))) - ++name, ++header; - if (*name || *header++ != ':') - return 0; - - header += skip_lws (header); - - return ((*procfun) (header, arg)); -} - -/* Helper functions for use with header_process(). */ - -/* Extract a long integer from HEADER and store it to CLOSURE. If an - error is encountered, return 0, else 1. */ -int -header_extract_number (const char *header, void *closure) -{ - const char *p = header; - long result; - - for (result = 0; ISDIGIT (*p); p++) - result = 10 * result + (*p - '0'); - - /* Failure if no number present. */ - if (p == header) - return 0; - - /* Skip trailing whitespace. */ - p += skip_lws (p); - - /* Indicate failure if trailing garbage is present. */ - if (*p) - return 0; - - *(long *)closure = result; - return 1; -} - -/* Strdup HEADER, and place the pointer to CLOSURE. */ -int -header_strdup (const char *header, void *closure) -{ - *(char **)closure = xstrdup (header); - return 1; -} - -/* Write the value 1 into the integer pointed to by CLOSURE. */ -int -header_exists (const char *header, void *closure) -{ - *(int *)closure = 1; - return 1; -} - -/* Skip LWS (linear white space), if present. Returns number of - characters to skip. */ -int -skip_lws (const char *string) -{ - const char *p = string; - - while (*p == ' ' || *p == '\t' || *p == '\r' || *p == '\n') - ++p; - return p - string; -} diff --git a/src/headers.h b/src/headers.h deleted file mode 100644 index 782ad359..00000000 --- a/src/headers.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Declarations for `headers.c'. - Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. - -This file is part of GNU Wget. - -GNU Wget is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -GNU Wget is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Wget; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -In addition, as a special exception, the Free Software Foundation -gives permission to link the code of its release of Wget with the -OpenSSL project's "OpenSSL" library (or with modified versions of it -that use the same license as the "OpenSSL" library), and distribute -the linked executables. You must obey the GNU General Public License -in all respects for all of the code used other than "OpenSSL". If you -modify this file, you may extend this exception to your version of the -file, but you are not obligated to do so. If you do not wish to do -so, delete this exception statement from your version. */ - -#ifndef HEADERS_H -#define HEADERS_H - -enum { - HG_OK, HG_ERROR, HG_EOF -}; - -enum header_get_flags { HG_NONE = 0, - HG_NO_CONTINUATIONS = 0x2 }; - -int header_process PARAMS ((const char *, const char *, - int (*) (const char *, void *), - void *)); - -int header_extract_number PARAMS ((const char *, void *)); -int header_strdup PARAMS ((const char *, void *)); -int header_exists PARAMS ((const char *, void *)); - -int skip_lws PARAMS ((const char *)); - -#endif /* HEADERS_H */ diff --git a/src/http.c b/src/http.c index de1cb084..09383af2 100644 --- a/src/http.c +++ b/src/http.c @@ -62,7 +62,6 @@ extern int errno; #include "url.h" #include "host.h" #include "retr.h" -#include "headers.h" #include "connect.h" #include "netrc.h" #ifdef HAVE_SSL @@ -250,6 +249,80 @@ next_header (const char *h) return end; } +/* Skip LWS (linear white space), if present. Returns number of + characters to skip. */ +static int +skip_lws (const char *string) +{ + const char *p = string; + + while (*p == ' ' || *p == '\t' || *p == '\r' || *p == '\n') + ++p; + return p - string; +} + +/* Check whether HEADER begins with NAME and, if yes, skip the `:' and + the whitespace, and call PROCFUN with the arguments of HEADER's + contents (after the `:' and space) and ARG. Otherwise, return 0. */ +int +header_process (const char *header, const char *name, + int (*procfun) (const char *, void *), + void *arg) +{ + /* Check whether HEADER matches NAME. */ + while (*name && (TOLOWER (*name) == TOLOWER (*header))) + ++name, ++header; + if (*name || *header++ != ':') + return 0; + + header += skip_lws (header); + + return ((*procfun) (header, arg)); +} + +/* Helper functions for use with header_process(). */ + +/* Extract a long integer from HEADER and store it to CLOSURE. If an + error is encountered, return 0, else 1. */ +int +header_extract_number (const char *header, void *closure) +{ + const char *p = header; + long result; + + for (result = 0; ISDIGIT (*p); p++) + result = 10 * result + (*p - '0'); + + /* Failure if no number present. */ + if (p == header) + return 0; + + /* Skip trailing whitespace. */ + p += skip_lws (p); + + /* Indicate failure if trailing garbage is present. */ + if (*p) + return 0; + + *(long *)closure = result; + return 1; +} + +/* Strdup HEADER, and place the pointer to CLOSURE. */ +int +header_strdup (const char *header, void *closure) +{ + *(char **)closure = xstrdup (header); + return 1; +} + +/* Write the value 1 into the integer pointed to by CLOSURE. */ +int +header_exists (const char *header, void *closure) +{ + *(int *)closure = 1; + return 1; +} /* Functions to be used as arguments to header_process(): */ diff --git a/windows/Makefile.src b/windows/Makefile.src index 617a8181..a665f25b 100644 --- a/windows/Makefile.src +++ b/windows/Makefile.src @@ -64,13 +64,13 @@ LINK = $(LD) $(LDFLAGS) $(DEBUGLF) /out:$@ RM = del SRC = cmpt.c safe-ctype.c convert.c connect.c host.c http.c netrc.c \ - ftp-basic.c ftp.c ftp-ls.c ftp-opie.c getopt.c hash.c headers.c \ + ftp-basic.c ftp.c ftp-ls.c ftp-opie.c getopt.c hash.c \ html-parse.c html-url.c progress.c retr.c recur.c res.c url.c cookies.c \ init.c utils.c main.c version.c xmalloc.c mswindows.c \ gen-md5.c gnu-md5.c log.c $(SSLSRC) OBJ = cmpt$o safe-ctype$o convert$o connect$o host$o http$o netrc$o \ - ftp-basic$o ftp$o ftp-ls$o ftp-opie$o getopt$o hash$o headers$o \ + ftp-basic$o ftp$o ftp-ls$o ftp-opie$o getopt$o hash$o \ html-parse$o html-url$o progress$o retr$o recur$o res$o url$o cookies$o \ init$o utils$o main$o version$o xmalloc$o mswindows$o \ gen-md5$o gnu-md5$o log$o $(SSLOBJ) diff --git a/windows/Makefile.src.bor b/windows/Makefile.src.bor index 91f982df..3457a10c 100644 --- a/windows/Makefile.src.bor +++ b/windows/Makefile.src.bor @@ -9,7 +9,7 @@ CFLAGS=-DWINDOWS -DHAVE_CONFIG_H -I. -w- -O2 ## variables OBJS=cmpt.obj connect.obj convert.obj ftp.obj ftp-basic.obj \ - ftp-ls.obj ftp-opie.obj getopt.obj headers.obj host.obj html-parse.obj html-url.obj \ + ftp-ls.obj ftp-opie.obj getopt.obj host.obj html-parse.obj html-url.obj \ http.obj init.obj log.obj main.obj gnu-md5.obj netrc.obj \ safe-ctype.obj hash.obj progress.obj gen-md5.obj cookies.obj \ recur.obj res.obj retr.obj url.obj utils.obj version.obj xmalloc.obj \ @@ -33,7 +33,6 @@ gen-md5.obj+ getopt.obj+ gnu-md5.obj+ hash.obj+ -headers.obj+ host.obj+ html-parse.obj+ html-url.obj+ diff --git a/windows/Makefile.src.mingw b/windows/Makefile.src.mingw index 0fddcf3a..9d349db3 100644 --- a/windows/Makefile.src.mingw +++ b/windows/Makefile.src.mingw @@ -22,7 +22,7 @@ CFLAGS= -DWINDOWS -DHAVE_CONFIG_H -O3 -Wall -I. LIBS= -lwsock32 OBJ_EXT=.o OBJS=cmpt${OBJ_EXT} convert${OBJ_EXT} connect${OBJ_EXT} ftp${OBJ_EXT} ftp-basic${OBJ_EXT} \ - ftp-ls${OBJ_EXT} ftp-opie${OBJ_EXT} getopt${OBJ_EXT} headers${OBJ_EXT} host${OBJ_EXT} html-parse${OBJ_EXT} html-url${OBJ_EXT} \ + ftp-ls${OBJ_EXT} ftp-opie${OBJ_EXT} getopt${OBJ_EXT} host${OBJ_EXT} html-parse${OBJ_EXT} html-url${OBJ_EXT} \ http${OBJ_EXT} init${OBJ_EXT} log${OBJ_EXT} main${OBJ_EXT} gnu-md5${OBJ_EXT} netrc${OBJ_EXT} \ safe-ctype${OBJ_EXT} hash${OBJ_EXT} progress${OBJ_EXT} gen-md5${OBJ_EXT} cookies${OBJ_EXT} \ recur${OBJ_EXT} res${OBJ_EXT} retr${OBJ_EXT} url${OBJ_EXT} utils${OBJ_EXT} \ diff --git a/windows/Makefile.watcom b/windows/Makefile.watcom index 75077d01..f235c647 100644 --- a/windows/Makefile.watcom +++ b/windows/Makefile.watcom @@ -52,7 +52,7 @@ CFLAGS+= /os /d2 # ^^-- mind the gap !! OBJS = cmpt.obj convert.obj connect.obj cookies.obj ftp.obj ftp-basic.obj & - ftp-ls.obj ftp-opie.obj getopt.obj hash.obj headers.obj host.obj html-parse.obj html-url.obj & + ftp-ls.obj ftp-opie.obj getopt.obj hash.obj host.obj html-parse.obj html-url.obj & http.obj init.obj log.obj main.obj gen-md5.obj gnu-md5.obj netrc.obj progress.obj & recur.obj res.obj retr.obj safe-ctype.obj url.obj utils.obj version.obj mswindows.obj diff --git a/windows/wget.dep b/windows/wget.dep index e2c2851a..bac6130b 100644 --- a/windows/wget.dep +++ b/windows/wget.dep @@ -13,11 +13,10 @@ gen_sslfunc$o: gen_sslfunc.c config.h wget.h sysdep.h mswindows.h options.h safe getopt$o: getopt.c config.h wget.h sysdep.h mswindows.h options.h safe-ctype.h getopt.h gnu-md5$o: gnu-md5.c config.h wget.h sysdep.h mswindows.h options.h safe-ctype.h gnu-md5.h hash$o: hash.c config.h wget.h sysdep.h mswindows.h options.h safe-ctype.h utils.h hash.h -headers$o: headers.c config.h wget.h sysdep.h mswindows.h options.h safe-ctype.h connect.h host.h headers.h host$o: host.c config.h wget.h sysdep.h mswindows.h options.h safe-ctype.h utils.h host.h url.h hash.h html-parse$o: html-parse.c config.h wget.h sysdep.h mswindows.h options.h safe-ctype.h html-parse.h html-url$o: html-url.c config.h wget.h sysdep.h mswindows.h options.h safe-ctype.h html-parse.h url.h utils.h -http$o: http.c config.h wget.h sysdep.h mswindows.h options.h safe-ctype.h utils.h url.h host.h retr.h headers.h connect.h netrc.h gen-md5.h +http$o: http.c config.h wget.h sysdep.h mswindows.h options.h safe-ctype.h utils.h url.h host.h retr.h connect.h netrc.h gen-md5.h init$o: init.c config.h wget.h sysdep.h mswindows.h options.h safe-ctype.h utils.h init.h host.h recur.h netrc.h cookies.h progress.h log$o: log.c config.h wget.h sysdep.h mswindows.h options.h safe-ctype.h utils.h main$o: main.c config.h wget.h sysdep.h mswindows.h options.h safe-ctype.h utils.h getopt.h init.h retr.h recur.h host.h gen_sslfunc.h getopt.h -- 2.39.2