]> sjero.net Git - wget/blob - src/utils.h
[svn] Rename LARGE_INT to SUM_SIZE_INT, and simplify its handling.
[wget] / src / utils.h
1 /* Declarations for utils.c.
2    Copyright (C) 2005 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 2 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, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
20 In addition, as a special exception, the Free Software Foundation
21 gives permission to link the code of its release of Wget with the
22 OpenSSL project's "OpenSSL" library (or with modified versions of it
23 that use the same license as the "OpenSSL" library), and distribute
24 the linked executables.  You must obey the GNU General Public License
25 in all respects for all of the code used other than "OpenSSL".  If you
26 modify this file, you may extend this exception to your version of the
27 file, but you are not obligated to do so.  If you do not wish to do
28 so, delete this exception statement from your version.  */
29
30 #ifndef UTILS_H
31 #define UTILS_H
32
33 enum accd {
34    ALLABS = 1
35 };
36
37 struct hash_table;
38
39 struct file_memory {
40   char *content;
41   long length;
42   int mmap_p;
43 };
44
45 #define HYPHENP(x) (*(x) == '-' && !*((x) + 1))
46
47 char *time_str (time_t *);
48 char *datetime_str (time_t *);
49
50 #ifdef DEBUG_MALLOC
51 void print_malloc_debug_stats ();
52 #endif
53
54 char *xstrdup_lower (const char *);
55
56 char *strdupdelim (const char *, const char *);
57 char **sepstring (const char *);
58 bool frontcmp (const char *, const char *);
59 void fork_to_background (void);
60
61 char *aprintf (const char *, ...) GCC_FORMAT_ATTR (1, 2);
62 char *concat_strings (const char *, ...);
63
64 void touch (const char *, time_t);
65 int remove_link (const char *);
66 bool file_exists_p (const char *);
67 bool file_non_directory_p (const char *);
68 wgint file_size (const char *);
69 int make_directory (const char *);
70 char *unique_name (const char *, bool);
71 FILE *unique_create (const char *, bool, char **);
72 FILE *fopen_excl (const char *, bool);
73 char *file_merge (const char *, const char *);
74
75 bool acceptable (const char *);
76 bool accdir (const char *s, enum accd);
77 char *suffix (const char *s);
78 bool match_tail (const char *, const char *, bool);
79 bool has_wildcards_p (const char *);
80
81 bool has_html_suffix_p (const char *);
82
83 char *read_whole_line (FILE *);
84 struct file_memory *read_file (const char *);
85 void read_file_free (struct file_memory *);
86
87 void free_vec (char **);
88 char **merge_vecs (char **, char **);
89 char **vec_append (char **, const char *);
90
91 void string_set_add (struct hash_table *, const char *);
92 int string_set_contains (struct hash_table *, const char *);
93 void string_set_to_array (struct hash_table *, char **);
94 void string_set_free (struct hash_table *);
95 void free_keys_and_values (struct hash_table *);
96
97 char *with_thousand_seps (wgint);
98 #ifndef with_thousand_seps_sum
99 char *with_thousand_seps_sum (SUM_SIZE_INT);
100 #endif
101 char *human_readable (wgint);
102 int numdigit (wgint);
103 char *number_to_string (char *, wgint);
104 char *number_to_static_string (wgint);
105
106 int determine_screen_width (void);
107 int random_number (int);
108 double random_float (void);
109
110 bool run_with_timeout (double, void (*) (void *), void *);
111 void xsleep (double);
112
113 /* How many bytes it will take to store LEN bytes in base64.  */
114 #define BASE64_LENGTH(len) (4 * (((len) + 2) / 3))
115
116 int base64_encode (const char *, int, char *);
117 int base64_decode (const char *, char *);
118
119 void stable_sort (void *, size_t, size_t, int (*) (const void *, const void *));
120
121 #endif /* UTILS_H */