]>
git.ipfire.org Git - thirdparty/squid.git/blob - include/util.h
2 * $Id: util.h,v 1.67 2003/01/23 00:36:48 robertc Exp $
4 * AUTHOR: Harvest Derived
6 * SQUID Web Proxy Cache http://www.squid-cache.org/
7 * ----------------------------------------------------------
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.
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.
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.
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
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
47 #if !defined(SQUIDHOSTNAMELEN)
48 #include <sys/param.h>
49 #ifndef _SQUID_NETDB_H_ /* need protection on NEXTSTEP */
50 #define _SQUID_NETDB_H_
53 #if !defined(MAXHOSTNAMELEN) || (MAXHOSTNAMELEN < 128)
54 #define SQUIDHOSTNAMELEN 128
56 #define SQUIDHOSTNAMELEN MAXHOSTNAMELEN
60 #if defined(_SQUID_FREEBSD_)
64 SQUIDCEXTERN
const char *getfullhostname(void);
65 SQUIDCEXTERN
const char *mkhttpdlogtime(const time_t *);
66 SQUIDCEXTERN
const char *mkrfc1123(time_t);
67 SQUIDCEXTERN
char *uudecode(const char *);
68 SQUIDCEXTERN
char *xstrdup(const char *);
69 SQUIDCEXTERN
char *xstrndup(const char *, size_t);
70 SQUIDCEXTERN
const char *xstrerror(void);
71 extern const char *xbstrerror(int);
72 SQUIDCEXTERN
int tvSubMsec(struct timeval
, struct timeval
);
73 SQUIDCEXTERN
int tvSubUsec(struct timeval
, struct timeval
);
74 SQUIDCEXTERN
double tvSubDsec(struct timeval
, struct timeval
);
75 SQUIDCEXTERN
char *xstrncpy(char *, const char *, size_t);
76 SQUIDCEXTERN
size_t xcountws(const char *str
);
77 SQUIDCEXTERN
time_t parse_rfc1123(const char *str
);
78 SQUIDCEXTERN
void *xcalloc(size_t, size_t);
79 SQUIDCEXTERN
void *xmalloc(size_t);
80 SQUIDCEXTERN
void *xrealloc(void *, size_t);
81 SQUIDCEXTERN
void Tolower(char *);
82 SQUIDCEXTERN
void xfree(void *);
83 SQUIDCEXTERN
void xxfree(const void *);
85 inline void *operator new(size_t size
)
89 inline void operator delete (void *address
)
93 inline void *operator new[] (size_t size
)
97 inline void operator delete[] (void *address
)
104 SQUIDCEXTERN
char *rfc1738_escape(const char *);
105 SQUIDCEXTERN
char *rfc1738_escape_unescaped(const char *);
106 SQUIDCEXTERN
char *rfc1738_escape_part(const char *);
107 SQUIDCEXTERN
void rfc1738_unescape(char *);
110 SQUIDCEXTERN
char *html_quote(const char *);
112 #if XMALLOC_STATISTICS
113 SQUIDCEXTERN
void malloc_statistics(void (*)(int, int, int, void *), void *);
117 #define xmalloc(size) (xmalloc_func="xmalloc",xmalloc_line=__LINE__,xmalloc_file=__FILE__,xmalloc(size))
118 #define xfree(ptr) (xmalloc_func="xfree",xmalloc_line=__LINE__,xmalloc_file=__FILE__,xfree(ptr))
119 #define xxfree(ptr) (xmalloc_func="xxfree",xmalloc_line=__LINE__,xmalloc_file=__FILE__,xxfree(ptr))
120 #define xrealloc(ptr,size) (xmalloc_func="xrealloc",xmalloc_line=__LINE__,xmalloc_file=__FILE__,xrealloc(ptr,size))
121 #define xcalloc(n,size) (xmalloc_func="xcalloc",xmalloc_line=__LINE__,xmalloc_file=__FILE__,xcalloc(n,size))
122 #define xstrdup(ptr) (xmalloc_func="xstrdup",xmalloc_line=__LINE__,xmalloc_file=__FILE__,xstrdup(ptr))
123 extern int xmalloc_line
;
124 extern char *xmalloc_file
;
125 extern char *xmalloc_func
;
126 extern int xmalloc_trace
;
127 extern size_t xmalloc_total
;
128 extern void xmalloc_find_leaks(void);
131 typedef struct in_addr SIA
;
132 SQUIDCEXTERN
int safe_inet_addr(const char *, SIA
*);
133 SQUIDCEXTERN
time_t parse_iso3307_time(const char *buf
);
134 SQUIDCEXTERN
char *base64_decode(const char *coded
);
135 SQUIDCEXTERN
const char *base64_encode(const char *decoded
);
136 SQUIDCEXTERN
const char *base64_encode_bin(const char *data
, int len
);
138 SQUIDCEXTERN
double xpercent(double part
, double whole
);
139 SQUIDCEXTERN
int xpercentInt(double part
, double whole
);
140 SQUIDCEXTERN
double xdiv(double nom
, double denom
);
142 SQUIDCEXTERN
const char *xitoa(int num
);
145 double drand48(void);
154 /* gb_type operations */
155 #define gb_flush_limit (0x3FFFFFFF)
156 #define gb_inc(gb, delta) { if ((gb)->bytes > gb_flush_limit || delta > gb_flush_limit) gb_flush(gb); (gb)->bytes += delta; (gb)->count++; }
157 #define gb_incb(gb, delta) { if ((gb)->bytes > gb_flush_limit || delta > gb_flush_limit) gb_flush(gb); (gb)->bytes += delta; }
158 #define gb_incc(gb, delta) { if ((gb)->bytes > gb_flush_limit || delta > gb_flush_limit) gb_flush(gb); (gb)->count+= delta; }
159 extern double gb_to_double(const gb_t
*);
160 SQUIDCEXTERN
const char *double_to_str(char *buf
, int buf_size
, double value
);
161 extern const char *gb_to_str(const gb_t
*);
162 extern void gb_flush(gb_t
*); /* internal, do not use this */
165 * Returns the amount of known allocated memory
167 int statMemoryAccounted(void);
169 #endif /* SQUID_UTIL_H */