The ConfigParser::strtokFile() methods added by rev.12620 use
an undo mechanism to pull the next token if anything has been
undone.
The new parseFlags() method also added in that revision uses
the undo mechanism for any token which is not a flag token
it also returns the token in its nextToken parameter.
In ACLIP the data parser uses parseFlags() and the nextToken
received then goes on to use strtokFile() and the undo copy
of that same token. The result being that all dst/src ACLs
had a double-entry for the first IP address tokens.
Since IP address tokens are de-duplicated with loud WARNING
on -k parse this was resulting in confusing noise from the
built-in ACL definitions.
Since parseFlags() is so new and ACLIP was the only user of the
nextToken parameter we can drop it entirely and rely on only
ConfigParser undo mechanism from now on.
}
void
-ACLFlags::parseFlags(char * &nextToken)
+ACLFlags::parseFlags()
{
+ char *nextToken;
while ((nextToken = ConfigParser::strtokFile()) != NULL && nextToken[0] == '-') {
//if token is the "--" break flag
*/
AclMatchedName = A->name; /* ugly */
- char *aTok;
- A->flags.parseFlags(aTok);
+ A->flags.parseFlags();
/*split the function here */
A->parse();
void makeSet(const ACLFlag f) { flags_ |= flagToInt(f); } ///< Set the given flag
/// Return true if the given flag is set
bool isSet(const ACLFlag f) const { return flags_ & flagToInt(f);}
- /// Parse a flags given in the form -[A..Z|a..z]
- void parseFlags(char * &nextToken);
+ /// Parse optional flags given in the form -[A..Z|a..z]
+ void parseFlags();
const char *flagsStr() const; ///< Convert the flags to a string representation
private:
void
ACLIP::parse()
{
- char *t = NULL;
+ flags.parseFlags();
- flags.parseFlags(t);
-
- if (!t)
- return;
-
- do {
+ while (char *t = strtokFile()) {
acl_ip_data *q = acl_ip_data::FactoryParse(t);
while (q != NULL) {
data = data->insert(q, acl_ip_data::NetworkCompare);
q = next_node;
}
- } while ((t = strtokFile()));
+ }
}
ACLIP::~ACLIP()