9#ifndef SQUID_SRC_CONFIGPARSER_H
10#define SQUID_SRC_CONFIGPARSER_H
33#define CONFIG_LINE_LIMIT 2048
64 SBuf token(
const char *expectedTokenDescription);
78 std::unique_ptr<RegexPattern>
regex(
const char *expectedRegexDescription);
130 static bool NextKvPair(
char * &key,
char * &value);
209 static char *
UnQuote(
const char *
token,
const char **next =
nullptr);
#define CONFIG_LINE_LIMIT
char * nextElement(TokenType &type)
std::string currentLine
The current line to parse.
std::string filePath
The file path.
FILE * wordFile
Pointer to the file.
char * parse(TokenType &type)
const char * parsePos
The next element position in parseBuffer string.
bool getFileLine()
Read the next line from the file.
char parseBuffer[CONFIG_LINE_LIMIT]
Temporary buffer to store data to parse.
bool startParse(char *path)
bool isOpen()
True if the configuration file is open.
int lineNo
Current line number.
bool optionalKvPair(char *&key, char *&value)
static void DisableMacros()
Do not allow macros inside quoted strings.
static const char * CfgLine
The current line to parse.
static TokenType LastTokenType
The type of last parsed element.
static SBuf CurrentLocation()
static char * RegexStrtokFile()
static const char * CfgPos
Pointer to the next element in cfgLine string.
static bool RecognizeQuotedPair_
The next tokens may contain quoted-pair (-escaped) characters.
void rejectDuplicateDirective()
rejects configuration due to a repeated directive
static char * NextQuotedToken()
static enum ConfigParser::ParsingStates KvPairState_
Parsing state while parsing kv-pair tokens.
static char * NextQuotedOrToEol()
ACLList * optionalAclList()
parses an [if [!]<acl>...] construct
std::unique_ptr< RegexPattern > regex(const char *expectedRegexDescription)
extracts and returns a regex (including any optional flags)
static std::queue< char * > CfgLineTokens_
Store the list of tokens for current configuration line.
static bool ParseKvPair_
The next token will be handled as kv-pair token.
static char * NextElement(TokenType &type)
Wrapper method for TokenParse.
static bool RecognizeQuotedValues
configuration_includes_quoted_values in squid.conf
static char * PeekAtToken()
static std::stack< CfgFile * > CfgFiles
The stack of open cfg files.
static bool ParseQuotedOrToEol_
The next tokens will be handled as quoted or to_eol token.
bool skipOptional(const char *keyword)
either extracts the given (optional) token or returns false
void closeDirective()
stops parsing the current configuration directive
static char * UnQuote(const char *token, const char **next=nullptr)
static bool NextKvPair(char *&key, char *&value)
static bool LastTokenWasQuoted()
static void ParseUShort(unsigned short *var)
CachePeer & cachePeer(const char *peerNameTokenDescription)
extracts a cache_peer name token and returns the corresponding CachePeer
static void ParseBool(bool *var)
static void SetCfgLine(char *line)
Set the configuration file line to parse.
static char * NextToken()
static void EnableMacros()
Allow macros inside quoted strings.
static char * strtokFile()
SBuf token(const char *expectedTokenDescription)
extracts and returns a required token
static void ParseWordList(wordlist **list)
static const char * QuoteString(const String &var)
static char * TokenParse(const char *&nextToken, TokenType &type)
void Parse()
interprets (and partially applies) squid.conf or equivalent configuration