1 /* Declarations for utils.c.
2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
3 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
5 This file is part of GNU Wget.
7 GNU Wget is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 GNU Wget is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Wget. If not, see <http://www.gnu.org/licenses/>.
20 Additional permission under GNU GPL version 3 section 7
22 If you modify this program, or any covered work, by linking or
23 combining it with the OpenSSL project's OpenSSL library (or a
24 modified version of that library), containing parts covered by the
25 terms of the OpenSSL or SSLeay licenses, the Free Software Foundation
26 grants you additional permission to convey the resulting work.
27 Corresponding Source for a non-source form of such a combination
28 shall include the source code for the parts of OpenSSL used as well
29 as that of the covered work. */
42 #define HYPHENP(x) (*(x) == '-' && !*((x) + 1))
44 char *time_str (time_t);
45 char *datetime_str (time_t);
48 void print_malloc_debug_stats ();
51 char *xstrdup_lower (const char *);
53 char *strdupdelim (const char *, const char *);
54 char **sepstring (const char *);
55 bool subdir_p (const char *, const char *);
56 void fork_to_background (void);
58 char *aprintf (const char *, ...) GCC_FORMAT_ATTR (1, 2);
59 char *concat_strings (const char *, ...);
61 void touch (const char *, time_t);
62 int remove_link (const char *);
63 bool file_exists_p (const char *);
64 bool file_non_directory_p (const char *);
65 wgint file_size (const char *);
66 int make_directory (const char *);
67 char *unique_name (const char *, bool);
68 FILE *unique_create (const char *, bool, char **);
69 FILE *fopen_excl (const char *, bool);
70 char *file_merge (const char *, const char *);
72 int fnmatch_nocase (const char *, const char *, int);
73 bool acceptable (const char *);
74 bool accdir (const char *s);
75 char *suffix (const char *s);
76 bool match_tail (const char *, const char *, bool);
77 bool has_wildcards_p (const char *);
79 bool has_html_suffix_p (const char *);
81 char *read_whole_line (FILE *);
82 struct file_memory *read_file (const char *);
83 void read_file_free (struct file_memory *);
85 void free_vec (char **);
86 char **merge_vecs (char **, char **);
87 char **vec_append (char **, const char *);
89 void string_set_add (struct hash_table *, const char *);
90 int string_set_contains (struct hash_table *, const char *);
91 void string_set_to_array (struct hash_table *, char **);
92 void string_set_free (struct hash_table *);
93 void free_keys_and_values (struct hash_table *);
95 const char *with_thousand_seps (wgint);
97 /* human_readable must be able to accept wgint and SUM_SIZE_INT
98 arguments. On machines where wgint is 32-bit, declare it to accept
100 #if SIZEOF_WGINT >= 8
101 # define HR_NUMTYPE wgint
103 # define HR_NUMTYPE double
105 char *human_readable (HR_NUMTYPE);
108 int numdigit (wgint);
109 char *number_to_string (char *, wgint);
110 char *number_to_static_string (wgint);
112 int determine_screen_width (void);
113 int random_number (int);
114 double random_float (void);
116 bool run_with_timeout (double, void (*) (void *), void *);
117 void xsleep (double);
119 /* How many bytes it will take to store LEN bytes in base64. */
120 #define BASE64_LENGTH(len) (4 * (((len) + 2) / 3))
122 int base64_encode (const void *, int, char *);
123 int base64_decode (const char *, void *);
125 void stable_sort (void *, size_t, size_t, int (*) (const void *, const void *));
127 const char *print_decimal (double);