From 2447fb9a9b85083c1e6fa54d0a18bdf3962fab1f Mon Sep 17 00:00:00 2001 From: hniksic Date: Mon, 27 Jun 2005 11:19:22 -0700 Subject: [PATCH] [svn] Move extern declarations to .h files. --- src/ChangeLog | 13 +++++++++++++ src/convert.h | 1 + src/cookies.c | 4 +--- src/ftp-ls.c | 3 +-- src/ftp.c | 7 +------ src/ftp.h | 4 +++- src/html-url.c | 4 ++-- src/http.c | 16 ++++++---------- src/http.h | 41 +++++++++++++++++++++++++++++++++++++++++ src/init.c | 14 ++++++-------- src/log.c | 2 +- src/main.c | 8 ++------ src/netrc.c | 2 +- src/openssl.c | 2 +- src/recur.c | 6 ------ src/retr.c | 1 + src/retr.h | 13 ++++--------- src/utils.c | 1 + src/wget.h | 2 +- 19 files changed, 87 insertions(+), 57 deletions(-) create mode 100644 src/http.h diff --git a/src/ChangeLog b/src/ChangeLog index 34de4665..1758f6d9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,16 @@ +2005-06-27 Hrvoje Niksic + + * wget.h (PTR_FORMAT): Cast the result of sizeof to int before + passing it to printf's %*. + + * retr.h: Declare output_stream and output_stream_regular. + + * ftp.h: Declare ftp_last_respline. + + * convert.h: Declare dl_url_file_map. + + * http.h: New file. + 2005-06-27 Hrvoje Niksic * cookies.c: Make cookies_now static. diff --git a/src/convert.h b/src/convert.h index 7dddc024..2615da4a 100644 --- a/src/convert.h +++ b/src/convert.h @@ -31,6 +31,7 @@ so, delete this exception statement from your version. */ #define CONVERT_H struct hash_table; /* forward decl */ +extern struct hash_table *dl_url_file_map; extern struct hash_table *downloaded_html_set; enum convert_options { diff --git a/src/cookies.c b/src/cookies.c index 3a28f900..10710eb6 100644 --- a/src/cookies.c +++ b/src/cookies.c @@ -55,9 +55,7 @@ so, delete this exception statement from your version. */ #include "utils.h" #include "hash.h" #include "cookies.h" - -/* This should *really* be in a .h file! */ -time_t http_atotm (const char *); +#include "http.h" /* for http_atotm */ /* Declarations of `struct cookie' and the most basic functions. */ diff --git a/src/ftp-ls.c b/src/ftp-ls.c index 7e448295..6613d7d1 100644 --- a/src/ftp-ls.c +++ b/src/ftp-ls.c @@ -44,8 +44,7 @@ so, delete this exception statement from your version. */ #include "ftp.h" #include "url.h" #include "convert.h" /* for html_quote_string prototype */ - -extern FILE *output_stream; +#include "retr.h" /* for output_stream */ /* Converts symbolic permissions to number-style ones, e.g. string rwxr-xr-x to 755. For now, it knows nothing of diff --git a/src/ftp.c b/src/ftp.c index 46a520ed..0d903d35 100644 --- a/src/ftp.c +++ b/src/ftp.c @@ -53,11 +53,6 @@ so, delete this exception statement from your version. */ /* File where the "ls -al" listing will be saved. */ #define LIST_FILENAME ".listing" -extern char ftp_last_respline[]; - -extern FILE *output_stream; -extern bool output_stream_regular; - typedef struct { int st; /* connection status */ @@ -1308,7 +1303,7 @@ Removing file due to --delete-after in ftp_loop_internal():\n")); /* Return the directory listing in a reusable format. The directory is specifed in u->dir. */ -uerr_t +static uerr_t ftp_get_listing (struct url *u, ccon *con, struct fileinfo **f) { uerr_t err; diff --git a/src/ftp.h b/src/ftp.h index 8391cfaa..0d4aec52 100644 --- a/src/ftp.h +++ b/src/ftp.h @@ -42,7 +42,9 @@ enum stype ST_OS400, ST_OTHER }; - + +extern char ftp_last_respline[]; + uerr_t ftp_response (int, char **); uerr_t ftp_login (int, const char *, const char *); uerr_t ftp_port (int, int *); diff --git a/src/html-url.c b/src/html-url.c index 47b52e69..2ce91721 100644 --- a/src/html-url.c +++ b/src/html-url.c @@ -170,8 +170,8 @@ static const char *additional_attributes[] = { "action" /* used by tag_handle_form */ }; -struct hash_table *interesting_tags; -struct hash_table *interesting_attributes; +static struct hash_table *interesting_tags; +static struct hash_table *interesting_attributes; static void init_interesting (void) diff --git a/src/http.c b/src/http.c index b62a9821..a5f5673c 100644 --- a/src/http.c +++ b/src/http.c @@ -41,6 +41,7 @@ so, delete this exception statement from your version. */ #include #include "wget.h" +#include "http.h" #include "utils.h" #include "url.h" #include "host.h" @@ -61,9 +62,6 @@ so, delete this exception statement from your version. */ extern char *version_string; -extern FILE *output_stream; -extern bool output_stream_regular; - #ifndef MIN # define MIN(x, y) ((x) > (y) ? (y) : (x)) #endif @@ -1089,8 +1087,6 @@ static char *create_authorization_line (const char *, const char *, static char *basic_authentication_encode (const char *, const char *); static bool known_authentication_scheme_p (const char *, const char *); -time_t http_atotm (const char *); - #define BEGINS_WITH(line, string_constant) \ (!strncasecmp (line, string_constant, sizeof (string_constant) - 1) \ && (ISSPACE (line[sizeof (string_constant) - 1]) \ @@ -2683,7 +2679,7 @@ extract_header_attr (const char *au, const char *attr_name, char **ret) buffer of 33 writable characters (32 for hex digits plus one for zero termination). */ static void -dump_hash (unsigned char *buf, const unsigned char *hash) +dump_hash (char *buf, const unsigned char *hash) { int i; @@ -2772,8 +2768,8 @@ digest_authentication_encode (const char *au, const char *user, { ALLOCA_MD5_CONTEXT (ctx); unsigned char hash[MD5_HASHLEN]; - unsigned char a1buf[MD5_HASHLEN * 2 + 1], a2buf[MD5_HASHLEN * 2 + 1]; - unsigned char response_digest[MD5_HASHLEN * 2 + 1]; + char a1buf[MD5_HASHLEN * 2 + 1], a2buf[MD5_HASHLEN * 2 + 1]; + char response_digest[MD5_HASHLEN * 2 + 1]; /* A1BUF = H(user ":" realm ":" password) */ gen_md5_init (ctx); @@ -2795,11 +2791,11 @@ digest_authentication_encode (const char *au, const char *user, /* RESPONSE_DIGEST = H(A1BUF ":" nonce ":" A2BUF) */ gen_md5_init (ctx); - gen_md5_update (a1buf, MD5_HASHLEN * 2, ctx); + gen_md5_update ((unsigned char *)a1buf, MD5_HASHLEN * 2, ctx); gen_md5_update ((unsigned char *)":", 1, ctx); gen_md5_update ((unsigned char *)nonce, strlen (nonce), ctx); gen_md5_update ((unsigned char *)":", 1, ctx); - gen_md5_update (a2buf, MD5_HASHLEN * 2, ctx); + gen_md5_update ((unsigned char *)a2buf, MD5_HASHLEN * 2, ctx); gen_md5_finish (ctx, hash); dump_hash (response_digest, hash); diff --git a/src/http.h b/src/http.h new file mode 100644 index 00000000..023566f0 --- /dev/null +++ b/src/http.h @@ -0,0 +1,41 @@ +/* Declarations for HTTP. + Copyright (C) 2005 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 HTTP_H +#define HTTP_H + +struct url; + +uerr_t http_loop (struct url *, char **, char **, const char *, int *, + struct url *); +void save_cookies (void); +void http_cleanup (void); +time_t http_atotm (const char *); + +#endif /* HTTP_H */ diff --git a/src/init.c b/src/init.c index a86006b4..db2d2742 100644 --- a/src/init.c +++ b/src/init.c @@ -51,6 +51,8 @@ so, delete this exception statement from your version. */ #include "recur.h" /* for INFINITE_RECURSION */ #include "convert.h" /* for convert_cleanup */ #include "res.h" /* for res_cleanup */ +#include "http.h" /* for http_cleanup */ +#include "retr.h" /* for output_stream */ /* We want tilde expansion enabled only when reading `.wgetrc' lines; otherwise, it will be performed by the shell. This variable will @@ -1415,7 +1417,6 @@ decode_string (const char *val, const struct decode_item *items, int itemcount, void cleanup_html_url (void); -void http_cleanup (void); /* Free the memory allocated by global variables. */ @@ -1424,13 +1425,10 @@ cleanup (void) { /* Free external resources, close files, etc. */ - { - extern FILE *output_stream; - if (output_stream) - fclose (output_stream); - /* No need to check for error because Wget flushes its output (and - checks for errors) after any data arrives. */ - } + if (output_stream) + fclose (output_stream); + /* No need to check for error because Wget flushes its output (and + checks for errors) after any data arrives. */ /* We're exiting anyway so there's no real need to call free() hundreds of times. Skipping the frees will make Wget exit diff --git a/src/log.c b/src/log.c index 8285c7ef..55e98842 100644 --- a/src/log.c +++ b/src/log.c @@ -769,7 +769,7 @@ log_cleanup (void) /* When SIGHUP or SIGUSR1 are received, the output is redirected elsewhere. Such redirection is only allowed once. */ -enum { RR_NONE, RR_REQUESTED, RR_DONE } redirect_request = RR_NONE; +static enum { RR_NONE, RR_REQUESTED, RR_DONE } redirect_request = RR_NONE; static const char *redirect_request_signal_name; /* Redirect output to `wget-log'. */ diff --git a/src/main.c b/src/main.c index a6dfbd65..9bf80465 100644 --- a/src/main.c +++ b/src/main.c @@ -51,6 +51,7 @@ so, delete this exception statement from your version. */ #include "url.h" #include "progress.h" /* for progress_handle_sigwinch */ #include "convert.h" +#include "http.h" /* for save_cookies */ /* On GNU system this will include system-wide getopt.h. */ #include "getopt.h" @@ -63,8 +64,6 @@ struct options opt; extern char *version_string; -extern struct cookie_jar *wget_cookie_jar; - static void redirect_output_signal (int); const char *exec_name; @@ -123,7 +122,7 @@ struct cmdline_option { int argtype; /* for non-standard options */ }; -struct cmdline_option option_data[] = +static struct cmdline_option option_data[] = { { "accept", 'A', OPT_VALUE, "accept", -1 }, { "append-output", 'a', OPT__APPEND_OUTPUT, NULL, required_argument }, @@ -896,9 +895,6 @@ Can't timestamp and not clobber old files at the same time.\n")); /* Open the output filename if necessary. */ if (opt.output_document) { - extern FILE *output_stream; - extern bool output_stream_regular; - if (HYPHENP (opt.output_document)) output_stream = stdout; else diff --git a/src/netrc.c b/src/netrc.c index 158ef39f..6e9611de 100644 --- a/src/netrc.c +++ b/src/netrc.c @@ -46,7 +46,7 @@ so, delete this exception statement from your version. */ #define NETRC_FILE_NAME ".netrc" -acc_t *netrc_list; +static acc_t *netrc_list; static acc_t *parse_netrc (const char *); diff --git a/src/openssl.c b/src/openssl.c index 24652946..75011af7 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -50,7 +50,7 @@ so, delete this exception statement from your version. */ /* Application-wide SSL context. This is common to all SSL connections. */ -SSL_CTX *ssl_ctx; +static SSL_CTX *ssl_ctx; /* Initialize the SSL's PRNG using various methods. */ diff --git a/src/recur.c b/src/recur.c index 75ed6f9d..47f96a10 100644 --- a/src/recur.c +++ b/src/recur.c @@ -48,12 +48,6 @@ so, delete this exception statement from your version. */ #include "hash.h" #include "res.h" #include "convert.h" - -extern char *version_string; -extern SUM_SIZE_INT total_downloaded_bytes; - -extern struct hash_table *dl_url_file_map; -extern struct hash_table *downloaded_html_set; /* Functions for maintaining the URL queue. */ diff --git a/src/retr.c b/src/retr.c index 3838c8d6..45061936 100644 --- a/src/retr.c +++ b/src/retr.c @@ -45,6 +45,7 @@ so, delete this exception statement from your version. */ #include "url.h" #include "recur.h" #include "ftp.h" +#include "http.h" #include "host.h" #include "connect.h" #include "hash.h" diff --git a/src/retr.h b/src/retr.h index 0cc9ebd1..305ced4f 100644 --- a/src/retr.h +++ b/src/retr.h @@ -30,8 +30,12 @@ so, delete this exception statement from your version. */ #ifndef RETR_H #define RETR_H +/* These global vars should be made static to retr.c and exported via + functions! */ extern SUM_SIZE_INT total_downloaded_bytes; extern double total_download_time; +extern FILE *output_stream; +extern bool output_stream_regular; /* Flags for fd_read_body. */ enum { @@ -57,13 +61,4 @@ void sleep_between_retrievals (int); void rotate_backups (const char *); -/* Because there's no http.h. */ - -struct url; - -uerr_t http_loop (struct url *, char **, char **, const char *, int *, - struct url *); -void save_cookies (void); - - #endif /* RETR_H */ diff --git a/src/utils.c b/src/utils.c index c027097f..fbf9b47f 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1477,6 +1477,7 @@ number_to_string (char *buffer, wgint number) #undef PR #undef W +#undef SPRINTF_WGINT #undef DIGITS_1 #undef DIGITS_2 #undef DIGITS_3 diff --git a/src/wget.h b/src/wget.h index d598cccb..6a0756b0 100644 --- a/src/wget.h +++ b/src/wget.h @@ -247,7 +247,7 @@ typedef double SUM_SIZE_INT; using printf ("%0*lx", PTR_FORMAT (p)). (%p is too unpredictable; some implementations prepend 0x, while some don't, and most don't 0-pad the address.) */ -#define PTR_FORMAT(p) 2 * sizeof (void *), (unsigned long) (p) +#define PTR_FORMAT(p) (int) (2 * sizeof (void *)), (unsigned long) (p) extern const char *exec_name; -- 2.39.2