mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
[svn] Remove headers.c and headers.h.
This commit is contained in:
parent
d9fea91a0a
commit
7736d5dc98
@ -1,3 +1,9 @@
|
||||
2003-11-21 Hrvoje Niksic <hniksic@xemacs.org>
|
||||
|
||||
* 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 <hniksic@xemacs.org>
|
||||
|
||||
* rbuf.c: Removed.
|
||||
|
@ -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
|
||||
|
138
src/headers.c
138
src/headers.c
@ -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 <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#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 OCTETs making up the field-value
|
||||
and consisting of either *TEXT or combinations
|
||||
of token, tspecials, and quoted-string>
|
||||
|
||||
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;
|
||||
}
|
@ -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 */
|
75
src/http.c
75
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(): */
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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+
|
||||
|
@ -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} \
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user