/*
- * $Id: acl.cc,v 1.283 2002/09/05 21:09:23 hno Exp $
+ * $Id: acl.cc,v 1.284 2002/09/07 15:12:55 hno Exp $
*
* DEBUG: section 28 Access Control
* AUTHOR: Duane Wessels
#include "squid.h"
#include "splay.h"
-static int aclFromFile = 0;
-static FILE *aclFile;
-
static void aclParseDomainList(void *curlist);
static void aclParseUserList(void **current);
static void aclParseIpList(void *curlist);
static void aclParseMethodList(void *curlist);
static void aclParseTimeSpec(void *curlist);
static void aclParseIntRange(void *curlist);
-extern char *strtokFile(void);
static void aclDestroyTimeList(acl_time_data * data);
static void aclDestroyIntRange(intrange *);
static void aclLookupProxyAuthStart(aclCheck_t * checklist);
#endif
static int aclCacheMatchAcl(dlink_list * cache, squid_acl acltype, void *data, char *MatchParam);
-char *
-strtokFile(void)
-{
- char *t, *fn;
- LOCAL_ARRAY(char, buf, 256);
-
- strtok_again:
- if (!aclFromFile) {
- t = (strtok(NULL, w_space));
- if (!t || *t == '#') {
- return NULL;
- } else if (*t == '\"' || *t == '\'') {
- /* quote found, start reading from file */
- fn = ++t;
- while (*t && *t != '\"' && *t != '\'')
- t++;
- *t = '\0';
- if ((aclFile = fopen(fn, "r")) == NULL) {
- debug(28, 0) ("strtokFile: %s not found\n", fn);
- return (NULL);
- }
-#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
- setmode(fileno(aclFile), O_TEXT);
-#endif
- aclFromFile = 1;
- } else {
- return t;
- }
- }
- /* aclFromFile */
- if (fgets(buf, 256, aclFile) == NULL) {
- /* stop reading from file */
- fclose(aclFile);
- aclFromFile = 0;
- goto strtok_again;
- } else {
- t = buf;
- /* skip leading and trailing white space */
- t += strspn(buf, w_space);
- t[strcspn(t, w_space)] = '\0';
- /* skip comments */
- if (*t == '#')
- goto strtok_again;
- /* skip blank lines */
- if (!*t)
- goto strtok_again;
- return t;
- }
-}
-
static squid_acl
aclStrToType(const char *s)
{
/*
- * $Id: cache_cf.cc,v 1.413 2002/09/07 15:02:24 hno Exp $
+ * $Id: cache_cf.cc,v 1.414 2002/09/07 15:12:56 hno Exp $
*
* DEBUG: section 3 Configuration File Parsing
* AUTHOR: Harvest Derived
char *
strtokFile(void)
{
+ static int fromFile = 0;
+ static FILE *wordFile = NULL;
+
char *t, *fn;
LOCAL_ARRAY(char, buf, 256);
strtok_again:
- if (!aclFromFile) {
+ if (!fromFile) {
t = (strtok(NULL, w_space));
if (!t || *t == '#') {
return NULL;
while (*t && *t != '\"' && *t != '\'')
t++;
*t = '\0';
- if ((aclFile = fopen(fn, "r")) == NULL) {
+ if ((wordFile = fopen(fn, "r")) == NULL) {
debug(28, 0) ("strtokFile: %s not found\n", fn);
return (NULL);
}
#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_)
- setmode(fileno(aclFile), O_TEXT);
+ setmode(fileno(wordFile), O_TEXT);
#endif
- aclFromFile = 1;
+ fromFile = 1;
} else {
return t;
}
}
- /* aclFromFile */
- if (fgets(buf, 256, aclFile) == NULL) {
+ /* fromFile */
+ if (fgets(buf, 256, wordFile) == NULL) {
/* stop reading from file */
- fclose(aclFile);
- aclFromFile = 0;
+ fclose(wordFile);
+ wordFile = NULL;
+ fromFile = 0;
goto strtok_again;
} else {
t = buf;
/*
- * $Id: protos.h,v 1.443 2002/09/07 14:55:24 hno Exp $
+ * $Id: protos.h,v 1.444 2002/09/07 15:12:56 hno Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
extern void parseEtcHosts(void);
extern int getMyPort(void);
-static void strwordquote(MemBuf * mb, const char *str);
+char *strwordtok(char *buf, char **t);
void strwordquote(MemBuf * mb, const char *str);
#if USE_HTCP
/*
- * $Id: tools.cc,v 1.222 2002/09/07 14:55:24 hno Exp $
+ * $Id: tools.cc,v 1.223 2002/09/07 15:12:56 hno Exp $
*
* DEBUG: section 21 Misc Functions
* AUTHOR: Harvest Derived
* Similar to strtok, but has some rudimentary knowledge
* of quoting
*/
-static char *
+char *
strwordtok(char *buf, char **t)
{
unsigned char *word = NULL;
/*
* Inverse of strwordtok. Quotes a word if needed
*/
-static void
+void
strwordquote(MemBuf * mb, const char *str)
{
int quoted = 0;