util.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #ifndef SQUID_UTIL_H
10 #define SQUID_UTIL_H
11 
12 #if HAVE_TIME_H
13 #include <time.h>
14 #endif
15 #if HAVE_ARPA_INET_H
16 #include <arpa/inet.h>
17 #endif
18 
19 SQUIDCEXTERN int tvSubUsec(struct timeval, struct timeval);
20 SQUIDCEXTERN double tvSubDsec(struct timeval, struct timeval);
21 SQUIDCEXTERN void Tolower(char *);
22 
23 SQUIDCEXTERN time_t parse_iso3307_time(const char *buf);
24 
25 SQUIDCEXTERN double xpercent(double part, double whole);
26 SQUIDCEXTERN int xpercentInt(double part, double whole);
27 SQUIDCEXTERN double xdiv(double nom, double denom);
28 
29 SQUIDCEXTERN const char *xitoa(int num);
30 SQUIDCEXTERN const char *xint64toa(int64_t num);
31 
32 typedef struct {
33  size_t count;
34  size_t bytes;
35  size_t gb;
36 } gb_t;
37 
38 /* gb_type operations */
39 #define gb_flush_limit (0x3FFFFFFF)
40 #define gb_inc(gb, delta) { if ((gb)->bytes > gb_flush_limit || delta > gb_flush_limit) gb_flush(gb); (gb)->bytes += delta; (gb)->count++; }
41 #define gb_incb(gb, delta) { if ((gb)->bytes > gb_flush_limit || delta > gb_flush_limit) gb_flush(gb); (gb)->bytes += delta; }
42 #define gb_incc(gb, delta) { if ((gb)->bytes > gb_flush_limit || delta > gb_flush_limit) gb_flush(gb); (gb)->count+= delta; }
43 extern double gb_to_double(const gb_t *);
44 SQUIDCEXTERN const char *double_to_str(char *buf, int buf_size, double value);
45 extern const char *gb_to_str(const gb_t *);
46 extern void gb_flush(gb_t *); /* internal, do not use this */
47 
48 /*
49  * Returns the amount of known allocated memory
50  */
51 int statMemoryAccounted(void);
52 
53 SQUIDCEXTERN unsigned int RoundTo(const unsigned int num, const unsigned int what);
54 
55 #endif /* SQUID_UTIL_H */
56 
SQUIDCEXTERN const char * double_to_str(char *buf, int buf_size, double value)
Definition: util.c:109
SQUIDCEXTERN double xpercent(double part, double whole)
Definition: util.c:54
SQUIDCEXTERN const char * xitoa(int num)
Definition: util.c:79
void gb_flush(gb_t *)
Definition: util.c:96
int statMemoryAccounted(void)
#define SQUIDCEXTERN
Definition: squid.h:26
SQUIDCEXTERN void Tolower(char *)
Definition: util.c:28
double gb_to_double(const gb_t *)
Definition: util.c:103
SQUIDCEXTERN int xpercentInt(double part, double whole)
Definition: util.c:60
size_t count
Definition: util.h:33
size_t bytes
Definition: util.h:34
SQUIDCEXTERN time_t parse_iso3307_time(const char *buf)
Definition: iso3307.c:25
SQUIDCEXTERN int tvSubUsec(struct timeval, struct timeval)
Definition: util.c:39
void const char * buf
Definition: stub_helper.cc:16
Definition: util.h:32
SQUIDCEXTERN const char * xint64toa(int64_t num)
Definition: util.c:88
SQUIDCEXTERN double xdiv(double nom, double denom)
Definition: util.c:72
const char * gb_to_str(const gb_t *)
Definition: util.c:124
size_t gb
Definition: util.h:35
SQUIDCEXTERN unsigned int RoundTo(const unsigned int num, const unsigned int what)
Definition: util.c:153
SQUIDCEXTERN double tvSubDsec(struct timeval, struct timeval)
Definition: util.c:46

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors