]> git.ipfire.org Git - thirdparty/squid.git/blob - src/protos.h
protos.h refactoring, part one.
[thirdparty/squid.git] / src / protos.h
1 /*
2 * SQUID Web Proxy Cache http://www.squid-cache.org/
3 * ----------------------------------------------------------
4 *
5 * Squid is the result of efforts by numerous individuals from
6 * the Internet community; see the CONTRIBUTORS file for full
7 * details. Many organizations have provided support for Squid's
8 * development; see the SPONSORS file for full details. Squid is
9 * Copyrighted (C) 2001 by the Regents of the University of
10 * California; see the COPYRIGHT file for full details. Squid
11 * incorporates software developed and/or copyrighted by other
12 * sources; see the CREDITS file for full details.
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
27 *
28 */
29 #ifndef SQUID_PROTOS_H
30 #define SQUID_PROTOS_H
31
32 /* included for routines that have not moved out to their proper homes
33 * yet.
34 */
35 #include "Packer.h"
36 /* for routines still in this file that take CacheManager parameters */
37 #include "ip/Address.h"
38 /* for parameters that still need these */
39 #include "enums.h"
40 /* some parameters stil need this */
41 #include "wordlist.h"
42 #include "anyp/ProtocolType.h"
43 #include "Debug.h"
44 #include "HttpHeader.h"
45 #include "HttpStatusCode.h"
46 #include "lookup_t.h"
47
48
49 class HttpRequestMethod;
50 #if USE_DELAY_POOLS
51 class ClientInfo;
52 #endif
53
54
55 class FwdState;
56
57
58 class HttpRequest;
59 class HttpReply;
60
61 /* TODO: move to StrList.h */
62 SQUIDCEXTERN void strListAdd(String * str, const char *item, char del);
63 SQUIDCEXTERN int strListIsMember(const String * str, const char *item, char del);
64 SQUIDCEXTERN int strListIsSubstr(const String * list, const char *s, char del);
65 SQUIDCEXTERN int strListGetItem(const String * str, char del, const char **item, int *ilen, const char **pos);
66
67 extern const char *getStringPrefix(const char *str, const char *end);
68
69
70
71 /* store report about current header usage and other stats */
72 void httpHeaderStoreReport(StoreEntry * e);
73 SQUIDCEXTERN void httpHdrMangleList(HttpHeader *, HttpRequest *, int req_or_rep);
74
75 #if SQUID_SNMP
76 SQUIDCEXTERN PF snmpHandleUdp;
77 SQUIDCEXTERN void snmpInit(void);
78 SQUIDCEXTERN void snmpOpenPorts(void);
79 SQUIDCEXTERN void snmpClosePorts(void);
80 SQUIDCEXTERN const char * snmpDebugOid(oid * Name, snint Len, MemBuf &outbuf);
81
82 SQUIDCEXTERN void addr2oid(Ip::Address &addr, oid *Dest);
83 SQUIDCEXTERN void oid2addr(oid *Dest, Ip::Address &addr, u_int code);
84
85 SQUIDCEXTERN Ip::Address *client_entry(Ip::Address *current);
86 extern variable_list *snmp_basicFn(variable_list *, snint *);
87 extern variable_list *snmp_confFn(variable_list *, snint *);
88 extern variable_list *snmp_sysFn(variable_list *, snint *);
89 extern variable_list *snmp_prfSysFn(variable_list *, snint *);
90 extern variable_list *snmp_prfProtoFn(variable_list *, snint *);
91 extern variable_list *snmp_prfPeerFn(variable_list *, snint *);
92 extern variable_list *snmp_netIpFn(variable_list *, snint *);
93 extern variable_list *snmp_netFqdnFn(variable_list *, snint *);
94 extern variable_list *snmp_netDnsFn(variable_list *, snint *);
95 extern variable_list *snmp_meshPtblFn(variable_list *, snint *);
96 extern variable_list *snmp_meshCtblFn(variable_list *, snint *);
97 #endif /* SQUID_SNMP */
98
99 extern char *mime_get_header(const char *mime, const char *header);
100 extern char *mime_get_header_field(const char *mime, const char *name, const char *prefix);
101 extern size_t headersEnd(const char *, size_t);
102
103 extern void mimeInit(char *filename);
104 extern void mimeFreeMemory(void);
105 extern char *mimeGetContentEncoding(const char *fn);
106 extern char *mimeGetContentType(const char *fn);
107 extern char const *mimeGetIcon(const char *fn);
108 extern const char *mimeGetIconURL(const char *fn);
109 extern char mimeGetTransferMode(const char *fn);
110 extern int mimeGetDownloadOption(const char *fn);
111 extern int mimeGetViewOption(const char *fn);
112
113 #include "ipcache.h"
114 extern int mcastSetTtl(int, int);
115 extern IPH mcastJoinGroups;
116
117 #include "comm/forward.h"
118 extern void getOutgoingAddress(HttpRequest * request, Comm::ConnectionPointer conn);
119 extern Ip::Address getOutgoingAddr(HttpRequest * request, struct peer *dst_peer);
120
121 SQUIDCEXTERN void urnStart(HttpRequest *, StoreEntry *);
122
123 SQUIDCEXTERN void redirectInit(void);
124 SQUIDCEXTERN void redirectShutdown(void);
125
126
127 extern void shut_down(int);
128 extern void rotate_logs(int);
129 extern void reconfigure(int);
130
131
132 extern void start_announce(void *unused);
133 extern void waisStart(FwdState *);
134
135 /* ----------------------------------------------------------------- */
136
137 /* repl_modules.c */
138 extern void storeReplSetup(void);
139
140 /*
141 * store_log.c
142 */
143 extern void storeLog(int tag, const StoreEntry * e);
144 extern void storeLogRotate(void);
145 extern void storeLogClose(void);
146 extern void storeLogOpen(void);
147
148
149 /*
150 * store_digest.c
151 */
152 extern void storeDigestInit(void);
153 extern void storeDigestNoteStoreReady(void);
154 extern void storeDigestScheduleRebuild(void);
155 extern void storeDigestDel(const StoreEntry * entry);
156 extern void storeDigestReport(StoreEntry *);
157
158 /*
159 * store_rebuild.c
160 */
161 SQUIDCEXTERN void storeRebuildStart(void);
162
163 SQUIDCEXTERN void storeRebuildComplete(struct _store_rebuild_data *);
164 SQUIDCEXTERN void storeRebuildProgress(int sd_index, int total, int sofar);
165
166 /// loads entry from disk; fills supplied memory buffer on success
167 extern bool storeRebuildLoadEntry(int fd, int diskIndex, MemBuf &buf, struct _store_rebuild_data &counts);
168 /// parses entry buffer and validates entry metadata; fills e on success
169 extern bool storeRebuildParseEntry(MemBuf &buf, StoreEntry &e, cache_key *key, struct _store_rebuild_data &counts, uint64_t expectedSize);
170 /// checks whether the loaded entry should be kept; updates counters
171 extern bool storeRebuildKeepEntry(const StoreEntry &e, const cache_key *key, struct _store_rebuild_data &counts);
172
173
174 /*
175 * store_swapin.c
176 */
177 class store_client;
178 extern void storeSwapInStart(store_client *);
179
180 /*
181 * store_client.c
182 */
183 SQUIDCEXTERN store_client *storeClientListAdd(StoreEntry * e, void *data);
184 SQUIDCEXTERN int storeClientCopyPending(store_client *, StoreEntry * e, void *data);
185 SQUIDCEXTERN int storeUnregister(store_client * sc, StoreEntry * e, void *data)
186 ;
187 SQUIDCEXTERN int storePendingNClients(const StoreEntry * e);
188 SQUIDCEXTERN int storeClientIsThisAClient(store_client * sc, void *someClient);
189
190
191 SQUIDCEXTERN const char *getMyHostname(void);
192 SQUIDCEXTERN const char *uniqueHostname(void);
193 SQUIDCEXTERN void safeunlink(const char *path, int quiet);
194
195 #include "fatal.h"
196 extern void death(int sig);
197 extern void sigusr2_handle(int sig);
198 extern void sig_child(int sig);
199 extern void sig_shutdown(int sig); ///< handles shutdown notifications from kids
200 SQUIDCEXTERN void leave_suid(void);
201 SQUIDCEXTERN void enter_suid(void);
202 SQUIDCEXTERN void no_suid(void);
203 SQUIDCEXTERN void writePidFile(void);
204 SQUIDCEXTERN void setSocketShutdownLifetimes(int);
205 SQUIDCEXTERN void setMaxFD(void);
206 SQUIDCEXTERN void setSystemLimits(void);
207 extern void squid_signal(int sig, SIGHDLR *, int flags);
208 SQUIDCEXTERN pid_t readPidFile(void);
209 SQUIDCEXTERN void keepCapabilities(void);
210 SQUIDCEXTERN void BroadcastSignalIfAny(int& sig);
211 /// whether the current process is the parent of all other Squid processes
212 SQUIDCEXTERN bool IamMasterProcess();
213 /**
214 whether the current process is dedicated to doing things that only
215 a single process should do, such as PID file maintenance and WCCP
216 */
217 SQUIDCEXTERN bool IamPrimaryProcess();
218 /// whether the current process coordinates worker processes
219 SQUIDCEXTERN bool IamCoordinatorProcess();
220 /// whether the current process handles HTTP transactions and such
221 SQUIDCEXTERN bool IamWorkerProcess();
222 /// whether the current process is dedicated to managing a cache_dir
223 extern bool IamDiskProcess();
224 /// Whether we are running in daemon mode
225 SQUIDCEXTERN bool InDaemonMode(); // try using specific Iam*() checks above first
226 /// Whether there should be more than one worker process running
227 SQUIDCEXTERN bool UsingSmp(); // try using specific Iam*() checks above first
228 /// number of Kid processes as defined in src/ipc/Kid.h
229 SQUIDCEXTERN int NumberOfKids();
230 /// a string describing this process roles such as worker or coordinator
231 extern String ProcessRoles();
232 SQUIDCEXTERN int DebugSignal;
233
234 /* AYJ debugs function to show locations being reset with memset() */
235 SQUIDCEXTERN void *xmemset(void *dst, int, size_t);
236
237 SQUIDCEXTERN void debug_trap(const char *);
238 SQUIDCEXTERN void logsFlush(void);
239 SQUIDCEXTERN const char *checkNullString(const char *p);
240
241 SQUIDCEXTERN void squid_getrusage(struct rusage *r);
242
243 SQUIDCEXTERN double rusage_cputime(struct rusage *r);
244
245 SQUIDCEXTERN int rusage_maxrss(struct rusage *r);
246
247 SQUIDCEXTERN int rusage_pagefaults(struct rusage *r);
248 SQUIDCEXTERN void releaseServerSockets(void);
249 SQUIDCEXTERN void PrintRusage(void);
250 SQUIDCEXTERN void dumpMallocStats(void);
251
252 #if USE_UNLINKD
253 SQUIDCEXTERN bool unlinkdNeeded(void);
254 SQUIDCEXTERN void unlinkdInit(void);
255 SQUIDCEXTERN void unlinkdClose(void);
256 SQUIDCEXTERN void unlinkdUnlink(const char *);
257 #endif
258
259
260 SQUIDCEXTERN peer_t parseNeighborType(const char *s);
261
262 SQUIDCEXTERN int stringHasWhitespace(const char *); //String.cc
263 SQUIDCEXTERN int stringHasCntl(const char *); //String.cc
264 SQUIDCEXTERN void linklistPush(link_list **, void *); //list.cc
265 SQUIDCEXTERN void *linklistShift(link_list **); //list.cc
266 SQUIDCEXTERN int xrename(const char *from, const char *to); //disk.cc
267 extern int isPowTen(int); //int.cc
268
269 SQUIDCEXTERN char *strwordtok(char *buf, char **t); //String.cc
270
271
272 /*
273 * ipc.c
274 */
275 SQUIDCEXTERN pid_t ipcCreate(int type,
276 const char *prog,
277 const char *const args[],
278 const char *name,
279 Ip::Address &local_addr,
280 int *rfd,
281 int *wfd,
282 void **hIpc);
283
284
285 /*
286 * prototypes for system functions missing from system includes
287 */
288
289 #if _SQUID_SOLARIS_
290
291 SQUIDCEXTERN int getrusage(int, struct rusage *);
292 SQUIDCEXTERN int getpagesize(void);
293 #if !defined(_XPG4_2) && !(defined(__EXTENSIONS__) || \
294 (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)))
295 SQUIDCEXTERN int gethostname(char *, int);
296 #endif
297 #endif
298
299 /*
300 * hack to allow snmp access to the statistics counters
301 */
302 class StatCounters;
303 SQUIDCEXTERN StatCounters *snmpStatGet(int);
304
305
306 /* CygWin & Windows NT Port */
307 /* win32.c */
308 #if _SQUID_WINDOWS_
309 SQUIDCEXTERN int WIN32_Subsystem_Init(int *, char ***);
310 SQUIDCEXTERN void WIN32_sendSignal(int);
311 SQUIDCEXTERN void WIN32_Abort(int);
312 SQUIDCEXTERN void WIN32_Exit(void);
313 SQUIDCEXTERN void WIN32_SetServiceCommandLine(void);
314 SQUIDCEXTERN void WIN32_InstallService(void);
315 SQUIDCEXTERN void WIN32_RemoveService(void);
316 SQUIDCEXTERN int SquidMain(int, char **);
317 #endif /* _SQUID_WINDOWS_ */
318 #if _SQUID_MSWIN_
319
320 SQUIDCEXTERN int WIN32_pipe(int[2]);
321
322 SQUIDCEXTERN int WIN32_getrusage(int, struct rusage *);
323 SQUIDCEXTERN void WIN32_ExceptionHandlerInit(void);
324
325 SQUIDCEXTERN int Win32__WSAFDIsSet(int fd, fd_set* set);
326 SQUIDCEXTERN DWORD WIN32_IpAddrChangeMonitorInit();
327
328 #endif
329
330 extern char *strtokFile(void);
331
332 #if USE_AUTH
333
334 #if HAVE_AUTH_MODULE_NEGOTIATE && HAVE_KRB5 && HAVE_GSSAPI
335 /* upstream proxy authentication */
336 SQUIDCEXTERN char *peer_proxy_negotiate_auth(char *principal_name, char *proxy);
337 #endif
338
339 namespace Auth {
340 /* call to ensure the auth component schemes exist. */
341 extern void Init(void);
342 } // namespace Auth
343
344 #endif /* USE_AUTH */
345
346 #endif /* SQUID_PROTOS_H */