]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/Parsing.h
c3917c9ef2654fa7f05fce78138ce8692cbf5dba
2 * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 /* DEBUG: section 03 Configuration File Parsing */
11 #ifndef SQUID_PARSING_H
12 #define SQUID_PARSING_H
14 #include "ip/Address.h"
16 double xatof(const char *token
);
17 int xatoi(const char *token
);
18 unsigned int xatoui(const char *token
, char eov
= '\0');
19 long xatol(const char *token
);
20 int64_t xatoll(const char *token
, int base
, char eov
= '\0');
21 unsigned short xatos(const char *token
);
24 * Parse a 64-bit integer value.
26 int64_t GetInteger64(void);
29 * Parses an integer value.
30 * Uses a method that obeys hexadecimal 0xN syntax needed for certain bitmasks.
31 * self_destruct() will be called to abort when invalid tokens are encountered.
36 * Parse a percentage value, e.g., 20%.
37 * The behavior of this function is similar as GetInteger().
38 * The difference is that the token might contain '%' as percentage symbol (%),
39 * and we may further check whether the value is in the range of [0, 100].
40 * For example, 20% and 20 are both valid tokens, while 101%, 101, -1 are invalid.
42 * \param limit whether to check the value is within 0-100% limit
44 * \return the percentage as a decimal number. ie 100% = 1.00, 50% = 0.5
46 double GetPercentage(bool limit
= true);
48 unsigned short GetShort(void);
50 // on success, returns true and sets *p (if any) to the end of the integer
51 bool StringToInt(const char *str
, int &result
, const char **p
, int base
);
52 bool StringToInt64(const char *str
, int64_t &result
, const char **p
, int base
);
55 * Parse a socket address (host:port), fill the given Ip::Address object
56 * \retval false Failure.
57 * \retval true Success.
58 * Destroys token during parse.
60 bool GetHostWithPort(char *token
, Ip::Address
*ipa
);
62 #endif /* SQUID_PARSING_H */