--------------------- PatchSet 1808 Date: 2001/04/04 21:50:21 Author: rbcollins Branch: generic_modules Tag: (none) Log: parse multiple directives on a single line ie parent option1 value option2 value Members: src/acl.c:1.21.4.4->1.21.4.5 src/cache_cf.c:1.18.4.21->1.18.4.22 Index: squid/src/acl.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/acl.c,v retrieving revision 1.21.4.4 retrieving revision 1.21.4.5 diff -u -r1.21.4.4 -r1.21.4.5 --- squid/src/acl.c 31 Mar 2001 11:07:22 -0000 1.21.4.4 +++ squid/src/acl.c 4 Apr 2001 21:50:21 -0000 1.21.4.5 @@ -1,6 +1,6 @@ /* - * $Id: acl.c,v 1.21.4.4 2001/03/31 11:07:22 rbcollins Exp $ + * $Id: acl.c,v 1.21.4.5 2001/04/04 21:50:21 rbcollins Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -2038,6 +2038,15 @@ } static void +aclDestroyIpList(parserNameNode *parserName, void * data) +{ + acl ** head=(acl **)data; + acl *a=*head; + if (a) + splay_destroy(a->data,aclFreeIpData); +} + +static void aclFreeUserData(void *data) { acl_user_data *d = data; @@ -2463,6 +2472,29 @@ return NULL; } +static void +dump_IpList(StoreEntry * entry, const char *name, void const * const data) +{ + acl * ae=*(acl * *)data; + wordlist *w; + wordlist *v; + while (ae != NULL) { + debug(3, 3) ("dump_IpList: %s %s\n", name, ae->name); + v = w = aclDumpIpList(ae->data); + while (v != NULL) { + debug(3, 3) ("dump_IpList: %s %s %s\n", name, ae->name, v->key); + storeAppendPrintf(entry, "%s %s %s %s\n", + name, + ae->name, + aclTypeToStr(ae->type), + v->key); + v = v->next; + } + wordlistDestroy(&w); + ae = ae->next; + } +} + /* * This function traverses all ACL elements referenced * by an access list (presumably 'http_access'). If @@ -3037,9 +3069,14 @@ void aclParserRegister(void) { + /* register the ACL types */ + parserRegisterType("iplist", aclParseIpList, aclDestroyIpList, dump_IpList ); +// aclParseIpList(&A->data);aclParseDomainList(&A->data);aclParseTimeSpec(&A->data); + if (aclinstances) - debug(3,0)("bwahhahhahaha\n\n"); + debug(3,0)("reconfiguring is broken just now!!! \n\n"); + /* this creates a hierarchical branch */ aclinstances = parserRegisterInstanceName("acl", parserTypeByName("acl"), NULL, NULL); - + /* this registers the hierarchical branch as "acl" */ parserRegisterName(NULL, "acl", parserTypeByName("instance_node"), aclinstances, default_if_none_acl, name_document_acl, NULL); } Index: squid/src/cache_cf.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/cache_cf.c,v retrieving revision 1.18.4.21 retrieving revision 1.18.4.22 diff -u -r1.18.4.21 -r1.18.4.22 --- squid/src/cache_cf.c 31 Mar 2001 11:07:22 -0000 1.18.4.21 +++ squid/src/cache_cf.c 4 Apr 2001 21:50:21 -0000 1.18.4.22 @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.c,v 1.18.4.21 2001/03/31 11:07:22 rbcollins Exp $ + * $Id: cache_cf.c,v 1.18.4.22 2001/04/04 21:50:21 rbcollins Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -2906,6 +2906,7 @@ default_line(const char *s) { LOCAL_ARRAY(char, tmp_line, BUFSIZ); + memset(tmp_line, '\0', BUFSIZ); xstrncpy(tmp_line, s, BUFSIZ); xstrncpy(config_input_line, s, BUFSIZ); config_lineno++; @@ -2913,27 +2914,51 @@ } static int +peek_line(char *current_token) +{ + char *token; + char saved; + saved=current_token[strlen(current_token)-1]; + if ((token = strtok(NULL, w_space)) == NULL) + /* Fail if no more tokens on this line */ + return 0; + debug(3,8)("next token %s\n",token); + /* back up strtok a step. Yummy */ + *(token + strlen(token))=' '; + *(token-2) = saved; + *(token-1) = ' '; + strtok(token-2,w_space); + return 1; +} + +static int parse_directive(parserNameNode *parent) { char *token; parserNameNode *parserName; if ((token = strtok(NULL, w_space)) == NULL) return 0; /* fail on directives with no data */ - debug(0,0)("parse_directive: %s\n", token); - if ((parserName=parserNameByNodeName(parent ? &parent->children : &parserNames, token))==NULL) { - /* unregistered child, parse as normal. */ - /* back up strtok a step. Yummy */ - *(token + strlen(token))=' '; - *(token-2) = 'A'; - *(token-1) = ' '; - strtok(token-2,w_space); - parent->type->parsefunc(parent, parent->location); - return 1; - } else { - /* registered child node */ - parserName->type->parsefunc(parserName, parserName->location); - return 1; + while (peek_line(token)) { + debug(0,0)("parse_directive: %s\n", token); + if ((parserName=parserNameByNodeName(parent ? &parent->children : &parserNames, token))==NULL) { + /* unregistered child, parse as normal. */ + /* back up strtok a step. Yummy */ + *(token + strlen(token))=' '; + *(token-2) = 'A'; + *(token-1) = ' '; + strtok(token-2,w_space); + parent->type->parsefunc(parent, parent->location); + if ((token = strtok(NULL, w_space)) == NULL) + return 1; /* finish at end of the line */ + } else { + /* registered child node */ + parserName->type->parsefunc(parserName, parserName->location); + if ((token = strtok(NULL, w_space)) == NULL) + return 1; /* finish at end of the line */ + } } + /* unreached */ + return 1; } static int