]> sjero.net Git - wget/blob - src/utils.h
[svn] Merge of fix for bugs 20341 and 20410.
[wget] / src / utils.h
1 /* Declarations for utils.c.
2    Copyright (C) 1996-2006 Free Software Foundation, Inc.
3
4 This file is part of GNU Wget.
5
6 GNU Wget is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 GNU Wget is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Wget.  If not, see <http://www.gnu.org/licenses/>.
18
19 In addition, as a special exception, the Free Software Foundation
20 gives permission to link the code of its release of Wget with the
21 OpenSSL project's "OpenSSL" library (or with modified versions of it
22 that use the same license as the "OpenSSL" library), and distribute
23 the linked executables.  You must obey the GNU General Public License
24 in all respects for all of the code used other than "OpenSSL".  If you
25 modify this file, you may extend this exception to your version of the
26 file, but you are not obligated to do so.  If you do not wish to do
27 so, delete this exception statement from your version.  */
28
29 #ifndef UTILS_H
30 #define UTILS_H
31
32 struct hash_table;
33
34 struct file_memory {
35   char *content;
36   long length;
37   int mmap_p;
38 };
39
40 #define HYPHENP(x) (*(x) == '-' && !*((x) + 1))
41
42 char *time_str (time_t);
43 char *datetime_str (time_t);
44
45 #ifdef DEBUG_MALLOC
46 void print_malloc_debug_stats ();
47 #endif
48
49 char *xstrdup_lower (const char *);
50
51 char *strdupdelim (const char *, const char *);
52 char **sepstring (const char *);
53 bool subdir_p (const char *, const char *);
54 void fork_to_background (void);
55
56 char *aprintf (const char *, ...) GCC_FORMAT_ATTR (1, 2);
57 char *concat_strings (const char *, ...);
58
59 void touch (const char *, time_t);
60 int remove_link (const char *);
61 bool file_exists_p (const char *);
62 bool file_non_directory_p (const char *);
63 wgint file_size (const char *);
64 int make_directory (const char *);
65 char *unique_name (const char *, bool);
66 FILE *unique_create (const char *, bool, char **);
67 FILE *fopen_excl (const char *, bool);
68 char *file_merge (const char *, const char *);
69
70 int fnmatch_nocase (const char *, const char *, int);
71 bool acceptable (const char *);
72 bool accdir (const char *s);
73 char *suffix (const char *s);
74 bool match_tail (const char *, const char *, bool);
75 bool has_wildcards_p (const char *);
76
77 bool has_html_suffix_p (const char *);
78
79 char *read_whole_line (FILE *);
80 struct file_memory *read_file (const char *);
81 void read_file_free (struct file_memory *);
82
83 void free_vec (char **);
84 char **merge_vecs (char **, char **);
85 char **vec_append (char **, const char *);
86
87 void string_set_add (struct hash_table *, const char *);
88 int string_set_contains (struct hash_table *, const char *);
89 void string_set_to_array (struct hash_table *, char **);
90 void string_set_free (struct hash_table *);
91 void free_keys_and_values (struct hash_table *);
92
93 const char *with_thousand_seps (wgint);
94
95 /* human_readable must be able to accept wgint and SUM_SIZE_INT
96    arguments.  On machines where wgint is 32-bit, declare it to accept
97    double.  */
98 #if SIZEOF_WGINT >= 8
99 # define HR_NUMTYPE wgint
100 #else
101 # define HR_NUMTYPE double
102 #endif
103 char *human_readable (HR_NUMTYPE);
104
105
106 int numdigit (wgint);
107 char *number_to_string (char *, wgint);
108 char *number_to_static_string (wgint);
109
110 int determine_screen_width (void);
111 int random_number (int);
112 double random_float (void);
113
114 bool run_with_timeout (double, void (*) (void *), void *);
115 void xsleep (double);
116
117 /* How many bytes it will take to store LEN bytes in base64.  */
118 #define BASE64_LENGTH(len) (4 * (((len) + 2) / 3))
119
120 int base64_encode (const void *, int, char *);
121 int base64_decode (const char *, void *);
122
123 void stable_sort (void *, size_t, size_t, int (*) (const void *, const void *));
124
125 const char *print_decimal (double);
126
127 #endif /* UTILS_H */