]> git.ipfire.org Git - thirdparty/squid.git/blob - src/tools.h
Merged from trunk
[thirdparty/squid.git] / src / tools.h
1 /*
2 * DEBUG: section 21 Misc Functions
3 * AUTHOR: Harvest Derived
4 *
5 * SQUID Web Proxy Cache http://www.squid-cache.org/
6 * ----------------------------------------------------------
7 *
8 * Squid is the result of efforts by numerous individuals from
9 * the Internet community; see the CONTRIBUTORS file for full
10 * details. Many organizations have provided support for Squid's
11 * development; see the SPONSORS file for full details. Squid is
12 * Copyrighted (C) 2001 by the Regents of the University of
13 * California; see the COPYRIGHT file for full details. Squid
14 * incorporates software developed and/or copyrighted by other
15 * sources; see the CREDITS file for full details.
16 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
30 *
31 */
32
33 #ifndef SQUID_TOOLS_H_
34 #define SQUID_TOOLS_H_
35
36 #include "Packer.h"
37 #include "SquidString.h"
38 #include "typedefs.h"
39
40 class MemBuf;
41
42 extern int DebugSignal;
43
44 extern void kb_incr(kb_t *, size_t);
45 extern void parseEtcHosts(void);
46 extern int getMyPort(void);
47 extern void setUmask(mode_t mask);
48 extern void strwordquote(MemBuf * mb, const char *str);
49
50 /* packs, then prints an object using debugs() */
51 extern void debugObj(int section, int level, const char *label, void *obj, ObjPackMethod pm);
52
53 extern const char *getMyHostname(void);
54 extern const char *uniqueHostname(void);
55
56 extern void death(int sig);
57 extern void sigusr2_handle(int sig);
58 extern void sig_child(int sig);
59 extern void sig_shutdown(int sig); ///< handles shutdown notifications from kids
60 extern void leave_suid(void);
61 extern void enter_suid(void);
62 extern void no_suid(void);
63 extern void writePidFile(void);
64 extern void setMaxFD(void);
65 extern void setSystemLimits(void);
66 extern void squid_signal(int sig, SIGHDLR *, int flags);
67 extern pid_t readPidFile(void);
68 extern void keepCapabilities(void);
69 extern void BroadcastSignalIfAny(int& sig);
70
71 /// whether the current process is the parent of all other Squid processes
72 extern bool IamMasterProcess();
73 /**
74 * whether the current process is dedicated to doing things that only
75 * a single process should do, such as PID file maintenance and WCCP
76 */
77 extern bool IamPrimaryProcess();
78 /// whether the current process coordinates worker processes
79 extern bool IamCoordinatorProcess();
80 /// whether the current process handles HTTP transactions and such
81 extern bool IamWorkerProcess();
82 /// whether the current process is dedicated to managing a cache_dir
83 extern bool IamDiskProcess();
84 /// Whether we are running in daemon mode
85 extern bool InDaemonMode(); // try using specific Iam*() checks above first
86 /// Whether there should be more than one worker process running
87 extern bool UsingSmp(); // try using specific Iam*() checks above first
88 /// number of Kid processes as defined in src/ipc/Kid.h
89 extern int NumberOfKids();
90 /// a string describing this process roles such as worker or coordinator
91 extern String ProcessRoles();
92
93 extern void debug_trap(const char *);
94 extern void *xmemset(void *dst, int, size_t);
95
96 extern void logsFlush(void);
97
98 extern void squid_getrusage(struct rusage *r);
99 extern double rusage_cputime(struct rusage *r);
100 extern int rusage_maxrss(struct rusage *r);
101 extern int rusage_pagefaults(struct rusage *r);
102 extern void releaseServerSockets(void);
103 extern void PrintRusage(void);
104 extern void dumpMallocStats(void);
105
106 #endif /* SQUID_TOOLS_H_ */