]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (C) 1996-2025 The Squid Software Foundation and contributors | |
3 | * | |
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. | |
7 | */ | |
8 | ||
9 | /* DEBUG: section 03 Configuration File Parsing */ | |
10 | ||
11 | #ifndef SQUID_SRC_PARSING_H | |
12 | #define SQUID_SRC_PARSING_H | |
13 | ||
14 | #include "ip/Address.h" | |
15 | ||
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 | uint64_t xatoull(const char *token, int base, char eov = '\0'); | |
22 | unsigned short xatos(const char *token); | |
23 | ||
24 | /** | |
25 | * Parse a 64-bit integer value. | |
26 | */ | |
27 | int64_t GetInteger64(void); | |
28 | ||
29 | /** | |
30 | * Parses an integer value. | |
31 | * Uses a method that obeys hexadecimal 0xN syntax needed for certain bitmasks. | |
32 | * self_destruct() will be called to abort when invalid tokens are encountered. | |
33 | */ | |
34 | int GetInteger(void); | |
35 | ||
36 | /** | |
37 | * Parse a percentage value, e.g., 20%. | |
38 | * The behavior of this function is similar as GetInteger(). | |
39 | * The difference is that the token might contain '%' as percentage symbol (%), | |
40 | * and we may further check whether the value is in the range of [0, 100]. | |
41 | * For example, 20% and 20 are both valid tokens, while 101%, 101, -1 are invalid. | |
42 | * | |
43 | * \param limit whether to check the value is within 0-100% limit | |
44 | * | |
45 | * \return the percentage as a decimal number. ie 100% = 1.00, 50% = 0.5 | |
46 | */ | |
47 | double GetPercentage(bool limit = true); | |
48 | ||
49 | unsigned short GetShort(void); | |
50 | ||
51 | // on success, returns true and sets *p (if any) to the end of the integer | |
52 | bool StringToInt(const char *str, int &result, const char **p, int base); | |
53 | bool StringToInt64(const char *str, int64_t &result, const char **p, int base); | |
54 | ||
55 | /** | |
56 | * Parse a socket address (host:port), fill the given Ip::Address object | |
57 | * \retval false Failure. | |
58 | * \retval true Success. | |
59 | * Destroys token during parse. | |
60 | */ | |
61 | bool GetHostWithPort(char *token, Ip::Address *ipa); | |
62 | ||
63 | #endif /* SQUID_SRC_PARSING_H */ | |
64 |