]>
Commit | Line | Data |
---|---|---|
090089c4 | 1 | /* |
8a7e978a | 2 | * $Id: util.h,v 1.62 2001/10/17 01:36:07 hno Exp $ |
30a4f2a8 | 3 | * |
4 | * AUTHOR: Harvest Derived | |
5 | * | |
2b6662ba | 6 | * SQUID Web Proxy Cache http://www.squid-cache.org/ |
7 | * ---------------------------------------------------------- | |
30a4f2a8 | 8 | * |
2b6662ba | 9 | * Squid is the result of efforts by numerous individuals from |
10 | * the Internet community; see the CONTRIBUTORS file for full | |
11 | * details. Many organizations have provided support for Squid's | |
12 | * development; see the SPONSORS file for full details. Squid is | |
13 | * Copyrighted (C) 2001 by the Regents of the University of | |
14 | * California; see the COPYRIGHT file for full details. Squid | |
15 | * incorporates software developed and/or copyrighted by other | |
16 | * sources; see the CREDITS file for full details. | |
30a4f2a8 | 17 | * |
18 | * This program is free software; you can redistribute it and/or modify | |
19 | * it under the terms of the GNU General Public License as published by | |
20 | * the Free Software Foundation; either version 2 of the License, or | |
21 | * (at your option) any later version. | |
22 | * | |
23 | * This program is distributed in the hope that it will be useful, | |
24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
26 | * GNU General Public License for more details. | |
27 | * | |
28 | * You should have received a copy of the GNU General Public License | |
29 | * along with this program; if not, write to the Free Software | |
cbdec147 | 30 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. |
30a4f2a8 | 31 | * |
090089c4 | 32 | */ |
01fe0751 | 33 | |
b5638623 | 34 | #ifndef SQUID_UTIL_H |
35 | #define SQUID_UTIL_H | |
090089c4 | 36 | |
37 | #include "config.h" | |
38 | #include <stdio.h> | |
39 | #include <time.h> | |
9d90e665 | 40 | #if HAVE_TIME_H |
41 | #include <time.h> | |
42 | #endif | |
43 | #if HAVE_SYS_TIME_H | |
44 | #include <sys/time.h> | |
45 | #endif | |
090089c4 | 46 | |
47 | #if !defined(SQUIDHOSTNAMELEN) | |
48 | #include <sys/param.h> | |
30a4f2a8 | 49 | #ifndef _SQUID_NETDB_H_ /* need protection on NEXTSTEP */ |
50 | #define _SQUID_NETDB_H_ | |
090089c4 | 51 | #include <netdb.h> |
30a4f2a8 | 52 | #endif |
090089c4 | 53 | #if !defined(MAXHOSTNAMELEN) || (MAXHOSTNAMELEN < 128) |
54 | #define SQUIDHOSTNAMELEN 128 | |
55 | #else | |
56 | #define SQUIDHOSTNAMELEN MAXHOSTNAMELEN | |
57 | #endif | |
58 | #endif | |
59 | ||
c8f322d5 | 60 | #if defined(_SQUID_FREEBSD_) |
61 | #define _etext etext | |
62 | #endif | |
63 | ||
f5b8bbc4 | 64 | extern const char *getfullhostname(void); |
65 | extern const char *mkhttpdlogtime(const time_t *); | |
66 | extern const char *mkrfc1123(time_t); | |
67 | extern char *uudecode(const char *); | |
68 | extern char *xstrdup(const char *); | |
c68e9c6b | 69 | extern char *xstrndup(const char *, size_t); |
f5b8bbc4 | 70 | extern const char *xstrerror(void); |
71 | extern const char *xbstrerror(int); | |
72 | extern int tvSubMsec(struct timeval, struct timeval); | |
73 | extern int tvSubUsec(struct timeval, struct timeval); | |
3a074b2e | 74 | extern double tvSubDsec(struct timeval, struct timeval); |
f5b8bbc4 | 75 | extern char *xstrncpy(char *, const char *, size_t); |
cb69b4c7 | 76 | extern size_t xcountws(const char *str); |
f5b8bbc4 | 77 | extern time_t parse_rfc1123(const char *str); |
8a7e978a | 78 | extern void *xcalloc(size_t, size_t); |
f5b8bbc4 | 79 | extern void *xmalloc(size_t); |
80 | extern void *xrealloc(void *, size_t); | |
81 | extern void Tolower(char *); | |
82 | extern void xfree(void *); | |
e7106f62 | 83 | extern void xxfree(const void *); |
30a4f2a8 | 84 | |
6f483f6d | 85 | /* rfc1738.c */ |
f5b8bbc4 | 86 | extern char *rfc1738_escape(const char *); |
9bc73deb | 87 | extern char *rfc1738_escape_unescaped(const char *); |
88 | extern char *rfc1738_escape_part(const char *); | |
41591069 | 89 | extern void rfc1738_unescape(char *); |
6f483f6d | 90 | |
10270faa | 91 | /* html.c */ |
92 | extern char *html_quote(const char *); | |
93 | ||
30a4f2a8 | 94 | #if XMALLOC_STATISTICS |
58cd5bbd | 95 | extern void malloc_statistics(void (*)(int, int, int, void *), void *); |
30a4f2a8 | 96 | #endif |
090089c4 | 97 | |
027acbaf | 98 | #if XMALLOC_TRACE |
99 | #define xmalloc(size) (xmalloc_func="xmalloc",xmalloc_line=__LINE__,xmalloc_file=__FILE__,xmalloc(size)) | |
100 | #define xfree(ptr) (xmalloc_func="xfree",xmalloc_line=__LINE__,xmalloc_file=__FILE__,xfree(ptr)) | |
101 | #define xxfree(ptr) (xmalloc_func="xxfree",xmalloc_line=__LINE__,xmalloc_file=__FILE__,xxfree(ptr)) | |
102 | #define xrealloc(ptr,size) (xmalloc_func="xrealloc",xmalloc_line=__LINE__,xmalloc_file=__FILE__,xrealloc(ptr,size)) | |
103 | #define xcalloc(n,size) (xmalloc_func="xcalloc",xmalloc_line=__LINE__,xmalloc_file=__FILE__,xcalloc(n,size)) | |
104 | #define xstrdup(ptr) (xmalloc_func="xstrdup",xmalloc_line=__LINE__,xmalloc_file=__FILE__,xstrdup(ptr)) | |
105 | extern int xmalloc_line; | |
106 | extern char *xmalloc_file; | |
107 | extern char *xmalloc_func; | |
33ab18e8 | 108 | extern int xmalloc_trace; |
e76fc3b6 | 109 | extern size_t xmalloc_total; |
79420eee | 110 | extern void xmalloc_find_leaks(void); |
027acbaf | 111 | #endif |
112 | ||
6ad85e8a | 113 | typedef struct in_addr SIA; |
f5b8bbc4 | 114 | extern int safe_inet_addr(const char *, SIA *); |
115 | extern time_t parse_iso3307_time(const char *buf); | |
116 | extern char *base64_decode(const char *coded); | |
f86a22c5 | 117 | extern const char *base64_encode(const char *decoded); |
94439e4e | 118 | extern const char *base64_encode_bin(const char *data, int len); |
6ad85e8a | 119 | |
7021844c | 120 | extern double xpercent(double part, double whole); |
02922e76 | 121 | extern int xpercentInt(double part, double whole); |
7021844c | 122 | extern double xdiv(double nom, double denom); |
123 | ||
de336bbe | 124 | extern const char *xitoa(int num); |
7021844c | 125 | |
da59eee6 | 126 | #if !HAVE_DRAND48 |
127 | double drand48(void); | |
128 | #endif | |
129 | ||
2d72d4fd | 130 | /* |
131 | * Returns the amount of known allocated memory | |
132 | */ | |
133 | int statMemoryAccounted(void); | |
134 | ||
b5638623 | 135 | #endif /* SQUID_UTIL_H */ |