+2005-06-27 Hrvoje Niksic <hniksic@xemacs.org>
+
+ * 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 <hniksic@xemacs.org>
* cookies.c: Make cookies_now static.
#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 {
#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 */
\f
/* Declarations of `struct cookie' and the most basic functions. */
#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
/* 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 */
/* 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;
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 *);
"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)
#include <locale.h>
#include "wget.h"
+#include "http.h"
#include "utils.h"
#include "url.h"
#include "host.h"
extern char *version_string;
-extern FILE *output_stream;
-extern bool output_stream_regular;
-
#ifndef MIN
# define MIN(x, y) ((x) > (y) ? (y) : (x))
#endif
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]) \
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;
{
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);
/* 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);
--- /dev/null
+/* 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 */
#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
\f
void cleanup_html_url (void);
-void http_cleanup (void);
/* Free the memory allocated by global variables. */
{
/* 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
\f
/* 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'. */
#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"
extern char *version_string;
-extern struct cookie_jar *wget_cookie_jar;
-
static void redirect_output_signal (int);
const char *exec_name;
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 },
/* 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
#define NETRC_FILE_NAME ".netrc"
-acc_t *netrc_list;
+static acc_t *netrc_list;
static acc_t *parse_netrc (const char *);
/* 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. */
#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;
\f
/* Functions for maintaining the URL queue. */
#include "url.h"
#include "recur.h"
#include "ftp.h"
+#include "http.h"
#include "host.h"
#include "connect.h"
#include "hash.h"
#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 {
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 */
#undef PR
#undef W
+#undef SPRINTF_WGINT
#undef DIGITS_1
#undef DIGITS_2
#undef DIGITS_3
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;
\f