]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/cache_cf.cc
3 * $Id: cache_cf.cc,v 1.456 2004/11/06 22:20:47 hno Exp $
5 * DEBUG: section 3 Configuration File Parsing
6 * AUTHOR: Harvest Derived
8 * SQUID Web Proxy Cache http://www.squid-cache.org/
9 * ----------------------------------------------------------
11 * Squid is the result of efforts by numerous individuals from
12 * the Internet community; see the CONTRIBUTORS file for full
13 * details. Many organizations have provided support for Squid's
14 * development; see the SPONSORS file for full details. Squid is
15 * Copyrighted (C) 2001 by the Regents of the University of
16 * California; see the COPYRIGHT file for full details. Squid
17 * incorporates software developed and/or copyrighted by other
18 * sources; see the CREDITS file for full details.
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
37 #include "authenticate.h"
38 #include "AuthConfig.h"
39 #include "AuthScheme.h"
42 #include "ConfigParser.h"
44 #include "StoreFileSystem.h"
50 #include "ESIParser.h"
55 static const char *const T_SECOND_STR
= "second";
56 static const char *const T_MINUTE_STR
= "minute";
57 static const char *const T_HOUR_STR
= "hour";
58 static const char *const T_DAY_STR
= "day";
59 static const char *const T_WEEK_STR
= "week";
60 static const char *const T_FORTNIGHT_STR
= "fortnight";
61 static const char *const T_MONTH_STR
= "month";
62 static const char *const T_YEAR_STR
= "year";
63 static const char *const T_DECADE_STR
= "decade";
65 static const char *const B_BYTES_STR
= "bytes";
66 static const char *const B_KBYTES_STR
= "KB";
67 static const char *const B_MBYTES_STR
= "MB";
68 static const char *const B_GBYTES_STR
= "GB";
70 static const char *const list_sep
= ", \t\n\r";
72 static void parse_logformat(logformat
** logformat_definitions
);
73 static void parse_access_log(customlog
** customlog_definitions
);
74 static int check_null_access_log(customlog
*customlog_definitions
);
76 static void dump_logformat(StoreEntry
* entry
, const char *name
, logformat
* definitions
);
77 static void dump_access_log(StoreEntry
* entry
, const char *name
, customlog
* definitions
);
78 static void free_logformat(logformat
** definitions
);
79 static void free_access_log(customlog
** definitions
);
84 static void update_maxobjsize(void);
85 static void configDoConfigure(void);
86 static void parse_refreshpattern(refresh_t
**);
87 static int parseTimeUnits(const char *unit
);
88 static void parseTimeLine(time_t * tptr
, const char *units
);
89 static void parse_ushort(u_short
* var
);
90 static void parse_string(char **);
91 static void default_all(void);
92 static void defaults_if_none(void);
93 static int parse_line(char *);
94 static void parseBytesLine(size_t * bptr
, const char *units
);
95 static size_t parseBytesUnits(const char *unit
);
96 static void free_all(void);
97 void requirePathnameExists(const char *name
, const char *path
);
98 static OBJH dump_config
;
100 static void dump_http_header_access(StoreEntry
* entry
, const char *name
, header_mangler header
[]);
101 static void parse_http_header_access(header_mangler header
[]);
102 static void free_http_header_access(header_mangler header
[]);
103 static void dump_http_header_replace(StoreEntry
* entry
, const char *name
, header_mangler header
[]);
104 static void parse_http_header_replace(header_mangler
* header
);
105 static void free_http_header_replace(header_mangler
* header
);
107 static void parse_denyinfo(acl_deny_info_list
** var
);
108 static void dump_denyinfo(StoreEntry
* entry
, const char *name
, acl_deny_info_list
* var
);
109 static void free_denyinfo(acl_deny_info_list
** var
);
111 static void parse_sockaddr_in_list(sockaddr_in_list
**);
112 static void dump_sockaddr_in_list(StoreEntry
*, const char *, const sockaddr_in_list
*);
113 static void free_sockaddr_in_list(sockaddr_in_list
**);
114 static int check_null_sockaddr_in_list(const sockaddr_in_list
*);
115 #endif /* CURRENTLY_UNUSED */
116 static void parse_http_port_list(http_port_list
**);
117 static void dump_http_port_list(StoreEntry
*, const char *, const http_port_list
*);
118 static void free_http_port_list(http_port_list
**);
120 static int check_null_http_port_list(const http_port_list
*);
123 static void parse_https_port_list(https_port_list
**);
124 static void dump_https_port_list(StoreEntry
*, const char *, const https_port_list
*);
125 static void free_https_port_list(https_port_list
**);
127 static int check_null_https_port_list(const https_port_list
*);
130 static void parse_b_size_t(size_t * var
);
135 fatalf("Bungled %s line %d: %s",
136 cfg_filename
, config_lineno
, config_input_line
);
140 wordlistDestroy(wordlist
** list
)
144 while ((w
= *list
) != NULL
) {
147 memFree(w
, MEM_WORDLIST
);
154 wordlistAdd(wordlist
** list
, const char *key
)
157 list
= &(*list
)->next
;
159 *list
= static_cast<wordlist
*>(memAllocate(MEM_WORDLIST
));
161 (*list
)->key
= xstrdup(key
);
163 (*list
)->next
= NULL
;
169 wordlistJoin(wordlist
** list
, wordlist
** wl
)
172 list
= &(*list
)->next
;
180 wordlistAddWl(wordlist
** list
, wordlist
* wl
)
183 list
= &(*list
)->next
;
185 for (; wl
; wl
= wl
->next
, list
= &(*list
)->next
) {
186 *list
= static_cast<wordlist
*>(memAllocate(MEM_WORDLIST
));
187 (*list
)->key
= xstrdup(wl
->key
);
188 (*list
)->next
= NULL
;
193 wordlistCat(const wordlist
* w
, MemBuf
* mb
)
196 memBufPrintf(mb
, "%s\n", w
->key
);
202 wordlistDup(const wordlist
* w
)
207 wordlistAdd(&D
, w
->key
);
215 * These functions is the same as atoi/l/f, except that they check for errors
219 xatol(const char *token
)
222 long ret
= strtol(token
, &end
, 10);
224 if (ret
== 0 && end
== token
)
231 xatoi(const char *token
)
237 xatof(const char *token
)
240 double ret
= strtod(token
, &end
);
242 if (ret
== 0 && end
== token
)
251 char *token
= strtok(NULL
, w_space
);
257 if (sscanf(token
, "%d", &i
) != 1)
264 update_maxobjsize(void)
269 for (i
= 0; i
< Config
.cacheSwap
.n_configured
; i
++) {
270 assert (Config
.cacheSwap
.swapDirs
[i
]);
272 if (Config
.cacheSwap
.swapDirs
[i
]->max_objsize
> ms
)
273 ms
= Config
.cacheSwap
.swapDirs
[i
]->max_objsize
;
276 store_maxobjsize
= ms
;
280 SetConfigFilename(char const *file_name
, bool is_pipe
)
282 cfg_filename
= file_name
;
287 cfg_filename
= file_name
+ 1;
288 else if ((token
= strrchr(cfg_filename
, '/')))
289 cfg_filename
= token
+ 1;
293 parseConfigFile(const char *file_name
)
303 if (file_name
[0] == '!' || file_name
[0] == '|') {
304 fp
= popen(file_name
+ 1, "r");
307 fp
= fopen(file_name
, "r");
311 fatalf("Unable to open configuration file: %s: %s",
312 file_name
, xstrerror());
316 setmode(fileno(fp
), O_TEXT
);
320 SetConfigFilename(file_name
, bool(is_pipe
));
322 memset(config_input_line
, '\0', BUFSIZ
);
326 while (fgets(config_input_line
, BUFSIZ
, fp
)) {
329 if ((token
= strchr(config_input_line
, '\n')))
332 if (strncmp(config_input_line
, "#line ", 6) == 0) {
333 static char new_file_name
[1024];
335 static char new_lineno
;
336 token
= config_input_line
+ 6;
337 new_lineno
= strtol(token
, &file
, 0) - 1;
340 continue; /* Not a valid #line directive, may be a comment */
342 while (*file
&& isspace((unsigned char) *file
))
347 continue; /* Not a valid #line directive, may be a comment */
349 xstrncpy(new_file_name
, file
+ 1, sizeof(new_file_name
));
351 if ((token
= strchr(new_file_name
, '"')))
354 cfg_filename
= new_file_name
;
356 #if PROBABLY_NOT_WANTED_HERE
358 SetConfigFilename(cfg_filename
, false);
364 config_lineno
= new_lineno
;
367 if (config_input_line
[0] == '#')
370 if (config_input_line
[0] == '\0')
373 debug(3, 5) ("Processing: '%s'\n", config_input_line
);
375 tmp_line
= xstrdup(config_input_line
);
377 if (!parse_line(tmp_line
)) {
378 debug(3, 0) ("parseConfigFile: '%s' line %d unrecognized: '%s'\n",
389 int ret
= pclose(fp
);
392 fatalf("parseConfigFile: '%s' failed with exit code %d\n", file_name
, ret
);
399 cachemgrRegister("config",
400 "Current Squid Configuration",
407 configDoConfigure(void)
409 memset(&Config2
, '\0', sizeof(SquidConfig2
));
410 /* init memory as early as possible */
414 if (Config
.cacheSwap
.swapDirs
== NULL
)
415 fatal("No cache_dir's specified in config file");
417 /* calculate Config.Swap.maxSize */
420 if (0 == Config
.Swap
.maxSize
)
421 /* people might want a zero-sized cache on purpose */
423 else if (Config
.Swap
.maxSize
< (Config
.memMaxSize
>> 10))
424 debug(3, 0) ("WARNING cache_mem is larger than total disk cache space!\n");
426 if (Config
.Announce
.period
> 0) {
427 Config
.onoff
.announce
= 1;
428 } else if (Config
.Announce
.period
< 1) {
429 Config
.Announce
.period
= 86400 * 365; /* one year */
430 Config
.onoff
.announce
= 0;
434 if (Config
.dnsChildren
< 1)
435 fatal("No dnsservers allocated");
439 if (Config
.Program
.redirect
) {
440 if (Config
.redirectChildren
< 1) {
441 Config
.redirectChildren
= 0;
442 wordlistDestroy(&Config
.Program
.redirect
);
446 if (Config
.appendDomain
)
447 if (*Config
.appendDomain
!= '.')
448 fatal("append_domain must begin with a '.'");
450 if (Config
.errHtmlText
== NULL
)
451 Config
.errHtmlText
= xstrdup(null_string
);
455 snprintf(ThisCache
, sizeof(ThisCache
), "%s (%s)",
457 full_appname_string
);
460 * the extra space is for loop detection in client_side.c -- we search
461 * for substrings in the Via header.
463 snprintf(ThisCache2
, sizeof(ThisCache
), " %s (%s)",
465 full_appname_string
);
467 if (!Config
.udpMaxHitObjsz
|| Config
.udpMaxHitObjsz
> SQUID_UDP_SO_SNDBUF
)
468 Config
.udpMaxHitObjsz
= SQUID_UDP_SO_SNDBUF
;
470 if (Config
.appendDomain
)
471 Config
.appendDomainLen
= strlen(Config
.appendDomain
);
473 Config
.appendDomainLen
= 0;
475 safe_free(debug_options
)
476 debug_options
= xstrdup(Config
.debugOptions
);
478 if (Config
.retry
.maxtries
> 10)
479 fatal("maximum_single_addr_tries cannot be larger than 10");
481 if (Config
.retry
.maxtries
< 1) {
482 debug(3, 0) ("WARNING: resetting 'maximum_single_addr_tries to 1\n");
483 Config
.retry
.maxtries
= 1;
486 requirePathnameExists("MIME Config Table", Config
.mimeTablePathname
);
489 requirePathnameExists("cache_dns_program", Config
.Program
.dnsserver
);
493 requirePathnameExists("unlinkd_program", Config
.Program
.unlinkd
);
496 if (Config
.Program
.redirect
)
497 requirePathnameExists("redirect_program", Config
.Program
.redirect
->key
);
499 requirePathnameExists("Icon Directory", Config
.icons
.directory
);
501 requirePathnameExists("Error Directory", Config
.errorDirectory
);
508 for (R
= Config
.Refresh
; R
; R
= R
->next
)
510 if (!R
->flags
.override_expire
)
513 debug(22, 1) ("WARNING: use of 'override-expire' in 'refresh_pattern' violates HTTP\n");
518 for (R
= Config
.Refresh
; R
; R
= R
->next
)
520 if (!R
->flags
.override_lastmod
)
523 debug(22, 1) ("WARNING: use of 'override-lastmod' in 'refresh_pattern' violates HTTP\n");
528 for (R
= Config
.Refresh
; R
; R
= R
->next
)
530 if (!R
->flags
.reload_into_ims
)
533 debug(22, 1) ("WARNING: use of 'reload-into-ims' in 'refresh_pattern' violates HTTP\n");
538 for (R
= Config
.Refresh
; R
; R
= R
->next
)
540 if (!R
->flags
.ignore_reload
)
543 debug(22, 1) ("WARNING: use of 'ignore-reload' in 'refresh_pattern' violates HTTP\n");
548 for (R
= Config
.Refresh
; R
; R
= R
->next
)
550 if (!R
->flags
.ignore_no_cache
)
553 debug(22, 1) ("WARNING: use of 'ignore-no-cache' in 'refresh_pattern' violates HTTP\n");
558 for (R
= Config
.Refresh
; R
; R
= R
->next
)
560 if (!R
->flags
.ignore_no_store
)
563 debug(22, 1) ("WARNING: use of 'ignore-no-store' in 'refresh_pattern' violates HTTP\n");
568 for (R
= Config
.Refresh
; R
; R
= R
->next
)
570 if (!R
->flags
.ignore_private
)
573 debug(22, 1) ("WARNING: use of 'ignore-private' in 'refresh_pattern' violates HTTP\n");
578 for (R
= Config
.Refresh
; R
; R
= R
->next
)
580 if (!R
->flags
.ignore_auth
)
583 debug(22, 1) ("WARNING: use of 'ignore-auth' in 'refresh_pattern' violates HTTP\n");
591 Config
.onoff
.via
= 1;
594 if (!Config
.onoff
.via
)
595 debug(22, 1) ("WARNING: HTTP requires the use of Via\n");
599 if (Config
.Wais
.relayHost
) {
600 if (Config
.Wais
._peer
)
601 cbdataFree(Config
.Wais
._peer
);
603 CBDATA_INIT_TYPE_FREECB(peer
, peerDestroy
);
605 Config
.Wais
._peer
= cbdataAlloc(peer
);
607 Config
.Wais
._peer
->host
= xstrdup(Config
.Wais
.relayHost
);
609 Config
.Wais
._peer
->http_port
= Config
.Wais
.relayPort
;
612 if (aclPurgeMethodInUse(Config
.accessList
.http
))
613 Config2
.onoff
.enable_purge
= 1;
615 if (geteuid() == 0) {
616 if (NULL
!= Config
.effectiveUser
) {
618 struct passwd
*pwd
= getpwnam(Config
.effectiveUser
);
622 * Andres Kroonmaa <andre@online.ee>:
623 * Some getpwnam() implementations (Solaris?) require
624 * an available FD < 256 for opening a FILE* to the
627 * This should be safe at startup, but might still fail
628 * during reconfigure.
630 fatalf("getpwnam failed to find userid for effective user '%s'",
631 Config
.effectiveUser
);
633 Config2
.effectiveUserID
= pwd
->pw_uid
;
635 Config2
.effectiveGroupID
= pwd
->pw_gid
;
638 Config2
.effectiveUserID
= geteuid();
639 Config2
.effectiveGroupID
= getegid();
642 if (NULL
!= Config
.effectiveGroup
) {
644 struct group
*grp
= getgrnam(Config
.effectiveGroup
);
647 fatalf("getgrnam failed to find groupid for effective group '%s'",
648 Config
.effectiveGroup
);
650 Config2
.effectiveGroupID
= grp
->gr_gid
;
653 urlExtMethodConfigure();
656 Config
.ssl_client
.sslContext
= sslCreateClientContext(Config
.ssl_client
.cert
, Config
.ssl_client
.key
, Config
.ssl_client
.version
, Config
.ssl_client
.cipher
, Config
.ssl_client
.options
, Config
.ssl_client
.flags
, Config
.ssl_client
.cafile
, Config
.ssl_client
.capath
);
660 /* Parse a time specification from the config file. Store the
661 * result in 'tptr', after converting it to 'units' */
663 parseTimeLine(time_t * tptr
, const char *units
)
670 if ((u
= parseTimeUnits(units
)) == 0)
673 if ((token
= strtok(NULL
, w_space
)) == NULL
)
678 m
= u
; /* default to 'units' if none specified */
682 else if ((token
= strtok(NULL
, w_space
)) == NULL
)
683 debug(3, 0) ("WARNING: No units on '%s', assuming %f %s\n",
684 config_input_line
, d
, units
);
685 else if ((m
= parseTimeUnits(token
)) == 0)
688 *tptr
= static_cast<time_t> (m
* d
/ u
);
692 parseTimeUnits(const char *unit
)
694 if (!strncasecmp(unit
, T_SECOND_STR
, strlen(T_SECOND_STR
)))
697 if (!strncasecmp(unit
, T_MINUTE_STR
, strlen(T_MINUTE_STR
)))
700 if (!strncasecmp(unit
, T_HOUR_STR
, strlen(T_HOUR_STR
)))
703 if (!strncasecmp(unit
, T_DAY_STR
, strlen(T_DAY_STR
)))
706 if (!strncasecmp(unit
, T_WEEK_STR
, strlen(T_WEEK_STR
)))
709 if (!strncasecmp(unit
, T_FORTNIGHT_STR
, strlen(T_FORTNIGHT_STR
)))
712 if (!strncasecmp(unit
, T_MONTH_STR
, strlen(T_MONTH_STR
)))
715 if (!strncasecmp(unit
, T_YEAR_STR
, strlen(T_YEAR_STR
)))
716 return static_cast<int>(86400 * 365.2522);
718 if (!strncasecmp(unit
, T_DECADE_STR
, strlen(T_DECADE_STR
)))
719 return static_cast<int>(86400 * 365.2522 * 10);
721 debug(3, 1) ("parseTimeUnits: unknown time unit '%s'\n", unit
);
727 parseBytesLine(size_t * bptr
, const char *units
)
734 if ((u
= parseBytesUnits(units
)) == 0)
737 if ((token
= strtok(NULL
, w_space
)) == NULL
)
740 if (strcmp(token
, "none") == 0 || strcmp(token
, "-1") == 0) {
741 *bptr
= static_cast<size_t>(-1);
747 m
= u
; /* default to 'units' if none specified */
751 else if ((token
= strtok(NULL
, w_space
)) == NULL
)
752 debug(3, 0) ("WARNING: No units on '%s', assuming %f %s\n",
753 config_input_line
, d
, units
);
754 else if ((m
= parseBytesUnits(token
)) == 0)
757 *bptr
= static_cast<size_t>(m
* d
/ u
);
759 if (static_cast<double>(*bptr
) != m
* d
/ u
)
764 parseBytesUnits(const char *unit
)
766 if (!strncasecmp(unit
, B_BYTES_STR
, strlen(B_BYTES_STR
)))
769 if (!strncasecmp(unit
, B_KBYTES_STR
, strlen(B_KBYTES_STR
)))
772 if (!strncasecmp(unit
, B_MBYTES_STR
, strlen(B_MBYTES_STR
)))
775 if (!strncasecmp(unit
, B_GBYTES_STR
, strlen(B_GBYTES_STR
)))
778 debug(3, 1) ("parseBytesUnits: unknown bytes unit '%s'\n", unit
);
783 /*****************************************************************************
785 *****************************************************************************/
788 dump_acl(StoreEntry
* entry
, const char *name
, ACL
* ae
)
794 debug(3, 3) ("dump_acl: %s %s\n", name
, ae
->name
);
795 storeAppendPrintf(entry
, "%s %s %s ",
799 v
= w
= ae
->dumpGeneric();
802 debug(3, 3) ("dump_acl: %s %s %s\n", name
, ae
->name
, v
->key
);
803 storeAppendPrintf(entry
, "%s ", v
->key
);
807 storeAppendPrintf(entry
, "\n");
816 ACL::ParseAclLine(ae
);
826 dump_acl_list(StoreEntry
* entry
, acl_list
* head
)
830 for (l
= head
; l
; l
= l
->next
) {
831 storeAppendPrintf(entry
, " %s%s",
832 l
->op
? null_string
: "!",
838 dump_acl_access(StoreEntry
* entry
, const char *name
, acl_access
* head
)
842 for (l
= head
; l
; l
= l
->next
) {
843 storeAppendPrintf(entry
, "%s %s",
845 l
->allow
? "Allow" : "Deny");
846 dump_acl_list(entry
, l
->aclList
);
847 storeAppendPrintf(entry
, "\n");
852 parse_acl_access(acl_access
** head
)
854 aclParseAccessLine(head
);
858 free_acl_access(acl_access
** head
)
860 aclDestroyAccessList(head
);
865 dump_address(StoreEntry
* entry
, const char *name
, struct in_addr addr
)
867 storeAppendPrintf(entry
, "%s %s\n", name
, inet_ntoa(addr
));
872 parse_address(struct in_addr
*addr
)
875 const struct hostent
*hp
;
876 char *token
= strtok(NULL
, w_space
);
881 if (safe_inet_addr(token
, addr
) == 1)
883 else if ((hp
= gethostbyname(token
))) /* dont use ipcache */
884 *addr
= inaddrFromHostent(hp
);
891 free_address(struct in_addr
*addr
)
894 memset(addr
, '\0', sizeof(struct in_addr
));
897 CBDATA_TYPE(acl_address
);
900 dump_acl_address(StoreEntry
* entry
, const char *name
, acl_address
* head
)
904 for (l
= head
; l
; l
= l
->next
) {
905 if (l
->addr
.s_addr
!= INADDR_ANY
)
906 storeAppendPrintf(entry
, "%s %s", name
, inet_ntoa(l
->addr
));
908 storeAppendPrintf(entry
, "%s autoselect", name
);
910 dump_acl_list(entry
, l
->aclList
);
912 storeAppendPrintf(entry
, "\n");
917 freed_acl_address(void *data
)
919 acl_address
*l
= static_cast<acl_address
*>(data
);
920 aclDestroyAclList(&l
->aclList
);
924 parse_acl_address(acl_address
** head
)
927 acl_address
**tail
= head
; /* sane name below */
928 CBDATA_INIT_TYPE_FREECB(acl_address
, freed_acl_address
);
929 l
= cbdataAlloc(acl_address
);
930 parse_address(&l
->addr
);
931 aclParseAclList(&l
->aclList
);
934 tail
= &(*tail
)->next
;
940 free_acl_address(acl_address
** head
)
943 acl_address
*l
= *head
;
949 CBDATA_TYPE(acl_tos
);
952 dump_acl_tos(StoreEntry
* entry
, const char *name
, acl_tos
* head
)
956 for (l
= head
; l
; l
= l
->next
) {
958 storeAppendPrintf(entry
, "%s 0x%02X", name
, l
->tos
);
960 storeAppendPrintf(entry
, "%s none", name
);
962 dump_acl_list(entry
, l
->aclList
);
964 storeAppendPrintf(entry
, "\n");
969 freed_acl_tos(void *data
)
971 acl_tos
*l
= static_cast<acl_tos
*>(data
);
972 aclDestroyAclList(&l
->aclList
);
976 parse_acl_tos(acl_tos
** head
)
979 acl_tos
**tail
= head
; /* sane name below */
982 char *token
= strtok(NULL
, w_space
);
987 if (sscanf(token
, "0x%x%c", &tos
, &junk
) != 1)
990 if (tos
< 0 || tos
> 255)
993 CBDATA_INIT_TYPE_FREECB(acl_tos
, freed_acl_tos
);
995 l
= cbdataAlloc(acl_tos
);
999 aclParseAclList(&l
->aclList
);
1002 tail
= &(*tail
)->next
;
1008 free_acl_tos(acl_tos
** head
)
1018 CBDATA_TYPE(acl_size_t
);
1021 dump_acl_b_size_t(StoreEntry
* entry
, const char *name
, acl_size_t
* head
)
1025 for (l
= head
; l
; l
= l
->next
) {
1026 if (l
->size
!= static_cast<size_t>(-1))
1027 storeAppendPrintf(entry
, "%s %d %s\n", name
, (int) l
->size
, B_BYTES_STR
);
1029 storeAppendPrintf(entry
, "%s none", name
);
1031 dump_acl_list(entry
, l
->aclList
);
1033 storeAppendPrintf(entry
, "\n");
1038 freed_acl_b_size_t(void *data
)
1040 acl_size_t
*l
= static_cast<acl_size_t
*>(data
);
1041 aclDestroyAclList(&l
->aclList
);
1045 parse_acl_b_size_t(acl_size_t
** head
)
1048 acl_size_t
**tail
= head
; /* sane name below */
1050 CBDATA_INIT_TYPE_FREECB(acl_size_t
, freed_acl_b_size_t
);
1052 l
= cbdataAlloc(acl_size_t
);
1054 parse_b_size_t(&l
->size
);
1056 aclParseAclList(&l
->aclList
);
1059 tail
= &(*tail
)->next
;
1065 free_acl_b_size_t(acl_size_t
** head
)
1068 acl_size_t
*l
= *head
;
1077 #include "DelayPools.h"
1078 #include "DelayConfig.h"
1079 /* do nothing - free_delay_pool_count is the magic free function.
1080 * this is why delay_pool_count isn't just marked TYPE: ushort
1082 #define free_delay_pool_class(X)
1083 #define free_delay_pool_access(X)
1084 #define free_delay_pool_rates(X)
1085 #define dump_delay_pool_class(X, Y, Z)
1086 #define dump_delay_pool_access(X, Y, Z)
1087 #define dump_delay_pool_rates(X, Y, Z)
1090 free_delay_pool_count(DelayConfig
* cfg
)
1092 cfg
->freePoolCount();
1096 dump_delay_pool_count(StoreEntry
* entry
, const char *name
, DelayConfig
&cfg
)
1098 cfg
.dumpPoolCount (entry
, name
);
1102 parse_delay_pool_count(DelayConfig
* cfg
)
1104 cfg
->parsePoolCount();
1108 parse_delay_pool_class(DelayConfig
* cfg
)
1110 cfg
->parsePoolClass();
1114 parse_delay_pool_rates(DelayConfig
* cfg
)
1116 cfg
->parsePoolRates();
1120 parse_delay_pool_access(DelayConfig
* cfg
)
1122 cfg
->parsePoolAccess();
1129 dump_http_header_access(StoreEntry
* entry
, const char *name
, header_mangler header
[])
1133 for (i
= 0; i
< HDR_ENUM_END
; i
++) {
1134 if (header
[i
].access_list
!= NULL
) {
1135 storeAppendPrintf(entry
, "%s ", name
);
1136 dump_acl_access(entry
, httpHeaderNameById(i
),
1137 header
[i
].access_list
);
1143 parse_http_header_access(header_mangler header
[])
1148 if ((t
= strtok(NULL
, w_space
)) == NULL
) {
1149 debug(3, 0) ("%s line %d: %s\n",
1150 cfg_filename
, config_lineno
, config_input_line
);
1151 debug(3, 0) ("parse_http_header_access: missing header name.\n");
1155 /* Now lookup index of header. */
1156 id
= httpHeaderIdByNameDef(t
, strlen(t
));
1158 if (strcmp(t
, "All") == 0)
1160 else if (strcmp(t
, "Other") == 0)
1162 else if (id
== -1) {
1163 debug(3, 0) ("%s line %d: %s\n",
1164 cfg_filename
, config_lineno
, config_input_line
);
1165 debug(3, 0) ("parse_http_header_access: unknown header name %s.\n", t
);
1169 if (id
!= HDR_ENUM_END
) {
1170 parse_acl_access(&header
[id
].access_list
);
1172 char *next_string
= t
+ strlen(t
) - 1;
1174 *(next_string
+ 1) = ' ';
1176 for (i
= 0; i
< HDR_ENUM_END
; i
++) {
1177 char *new_string
= xstrdup(next_string
);
1178 strtok(new_string
, w_space
);
1179 parse_acl_access(&header
[i
].access_list
);
1180 safe_free(new_string
);
1186 free_http_header_access(header_mangler header
[])
1190 for (i
= 0; i
< HDR_ENUM_END
; i
++) {
1191 free_acl_access(&header
[i
].access_list
);
1196 dump_http_header_replace(StoreEntry
* entry
, const char *name
, header_mangler
1201 for (i
= 0; i
< HDR_ENUM_END
; i
++) {
1202 if (NULL
== header
[i
].replacement
)
1205 storeAppendPrintf(entry
, "%s %s %s\n", name
, httpHeaderNameById(i
),
1206 header
[i
].replacement
);
1211 parse_http_header_replace(header_mangler header
[])
1216 if ((t
= strtok(NULL
, w_space
)) == NULL
) {
1217 debug(3, 0) ("%s line %d: %s\n",
1218 cfg_filename
, config_lineno
, config_input_line
);
1219 debug(3, 0) ("parse_http_header_replace: missing header name.\n");
1223 /* Now lookup index of header. */
1224 id
= httpHeaderIdByNameDef(t
, strlen(t
));
1226 if (strcmp(t
, "All") == 0)
1228 else if (strcmp(t
, "Other") == 0)
1230 else if (id
== -1) {
1231 debug(3, 0) ("%s line %d: %s\n",
1232 cfg_filename
, config_lineno
, config_input_line
);
1233 debug(3, 0) ("parse_http_header_replace: unknown header name %s.\n",
1238 if (id
!= HDR_ENUM_END
) {
1239 if (header
[id
].replacement
!= NULL
)
1240 safe_free(header
[id
].replacement
);
1242 header
[id
].replacement
= xstrdup(t
+ strlen(t
) + 1);
1244 for (i
= 0; i
< HDR_ENUM_END
; i
++) {
1245 if (header
[i
].replacement
!= NULL
)
1246 safe_free(header
[i
].replacement
);
1248 header
[i
].replacement
= xstrdup(t
+ strlen(t
) + 1);
1254 free_http_header_replace(header_mangler header
[])
1258 for (i
= 0; i
< HDR_ENUM_END
; i
++) {
1259 if (header
[i
].replacement
!= NULL
)
1260 safe_free(header
[i
].replacement
);
1268 dump_cachedir(StoreEntry
* entry
, const char *name
, _SquidConfig::_cacheSwap swap
)
1274 for (i
= 0; i
< swap
.n_configured
; i
++) {
1275 s
= swap
.swapDirs
[i
];
1276 storeAppendPrintf(entry
, "%s %s %s", name
, s
->type(), s
->path
);
1278 storeAppendPrintf(entry
, "\n");
1284 check_null_cachedir(_SquidConfig::_cacheSwap swap
)
1286 return swap
.swapDirs
== NULL
;
1290 check_null_string(char *s
)
1296 parse_authparam(authConfig
* config
)
1301 if ((type_str
= strtok(NULL
, w_space
)) == NULL
)
1304 if ((param_str
= strtok(NULL
, w_space
)) == NULL
)
1307 /* find a configuration for the scheme */
1308 AuthConfig
*scheme
= AuthConfig::Find (type_str
);
1310 if (scheme
== NULL
) {
1311 /* Create a configuration */
1312 AuthScheme
*theScheme
;
1314 if ((theScheme
= AuthScheme::Find(type_str
)) == NULL
) {
1315 debug(3, 0) ("Parsing Config File: Unknown authentication scheme '%s'.\n", type_str
);
1319 config
->push_back(theScheme
->createConfig());
1320 scheme
= config
->back();
1324 scheme
->parse(scheme
, config
->size(), param_str
);
1328 free_authparam(authConfig
* cfg
)
1331 /* DON'T FREE THESE FOR RECONFIGURE */
1336 while (cfg
->size()) {
1337 scheme
= cfg
->pop_back();
1343 dump_authparam(StoreEntry
* entry
, const char *name
, authConfig cfg
)
1345 for (authConfig::iterator i
= cfg
.begin(); i
!= cfg
.end(); ++i
)
1346 (*i
)->dump(entry
, name
, (*i
));
1350 allocate_new_swapdir(_SquidConfig::_cacheSwap
* swap
)
1352 if (swap
->swapDirs
== NULL
) {
1353 swap
->n_allocated
= 4;
1354 swap
->swapDirs
= static_cast<SwapDir
**>(xcalloc(swap
->n_allocated
, sizeof(SwapDir
*)));
1357 if (swap
->n_allocated
== swap
->n_configured
) {
1359 swap
->n_allocated
<<= 1;
1360 tmp
= static_cast<SwapDir
**>(xcalloc(swap
->n_allocated
, sizeof(SwapDir
*)));
1361 xmemcpy(tmp
, swap
->swapDirs
, swap
->n_configured
* sizeof(SwapDir
*));
1362 xfree(swap
->swapDirs
);
1363 swap
->swapDirs
= tmp
;
1367 /* TODO: just return the object, the # is irrelevant */
1369 find_fstype(char *type
)
1371 for (size_t i
= 0; i
< StoreFileSystem::FileSystems().size(); ++i
)
1372 if (strcasecmp(type
, StoreFileSystem::FileSystems().items
[i
]->type()) == 0)
1379 parse_cachedir(_SquidConfig::_cacheSwap
* swap
)
1387 if ((type_str
= strtok(NULL
, w_space
)) == NULL
)
1390 if ((path_str
= strtok(NULL
, w_space
)) == NULL
)
1394 * This bit of code is a little strange.
1395 * See, if we find a path and type match for a given line, then
1396 * as long as we're reconfiguring, we can just call its reconfigure
1397 * function. No harm there.
1399 * Trouble is, if we find a path match, but not a type match, we have
1400 * a dilemma - we could gracefully shut down the fs, kill it, and
1401 * create a new one of a new type in its place, BUT at this stage the
1402 * fs is meant to be the *NEW* one, and so things go very strange. :-)
1404 * So, we'll assume the person isn't going to change the fs type for now,
1405 * and XXX later on we will make sure that its picked up.
1407 * (moving around cache_dir lines will be looked at later in a little
1408 * more sane detail..)
1411 for (i
= 0; i
< swap
->n_configured
; i
++) {
1412 assert (swap
->swapDirs
[i
]);
1414 if (0 == strcasecmp(path_str
, swap
->swapDirs
[i
]->path
)) {
1415 /* This is a little weird, you'll appreciate it later */
1416 fs
= find_fstype(type_str
);
1419 fatalf("Unknown cache_dir type '%s'\n", type_str
);
1422 sd
= swap
->swapDirs
[i
];
1423 sd
->reconfigure (i
, path_str
);
1424 update_maxobjsize();
1429 assert(swap
->n_configured
< 63); /* 7 bits, signed */
1431 fs
= find_fstype(type_str
);
1434 /* If we get here, we didn't find a matching cache_dir type */
1435 fatalf("Unknown cache_dir type '%s'\n", type_str
);
1438 allocate_new_swapdir(swap
);
1439 swap
->swapDirs
[swap
->n_configured
] = StoreFileSystem::FileSystems().items
[fs
]->createSwapDir();
1440 sd
= swap
->swapDirs
[swap
->n_configured
];
1441 /* parse the FS parameters and options */
1442 sd
->parse(swap
->n_configured
, path_str
);
1443 ++swap
->n_configured
;
1444 /* Update the max object size */
1445 update_maxobjsize();
1449 free_cachedir(_SquidConfig::_cacheSwap
* swap
)
1452 /* DON'T FREE THESE FOR RECONFIGURE */
1457 for (i
= 0; i
< swap
->n_configured
; i
++) {
1458 SwapDir
* s
= swap
->swapDirs
[i
];
1459 swap
->swapDirs
[i
] = NULL
;
1463 safe_free(swap
->swapDirs
);
1464 swap
->swapDirs
= NULL
;
1465 swap
->n_allocated
= 0;
1466 swap
->n_configured
= 0;
1470 peer_type_str(const peer_t type
)
1482 case PEER_MULTICAST
:
1493 dump_peer(StoreEntry
* entry
, const char *name
, peer
* p
)
1497 LOCAL_ARRAY(char, xname
, 128);
1500 storeAppendPrintf(entry
, "%s %s %s %d %d",
1506 dump_peer_options(entry
, p
);
1508 for (d
= p
->peer_domain
; d
; d
= d
->next
) {
1509 storeAppendPrintf(entry
, "cache_peer_domain %s %s%s\n",
1511 d
->do_ping
? null_string
: "!",
1516 snprintf(xname
, 128, "cache_peer_access %s", p
->name
);
1517 dump_acl_access(entry
, xname
, p
->access
);
1520 for (t
= p
->typelist
; t
; t
= t
->next
) {
1521 storeAppendPrintf(entry
, "neighbor_type_domain %s %s %s\n",
1523 peer_type_str(t
->type
),
1532 parse_peer(peer
** head
)
1537 CBDATA_INIT_TYPE_FREECB(peer
, peerDestroy
);
1538 p
= cbdataAlloc(peer
);
1539 p
->http_port
= CACHE_HTTP_PORT
;
1540 p
->icp
.port
= CACHE_ICP_PORT
;
1543 p
->stats
.logged_state
= PEER_ALIVE
;
1545 if ((token
= strtok(NULL
, w_space
)) == NULL
)
1548 p
->host
= xstrdup(token
);
1550 p
->name
= xstrdup(token
);
1552 if ((token
= strtok(NULL
, w_space
)) == NULL
)
1555 p
->type
= parseNeighborType(token
);
1559 p
->http_port
= (u_short
) i
;
1563 p
->icp
.port
= (u_short
) i
;
1565 while ((token
= strtok(NULL
, w_space
))) {
1566 if (!strcasecmp(token
, "proxy-only")) {
1567 p
->options
.proxy_only
= 1;
1568 } else if (!strcasecmp(token
, "no-query")) {
1569 p
->options
.no_query
= 1;
1570 } else if (!strcasecmp(token
, "background-ping")) {
1571 p
->options
.background_ping
= 1;
1572 } else if (!strcasecmp(token
, "no-digest")) {
1573 p
->options
.no_digest
= 1;
1574 } else if (!strcasecmp(token
, "multicast-responder")) {
1575 p
->options
.mcast_responder
= 1;
1576 } else if (!strncasecmp(token
, "weight=", 7)) {
1577 p
->weight
= xatoi(token
+ 7);
1578 } else if (!strncasecmp(token
, "basetime=", 9)) {
1579 p
->basetime
= xatoi(token
+ 9);
1580 } else if (!strcasecmp(token
, "closest-only")) {
1581 p
->options
.closest_only
= 1;
1582 } else if (!strncasecmp(token
, "ttl=", 4)) {
1583 p
->mcast
.ttl
= xatoi(token
+ 4);
1585 if (p
->mcast
.ttl
< 0)
1588 if (p
->mcast
.ttl
> 128)
1590 } else if (!strcasecmp(token
, "default")) {
1591 p
->options
.default_parent
= 1;
1592 } else if (!strcasecmp(token
, "round-robin")) {
1593 p
->options
.roundrobin
= 1;
1594 } else if (!strcasecmp(token
, "weighted-round-robin")) {
1595 p
->options
.weighted_roundrobin
= 1;
1598 } else if (!strcasecmp(token
, "htcp")) {
1599 p
->options
.htcp
= 1;
1602 } else if (!strcasecmp(token
, "no-netdb-exchange")) {
1603 p
->options
.no_netdb_exchange
= 1;
1606 } else if (!strcasecmp(token
, "carp")) {
1607 if (p
->type
!= PEER_PARENT
)
1608 fatalf("parse_peer: non-parent carp peer %s/%d\n", p
->host
, p
->http_port
);
1610 p
->options
.carp
= 1;
1615 } else if (!strcasecmp(token
, "no-delay")) {
1616 p
->options
.no_delay
= 1;
1619 } else if (!strncasecmp(token
, "login=", 6)) {
1620 p
->login
= xstrdup(token
+ 6);
1621 rfc1738_unescape(p
->login
);
1622 } else if (!strncasecmp(token
, "connect-timeout=", 16)) {
1623 p
->connect_timeout
= xatoi(token
+ 16);
1624 #if USE_CACHE_DIGESTS
1626 } else if (!strncasecmp(token
, "digest-url=", 11)) {
1627 p
->digest_url
= xstrdup(token
+ 11);
1630 } else if (!strcasecmp(token
, "allow-miss")) {
1631 p
->options
.allow_miss
= 1;
1632 } else if (!strncasecmp(token
, "max-conn=", 9)) {
1633 p
->max_conn
= xatoi(token
+ 9);
1634 } else if (!strcasecmp(token
, "originserver")) {
1635 p
->options
.originserver
= 1;
1636 } else if (!strncasecmp(token
, "name=", 5)) {
1640 p
->name
= xstrdup(token
+ 5);
1641 } else if (!strncasecmp(token
, "forceddomain=", 13)) {
1642 safe_free(p
->domain
);
1645 p
->domain
= xstrdup(token
+ 13);
1649 } else if (strcmp(token
, "ssl") == 0) {
1651 } else if (strncmp(token
, "sslcert=", 8) == 0) {
1652 safe_free(p
->sslcert
);
1653 p
->sslcert
= xstrdup(token
+ 8);
1654 } else if (strncmp(token
, "sslkey=", 7) == 0) {
1655 safe_free(p
->sslkey
);
1656 p
->sslkey
= xstrdup(token
+ 7);
1657 } else if (strncmp(token
, "sslversion=", 11) == 0) {
1658 p
->sslversion
= atoi(token
+ 11);
1659 } else if (strncmp(token
, "ssloptions=", 11) == 0) {
1660 safe_free(p
->ssloptions
);
1661 p
->ssloptions
= xstrdup(token
+ 11);
1662 } else if (strncmp(token
, "sslcipher=", 10) == 0) {
1663 safe_free(p
->sslcipher
);
1664 p
->sslcipher
= xstrdup(token
+ 10);
1665 } else if (strncmp(token
, "sslcafile=", 10) == 0) {
1666 safe_free(p
->sslcafile
);
1667 p
->sslcipher
= xstrdup(token
+ 10);
1668 } else if (strncmp(token
, "sslcapath=", 10) == 0) {
1669 safe_free(p
->sslcapath
);
1670 p
->sslcipher
= xstrdup(token
+ 10);
1671 } else if (strncmp(token
, "sslflags=", 9) == 0) {
1672 safe_free(p
->sslflags
);
1673 p
->sslflags
= xstrdup(token
+ 9);
1674 } else if (strncmp(token
, "ssldomain=", 10) == 0) {
1675 safe_free(p
->ssldomain
);
1676 p
->ssldomain
= xstrdup(token
+ 10);
1679 } else if (strcmp(token
, "front-end-https") == 0) {
1680 p
->front_end_https
= 1;
1681 } else if (strcmp(token
, "front-end-https=on") == 0) {
1682 p
->front_end_https
= 1;
1683 } else if (strcmp(token
, "front-end-https=auto") == 0) {
1684 p
->front_end_https
= 2;
1686 debug(3, 0) ("parse_peer: token='%s'\n", token
);
1691 if (peerFindByName(p
->name
))
1692 fatalf("ERROR: cache_peer %s specified twice\n", p
->name
);
1697 p
->icp
.version
= ICP_VERSION_CURRENT
;
1699 p
->tcp_up
= PEER_TCP_MAGIC_COUNT
;
1703 #if USE_CACHE_DIGESTS
1705 if (!p
->options
.no_digest
) {
1706 /* XXX This looks odd.. who has the original pointer
1709 PeerDigest
*pd
= peerDigestCreate(p
);
1710 p
->digest
= cbdataReference(pd
);
1716 p
->sslContext
= sslCreateClientContext(p
->sslcert
, p
->sslkey
, p
->sslversion
, p
->sslcipher
, p
->ssloptions
, p
->sslflags
, p
->sslcafile
, p
->sslcapath
);
1720 while (*head
!= NULL
)
1721 head
= &(*head
)->next
;
1731 free_peer(peer
** P
)
1735 while ((p
= *P
) != NULL
) {
1737 #if USE_CACHE_DIGESTS
1739 cbdataReferenceDone(p
->digest
);
1749 dump_cachemgrpasswd(StoreEntry
* entry
, const char *name
, cachemgr_passwd
* list
)
1753 while (list
!= NULL
) {
1754 if (strcmp(list
->passwd
, "none") && strcmp(list
->passwd
, "disable"))
1755 storeAppendPrintf(entry
, "%s XXXXXXXXXX", name
);
1757 storeAppendPrintf(entry
, "%s %s", name
, list
->passwd
);
1759 for (w
= list
->actions
; w
!= NULL
; w
= w
->next
) {
1760 storeAppendPrintf(entry
, " %s", w
->key
);
1763 storeAppendPrintf(entry
, "\n");
1769 parse_cachemgrpasswd(cachemgr_passwd
** head
)
1771 char *passwd
= NULL
;
1772 wordlist
*actions
= NULL
;
1774 cachemgr_passwd
**P
;
1775 parse_string(&passwd
);
1776 parse_wordlist(&actions
);
1777 p
= static_cast<cachemgr_passwd
*>(xcalloc(1, sizeof(cachemgr_passwd
)));
1779 p
->actions
= actions
;
1781 for (P
= head
; *P
; P
= &(*P
)->next
) {
1783 * See if any of the actions from this line already have a
1784 * password from previous lines. The password checking
1785 * routines in cache_manager.c take the the password from
1786 * the first cachemgr_passwd struct that contains the
1787 * requested action. Thus, we should warn users who might
1788 * think they can have two passwords for the same action.
1793 for (w
= (*P
)->actions
; w
; w
= w
->next
) {
1794 for (u
= actions
; u
; u
= u
->next
) {
1795 if (strcmp(w
->key
, u
->key
))
1798 debug(0, 0) ("WARNING: action '%s' (line %d) already has a password\n",
1799 u
->key
, config_lineno
);
1808 free_cachemgrpasswd(cachemgr_passwd
** head
)
1812 while ((p
= *head
) != NULL
) {
1815 wordlistDestroy(&p
->actions
);
1821 dump_denyinfo(StoreEntry
* entry
, const char *name
, acl_deny_info_list
* var
)
1825 while (var
!= NULL
) {
1826 storeAppendPrintf(entry
, "%s %s", name
, var
->err_page_name
);
1828 for (a
= var
->acl_list
; a
!= NULL
; a
= a
->next
)
1829 storeAppendPrintf(entry
, " %s", a
->name
);
1831 storeAppendPrintf(entry
, "\n");
1838 parse_denyinfo(acl_deny_info_list
** var
)
1840 aclParseDenyInfoLine(var
);
1844 free_denyinfo(acl_deny_info_list
** list
)
1846 acl_deny_info_list
*a
= NULL
;
1847 acl_deny_info_list
*a_next
= NULL
;
1848 acl_name_list
*l
= NULL
;
1849 acl_name_list
*l_next
= NULL
;
1851 for (a
= *list
; a
; a
= a_next
) {
1852 for (l
= a
->acl_list
; l
; l
= l_next
) {
1854 memFree(l
, MEM_ACL_NAME_LIST
);
1859 memFree(a
, MEM_ACL_DENY_INFO_LIST
);
1867 parse_peer_access(void)
1872 if (!(host
= strtok(NULL
, w_space
)))
1875 if ((p
= peerFindByName(host
)) == NULL
) {
1876 debug(15, 0) ("%s, line %d: No cache_peer '%s'\n",
1877 cfg_filename
, config_lineno
, host
);
1881 aclParseAccessLine(&p
->access
);
1885 parse_hostdomain(void)
1888 char *domain
= NULL
;
1890 if (!(host
= strtok(NULL
, w_space
)))
1893 while ((domain
= strtok(NULL
, list_sep
))) {
1894 domain_ping
*l
= NULL
;
1895 domain_ping
**L
= NULL
;
1898 if ((p
= peerFindByName(host
)) == NULL
) {
1899 debug(15, 0) ("%s, line %d: No cache_peer '%s'\n",
1900 cfg_filename
, config_lineno
, host
);
1904 l
= static_cast<domain_ping
*>(xcalloc(1, sizeof(domain_ping
)));
1907 if (*domain
== '!') { /* check for !.edu */
1912 l
->domain
= xstrdup(domain
);
1914 for (L
= &(p
->peer_domain
); *L
; L
= &((*L
)->next
))
1922 parse_hostdomaintype(void)
1926 char *domain
= NULL
;
1928 if (!(host
= strtok(NULL
, w_space
)))
1931 if (!(type
= strtok(NULL
, w_space
)))
1934 while ((domain
= strtok(NULL
, list_sep
))) {
1935 domain_type
*l
= NULL
;
1936 domain_type
**L
= NULL
;
1939 if ((p
= peerFindByName(host
)) == NULL
) {
1940 debug(15, 0) ("%s, line %d: No cache_peer '%s'\n",
1941 cfg_filename
, config_lineno
, host
);
1945 l
= static_cast<domain_type
*>(xcalloc(1, sizeof(domain_type
)));
1946 l
->type
= parseNeighborType(type
);
1947 l
->domain
= xstrdup(domain
);
1949 for (L
= &(p
->typelist
); *L
; L
= &((*L
)->next
))
1958 dump_ushortlist(StoreEntry
* entry
, const char *name
, ushortlist
* u
)
1961 storeAppendPrintf(entry
, "%s %d\n", name
, (int) u
->i
);
1967 check_null_ushortlist(ushortlist
* u
)
1973 parse_ushortlist(ushortlist
** P
)
1980 while ((token
= strtok(NULL
, w_space
))) {
1981 if (sscanf(token
, "%d", &i
) != 1)
1987 u
= xcalloc(1, sizeof(ushortlist
));
1991 for (U
= P
; *U
; U
= &(*U
)->next
)
1999 free_ushortlist(ushortlist
** P
)
2003 while ((u
= *P
) != NULL
) {
2012 dump_int(StoreEntry
* entry
, const char *name
, int var
)
2014 storeAppendPrintf(entry
, "%s %d\n", name
, var
);
2032 dump_onoff(StoreEntry
* entry
, const char *name
, int var
)
2034 storeAppendPrintf(entry
, "%s %s\n", name
, var
? "on" : "off");
2038 parse_onoff(int *var
)
2040 char *token
= strtok(NULL
, w_space
);
2045 if (!strcasecmp(token
, "on") || !strcasecmp(token
, "enable"))
2051 #define free_onoff free_int
2052 #define dump_eol dump_string
2053 #define free_eol free_string
2054 #define dump_debug dump_string
2055 #define free_debug free_string
2058 dump_refreshpattern(StoreEntry
* entry
, const char *name
, refresh_t
* head
)
2060 while (head
!= NULL
) {
2061 storeAppendPrintf(entry
, "%s%s %s %d %d%% %d\n",
2063 head
->flags
.icase
? " -i" : null_string
,
2065 (int) head
->min
/ 60,
2066 (int) (100.0 * head
->pct
+ 0.5),
2067 (int) head
->max
/ 60);
2070 if (head
->flags
.override_expire
)
2071 storeAppendPrintf(entry
, " override-expire");
2073 if (head
->flags
.override_lastmod
)
2074 storeAppendPrintf(entry
, " override-lastmod");
2076 if (head
->flags
.reload_into_ims
)
2077 storeAppendPrintf(entry
, " reload-into-ims");
2079 if (head
->flags
.ignore_reload
)
2080 storeAppendPrintf(entry
, " ignore-reload");
2082 if (head
->flags
.ignore_no_cache
)
2083 storeAppendPrintf(entry
, " ignore-no-cache");
2085 if (head
->flags
.ignore_no_store
)
2086 storeAppendPrintf(entry
, " ignore-no-store");
2088 if (head
->flags
.ignore_private
)
2089 storeAppendPrintf(entry
, " ignore-private");
2091 if (head
->flags
.ignore_auth
)
2092 storeAppendPrintf(entry
, " ignore-auth");
2096 storeAppendPrintf(entry
, "\n");
2103 parse_refreshpattern(refresh_t
** head
)
2112 int override_expire
= 0;
2113 int override_lastmod
= 0;
2114 int reload_into_ims
= 0;
2115 int ignore_reload
= 0;
2116 int ignore_no_cache
= 0;
2117 int ignore_no_store
= 0;
2118 int ignore_private
= 0;
2119 int ignore_auth
= 0;
2126 int flags
= REG_EXTENDED
| REG_NOSUB
;
2128 if ((token
= strtok(NULL
, w_space
)) == NULL
)
2131 if (strcmp(token
, "-i") == 0) {
2133 token
= strtok(NULL
, w_space
);
2134 } else if (strcmp(token
, "+i") == 0) {
2135 flags
&= ~REG_ICASE
;
2136 token
= strtok(NULL
, w_space
);
2142 pattern
= xstrdup(token
);
2144 i
= GetInteger(); /* token: min */
2146 min
= (time_t) (i
* 60); /* convert minutes to seconds */
2148 i
= GetInteger(); /* token: pct */
2150 pct
= (double) i
/ 100.0;
2152 i
= GetInteger(); /* token: max */
2154 max
= (time_t) (i
* 60); /* convert minutes to seconds */
2157 while ((token
= strtok(NULL
, w_space
)) != NULL
) {
2160 if (!strcmp(token
, "override-expire"))
2161 override_expire
= 1;
2162 else if (!strcmp(token
, "override-lastmod"))
2163 override_lastmod
= 1;
2164 else if (!strcmp(token
, "ignore-no-cache"))
2165 ignore_no_cache
= 1;
2166 else if (!strcmp(token
, "ignore-no-store"))
2167 ignore_no_store
= 1;
2168 else if (!strcmp(token
, "ignore-private"))
2170 else if (!strcmp(token
, "ignore-auth"))
2172 else if (!strcmp(token
, "reload-into-ims")) {
2173 reload_into_ims
= 1;
2174 refresh_nocache_hack
= 1;
2175 /* tell client_side.c that this is used */
2176 } else if (!strcmp(token
, "ignore-reload")) {
2178 refresh_nocache_hack
= 1;
2179 /* tell client_side.c that this is used */
2183 debug(22, 0) ("redreshAddToList: Unknown option '%s': %s\n",
2187 if ((errcode
= regcomp(&comp
, pattern
, flags
)) != 0) {
2189 regerror(errcode
, &comp
, errbuf
, sizeof errbuf
);
2190 debug(22, 0) ("%s line %d: %s\n",
2191 cfg_filename
, config_lineno
, config_input_line
);
2192 debug(22, 0) ("refreshAddToList: Invalid regular expression '%s': %s\n",
2197 pct
= pct
< 0.0 ? 0.0 : pct
;
2198 max
= max
< 0 ? 0 : max
;
2199 t
= static_cast<refresh_t
*>(xcalloc(1, sizeof(refresh_t
)));
2200 t
->pattern
= (char *) xstrdup(pattern
);
2201 t
->compiled_pattern
= comp
;
2206 if (flags
& REG_ICASE
)
2211 if (override_expire
)
2212 t
->flags
.override_expire
= 1;
2214 if (override_lastmod
)
2215 t
->flags
.override_lastmod
= 1;
2217 if (reload_into_ims
)
2218 t
->flags
.reload_into_ims
= 1;
2221 t
->flags
.ignore_reload
= 1;
2223 if (ignore_no_cache
)
2224 t
->flags
.ignore_no_cache
= 1;
2226 if (ignore_no_store
)
2227 t
->flags
.ignore_no_store
= 1;
2230 t
->flags
.ignore_private
= 1;
2233 t
->flags
.ignore_auth
= 1;
2240 head
= &(*head
)->next
;
2249 check_null_refreshpattern(refresh_t
* data
)
2251 return data
== NULL
;
2257 free_refreshpattern(refresh_t
** head
)
2261 while ((t
= *head
) != NULL
) {
2263 safe_free(t
->pattern
);
2264 regfree(&t
->compiled_pattern
);
2270 dump_string(StoreEntry
* entry
, const char *name
, char *var
)
2273 storeAppendPrintf(entry
, "%s %s\n", name
, var
);
2277 parse_string(char **var
)
2279 char *token
= strtok(NULL
, w_space
);
2285 *var
= xstrdup(token
);
2289 free_string(char **var
)
2295 parse_eol(char *volatile *var
)
2297 unsigned char *token
= (unsigned char *) strtok(NULL
, null_string
);
2303 while (*token
&& isspace(*token
))
2309 *var
= xstrdup((char *) token
);
2313 parse_debug(char *volatile *var
)
2316 safe_free(debug_options
)
2317 debug_options
= xstrdup(Config
.debugOptions
);
2318 Debug::parseOptions(Config
.debugOptions
);
2322 dump_time_t(StoreEntry
* entry
, const char *name
, time_t var
)
2324 storeAppendPrintf(entry
, "%s %d seconds\n", name
, (int) var
);
2328 parse_time_t(time_t * var
)
2330 parseTimeLine(var
, T_SECOND_STR
);
2334 free_time_t(time_t * var
)
2340 dump_size_t(StoreEntry
* entry
, const char *name
, size_t var
)
2342 storeAppendPrintf(entry
, "%s %d\n", name
, (int) var
);
2346 dump_b_size_t(StoreEntry
* entry
, const char *name
, size_t var
)
2348 storeAppendPrintf(entry
, "%s %d %s\n", name
, (int) var
, B_BYTES_STR
);
2352 dump_kb_size_t(StoreEntry
* entry
, const char *name
, size_t var
)
2354 storeAppendPrintf(entry
, "%s %d %s\n", name
, (int) var
, B_KBYTES_STR
);
2358 parse_size_t(size_t * var
)
2366 parse_b_size_t(size_t * var
)
2368 parseBytesLine(var
, B_BYTES_STR
);
2372 parse_kb_size_t(size_t * var
)
2374 parseBytesLine(var
, B_KBYTES_STR
);
2378 free_size_t(size_t * var
)
2383 #define free_b_size_t free_size_t
2384 #define free_kb_size_t free_size_t
2385 #define free_mb_size_t free_size_t
2386 #define free_gb_size_t free_size_t
2389 dump_ushort(StoreEntry
* entry
, const char *name
, u_short var
)
2391 storeAppendPrintf(entry
, "%s %d\n", name
, var
);
2395 free_ushort(u_short
* u
)
2401 parse_ushort(u_short
* var
)
2403 ConfigParser::ParseUShort(var
);
2407 ConfigParser::ParseUShort(u_short
*var
)
2420 dump_wordlist(StoreEntry
* entry
, const char *name
, wordlist
* list
)
2422 while (list
!= NULL
) {
2423 storeAppendPrintf(entry
, "%s %s\n", name
, list
->key
);
2429 parse_wordlist(wordlist
** list
)
2432 char *t
= strtok(NULL
, "");
2434 while ((token
= strwordtok(NULL
, &t
)))
2435 wordlistAdd(list
, token
);
2439 check_null_wordlist(wordlist
* w
)
2445 check_null_acl_access(acl_access
* a
)
2450 #define free_wordlist wordlistDestroy
2452 #define free_uri_whitespace free_int
2455 parse_uri_whitespace(int *var
)
2457 char *token
= strtok(NULL
, w_space
);
2462 if (!strcasecmp(token
, "strip"))
2463 *var
= URI_WHITESPACE_STRIP
;
2464 else if (!strcasecmp(token
, "deny"))
2465 *var
= URI_WHITESPACE_DENY
;
2466 else if (!strcasecmp(token
, "allow"))
2467 *var
= URI_WHITESPACE_ALLOW
;
2468 else if (!strcasecmp(token
, "encode"))
2469 *var
= URI_WHITESPACE_ENCODE
;
2470 else if (!strcasecmp(token
, "chop"))
2471 *var
= URI_WHITESPACE_CHOP
;
2478 dump_uri_whitespace(StoreEntry
* entry
, const char *name
, int var
)
2482 if (var
== URI_WHITESPACE_ALLOW
)
2484 else if (var
== URI_WHITESPACE_ENCODE
)
2486 else if (var
== URI_WHITESPACE_CHOP
)
2488 else if (var
== URI_WHITESPACE_DENY
)
2493 storeAppendPrintf(entry
, "%s %s\n", name
, s
);
2497 free_removalpolicy(RemovalPolicySettings
** settings
)
2502 free_string(&(*settings
)->type
);
2504 free_wordlist(&(*settings
)->args
);
2512 parse_removalpolicy(RemovalPolicySettings
** settings
)
2515 free_removalpolicy(settings
);
2517 *settings
= static_cast<RemovalPolicySettings
*>(xcalloc(1, sizeof(**settings
)));
2519 parse_string(&(*settings
)->type
);
2521 parse_wordlist(&(*settings
)->args
);
2525 dump_removalpolicy(StoreEntry
* entry
, const char *name
, RemovalPolicySettings
* settings
)
2528 storeAppendPrintf(entry
, "%s %s", name
, settings
->type
);
2529 args
= settings
->args
;
2532 storeAppendPrintf(entry
, " %s", args
->key
);
2536 storeAppendPrintf(entry
, "\n");
2540 #include "cf_parser.h"
2543 parseNeighborType(const char *s
)
2545 if (!strcasecmp(s
, "parent"))
2548 if (!strcasecmp(s
, "neighbor"))
2549 return PEER_SIBLING
;
2551 if (!strcasecmp(s
, "neighbour"))
2552 return PEER_SIBLING
;
2554 if (!strcasecmp(s
, "sibling"))
2555 return PEER_SIBLING
;
2557 if (!strcasecmp(s
, "multicast"))
2558 return PEER_MULTICAST
;
2560 debug(15, 0) ("WARNING: Unknown neighbor type: %s\n", s
);
2562 return PEER_SIBLING
;
2565 #if CURRENTLY_UNUSED
2566 /* This code was previously used by http_port. Left as it really should
2567 * be used by icp_port and htcp_port
2570 parse_sockaddr_in_list_token(sockaddr_in_list
** head
, char *token
)
2575 const struct hostent
*hp
;
2576 unsigned short port
;
2577 sockaddr_in_list
*s
;
2582 if ((t
= strchr(token
, ':'))) {
2586 port
= (unsigned short) xatoi(t
+ 1);
2590 } else if ((port
= xatoi(token
)) > 0) {
2596 s
= static_cast<sockaddr_in_list
*>(xcalloc(1, sizeof(*s
)));
2597 s
->s
.sin_port
= htons(port
);
2600 s
->s
.sin_addr
= any_addr
;
2601 else if (1 == safe_inet_addr(host
, &s
->s
.sin_addr
))
2603 else if ((hp
= gethostbyname(host
))) /* dont use ipcache */
2604 s
->s
.sin_addr
= inaddrFromHostent(hp
);
2609 head
= &(*head
)->next
;
2615 parse_sockaddr_in_list(sockaddr_in_list
** head
)
2619 while ((token
= strtok(NULL
, w_space
))) {
2620 parse_sockaddr_in_list_token(head
, token
);
2625 dump_sockaddr_in_list(StoreEntry
* e
, const char *n
, const sockaddr_in_list
* s
)
2628 storeAppendPrintf(e
, "%s %s:%d\n",
2630 inet_ntoa(s
->s
.sin_addr
),
2631 ntohs(s
->s
.sin_port
));
2637 free_sockaddr_in_list(sockaddr_in_list
** head
)
2639 sockaddr_in_list
*s
;
2641 while ((s
= *head
) != NULL
) {
2648 check_null_sockaddr_in_list(const sockaddr_in_list
* s
)
2653 #endif /* CURRENTLY_UNUSED */
2656 parse_http_port_specification(http_port_list
* s
, char *token
)
2660 const struct hostent
*hp
;
2661 unsigned short port
= 0;
2664 if ((t
= strchr(token
, ':'))) {
2668 port
= (unsigned short) atoi(t
+ 1);
2672 } else if ((port
= atoi(token
)) > 0) {
2678 s
->s
.sin_port
= htons(port
);
2681 s
->s
.sin_addr
= any_addr
;
2682 else if (1 == safe_inet_addr(host
, &s
->s
.sin_addr
))
2684 else if ((hp
= gethostbyname(host
))) {
2685 /* dont use ipcache */
2686 s
->s
.sin_addr
= inaddrFromHostent(hp
);
2687 s
->defaultsite
= xstrdup(host
);
2693 parse_http_port_option(http_port_list
* s
, char *token
)
2695 if (strncmp(token
, "defaultsite=", 12) == 0) {
2696 safe_free(s
->defaultsite
);
2697 s
->defaultsite
= xstrdup(token
+ 12);
2699 } else if (strncmp(token
, "name=", 5) == 0) {
2701 s
->name
= xstrdup(token
+ 5);
2702 } else if (strcmp(token
, "transparent") == 0) {
2704 } else if (strcmp(token
, "vhost") == 0) {
2707 } else if (strcmp(token
, "vport") == 0) {
2710 } else if (strncmp(token
, "vport=", 6) == 0) {
2711 s
->vport
= atoi(token
+ 6);
2713 } else if (strncmp(token
, "protocol=", 9) == 0) {
2714 s
->protocol
= xstrdup(token
+ 9);
2716 } else if (strcmp(token
, "accel") == 0) {
2724 free_generic_http_port_data(http_port_list
* s
)
2727 safe_free(s
->defaultsite
);
2731 cbdataFree_http_port(void *data
)
2733 free_generic_http_port_data((http_port_list
*)data
);
2737 static http_port_list
*
2738 create_http_port(char *portspec
)
2740 CBDATA_TYPE(http_port_list
);
2741 CBDATA_INIT_TYPE_FREECB(http_port_list
, cbdataFree_http_port
);
2743 http_port_list
*s
= cbdataAlloc(http_port_list
);
2744 s
->protocol
= xstrdup("http");
2745 parse_http_port_specification(s
, portspec
);
2750 add_http_port(char *portspec
)
2752 http_port_list
*s
= create_http_port(portspec
);
2753 s
->next
= Config
.Sockaddr
.http
;
2754 Config
.Sockaddr
.http
= s
;
2758 parse_http_port_list(http_port_list
** head
)
2760 char *token
= strtok(NULL
, w_space
);
2765 http_port_list
*s
= create_http_port(token
);
2767 /* parse options ... */
2768 while ((token
= strtok(NULL
, w_space
))) {
2769 parse_http_port_option(s
, token
);
2773 head
= &(*head
)->next
;
2779 dump_generic_http_port(StoreEntry
* e
, const char *n
, const http_port_list
* s
)
2781 storeAppendPrintf(e
, "%s %s:%d",
2783 inet_ntoa(s
->s
.sin_addr
),
2784 ntohs(s
->s
.sin_port
));
2787 storeAppendPrintf(e
, " defaultsite=%s", s
->defaultsite
);
2790 storeAppendPrintf(e
, " transparent");
2793 storeAppendPrintf(e
, " vhost");
2796 storeAppendPrintf(e
, " vport");
2800 dump_http_port_list(StoreEntry
* e
, const char *n
, const http_port_list
* s
)
2803 dump_generic_http_port(e
, n
, s
);
2804 storeAppendPrintf(e
, "\n");
2810 free_http_port_list(http_port_list
** head
)
2814 while ((s
= *head
) != NULL
) {
2822 check_null_http_port_list(const http_port_list
* s
)
2831 cbdataFree_https_port(void *data
)
2833 https_port_list
*s
= (https_port_list
*)data
;
2834 free_generic_http_port_data(&s
->http
);
2840 parse_https_port_list(https_port_list
** head
)
2842 CBDATA_TYPE(https_port_list
);
2845 CBDATA_INIT_TYPE_FREECB(https_port_list
, cbdataFree_https_port
);
2846 token
= strtok(NULL
, w_space
);
2851 s
= cbdataAlloc(https_port_list
);
2853 s
->http
.protocol
= xstrdup("https");
2855 parse_http_port_specification(&s
->http
, token
);
2857 /* parse options ... */
2858 while ((token
= strtok(NULL
, w_space
))) {
2859 if (strncmp(token
, "cert=", 5) == 0) {
2861 s
->cert
= xstrdup(token
+ 5);
2862 } else if (strncmp(token
, "key=", 4) == 0) {
2864 s
->key
= xstrdup(token
+ 4);
2865 } else if (strncmp(token
, "version=", 8) == 0) {
2866 s
->version
= xatoi(token
+ 8);
2867 } else if (strncmp(token
, "options=", 8) == 0) {
2868 safe_free(s
->options
);
2869 s
->options
= xstrdup(token
+ 8);
2870 } else if (strncmp(token
, "cipher=", 7) == 0) {
2871 safe_free(s
->cipher
);
2872 s
->cipher
= xstrdup(token
+ 7);
2873 } else if (strncmp(token
, "clientca=", 9) == 0) {
2874 safe_free(s
->clientca
);
2875 s
->clientca
= xstrdup(token
+ 9);
2876 } else if (strncmp(token
, "cafile=", 7) == 0) {
2877 safe_free(s
->cafile
);
2878 s
->cafile
= xstrdup(token
+ 7);
2879 } else if (strncmp(token
, "capath=", 7) == 0) {
2880 safe_free(s
->capath
);
2881 s
->capath
= xstrdup(token
+ 7);
2882 } else if (strncmp(token
, "dhparams=", 9) == 0) {
2883 safe_free(s
->dhfile
);
2884 s
->dhfile
= xstrdup(token
+ 9);
2885 } else if (strncmp(token
, "sslflags=", 9) == 0) {
2886 safe_free(s
->sslflags
);
2887 s
->sslflags
= xstrdup(token
+ 9);
2889 parse_http_port_option(&s
->http
, token
);
2893 s
->sslContext
= sslCreateServerContext(s
->cert
, s
->key
, s
->version
, s
->cipher
, s
->options
, s
->sslflags
, s
->clientca
, s
->cafile
, s
->capath
, s
->dhfile
);
2899 head
= (https_port_list
**)&(*head
)->http
.next
;
2905 dump_https_port_list(StoreEntry
* e
, const char *n
, const https_port_list
* s
)
2908 dump_generic_http_port(e
, n
, &s
->http
);
2911 storeAppendPrintf(e
, " cert=%s", s
->cert
);
2914 storeAppendPrintf(e
, " key=%s", s
->cert
);
2917 storeAppendPrintf(e
, " version=%d", s
->version
);
2920 storeAppendPrintf(e
, " options=%s", s
->options
);
2923 storeAppendPrintf(e
, " cipher=%s", s
->cipher
);
2926 storeAppendPrintf(e
, " cafile=%s", s
->cafile
);
2929 storeAppendPrintf(e
, " capath=%s", s
->capath
);
2932 storeAppendPrintf(e
, " dhparams=%s", s
->dhfile
);
2935 storeAppendPrintf(e
, " sslflags=%s", s
->sslflags
);
2937 storeAppendPrintf(e
, "\n");
2939 s
= (https_port_list
*) s
->http
.next
;
2944 free_https_port_list(https_port_list
** head
)
2948 while ((s
= *head
) != NULL
) {
2949 *head
= (https_port_list
*) s
->http
.next
;
2956 check_null_https_port_list(const https_port_list
* s
)
2963 #endif /* USE_SSL */
2966 configFreeMemory(void)
2972 requirePathnameExists(const char *name
, const char *path
)
2976 char pathbuf
[BUFSIZ
];
2977 assert(path
!= NULL
);
2979 if (Config
.chroot_dir
) {
2980 snprintf(pathbuf
, BUFSIZ
, "%s/%s", Config
.chroot_dir
, path
);
2984 if (stat(path
, &sb
) < 0)
2985 fatalf("%s %s: %s", name
, path
, xstrerror());
2991 static int fromFile
= 0;
2992 static FILE *wordFile
= NULL
;
2995 LOCAL_ARRAY(char, buf
, 256);
3000 t
= (strtok(NULL
, w_space
));
3002 if (!t
|| *t
== '#') {
3004 } else if (*t
== '\"' || *t
== '\'') {
3005 /* quote found, start reading from file */
3008 while (*t
&& *t
!= '\"' && *t
!= '\'')
3013 if ((wordFile
= fopen(fn
, "r")) == NULL
) {
3014 debug(28, 0) ("strtokFile: %s not found\n", fn
);
3018 #ifdef _SQUID_WIN32_
3019 setmode(fileno(wordFile
), O_TEXT
);
3030 if (fgets(buf
, 256, wordFile
) == NULL
) {
3031 /* stop reading from file */
3039 /* skip leading and trailing white space */
3040 t
+= strspn(buf
, w_space
);
3041 t2
= t
+ strcspn(t
, w_space
);
3042 t3
= t2
+ strspn(t2
, w_space
);
3044 while (*t3
&& *t3
!= '#') {
3045 t2
= t3
+ strcspn(t3
, w_space
);
3046 t3
= t2
+ strspn(t2
, w_space
);
3055 /* skip blank lines */
3063 #include "AccessLogEntry.h"
3064 /* TODO: split out parsing somehow ...*/
3066 parse_logformat(logformat
** logformat_definitions
)
3071 if ((name
= strtok(NULL
, w_space
)) == NULL
)
3074 if ((def
= strtok(NULL
, "\r\n")) == NULL
)
3077 debug(3, 1) ("Logformat for '%s' is '%s'\n", name
, def
);
3079 nlf
= (logformat
*)xcalloc(1, sizeof(logformat
));
3081 nlf
->name
= xstrdup(name
);
3083 if (!accessLogParseLogFormat(&nlf
->format
, def
))
3086 nlf
->next
= *logformat_definitions
;
3088 *logformat_definitions
= nlf
;
3092 parse_access_log(customlog
** logs
)
3094 const char *filename
, *logdef_name
;
3098 cl
= (customlog
*)xcalloc(1, sizeof(*cl
));
3100 if ((filename
= strtok(NULL
, w_space
)) == NULL
)
3103 if (strcmp(filename
, "none") == 0) {
3104 cl
->type
= CLF_NONE
;
3108 if ((logdef_name
= strtok(NULL
, w_space
)) == NULL
)
3109 logdef_name
= "auto";
3111 debug(3, 9) ("Log definition name '%s' file '%s'\n", logdef_name
, filename
);
3113 cl
->filename
= xstrdup(filename
);
3115 /* look for the definition pointer corresponding to this name */
3116 lf
= Config
.Log
.logformats
;
3118 while (lf
!= NULL
) {
3119 debug(3, 9) ("Comparing against '%s'\n", lf
->name
);
3121 if (strcmp(lf
->name
, logdef_name
) == 0)
3128 cl
->type
= CLF_CUSTOM
;
3130 } else if (strcmp(logdef_name
, "auto") == 0) {
3131 cl
->type
= CLF_AUTO
;
3132 } else if (strcmp(logdef_name
, "squid") == 0) {
3133 cl
->type
= CLF_SQUID
;
3134 } else if (strcmp(logdef_name
, "common") == 0) {
3135 cl
->type
= CLF_COMMON
;
3137 debug(3, 0) ("Log format '%s' is not defined\n", logdef_name
);
3142 aclParseAclList(&cl
->aclList
);
3145 logs
= &(*logs
)->next
;
3151 check_null_access_log(customlog
*customlog_definitions
)
3153 return customlog_definitions
== NULL
;
3157 dump_logformat(StoreEntry
* entry
, const char *name
, logformat
* definitions
)
3159 accessLogDumpLogFormat(entry
, name
, definitions
);
3163 dump_access_log(StoreEntry
* entry
, const char *name
, customlog
* logs
)
3167 for (log
= logs
; log
; log
= log
->next
) {
3168 storeAppendPrintf(entry
, "%s ", name
);
3170 switch (log
->type
) {
3173 storeAppendPrintf(entry
, "%s %s", log
->filename
, log
->logFormat
->name
);
3177 storeAppendPrintf(entry
, "none");
3181 storeAppendPrintf(entry
, "%s squid", log
->filename
);
3185 storeAppendPrintf(entry
, "%s squid", log
->filename
);
3191 storeAppendPrintf(entry
, "%s auto", log
->filename
);
3193 storeAppendPrintf(entry
, "%s", log
->filename
);
3202 dump_acl_list(entry
, log
->aclList
);
3204 storeAppendPrintf(entry
, "\n");
3209 free_logformat(logformat
** definitions
)
3211 while (*definitions
) {
3212 logformat
*format
= *definitions
;
3213 *definitions
= format
->next
;
3214 accessLogFreeLogFormat(&format
->format
);
3220 free_access_log(customlog
** definitions
)
3222 while (*definitions
) {
3223 customlog
*log
= *definitions
;
3224 *definitions
= log
->next
;
3226 log
->logFormat
= NULL
;
3227 log
->type
= CLF_UNKNOWN
;
3230 aclDestroyAclList(&log
->aclList
);
3232 safe_free(log
->filename
);