]>
Commit | Line | Data |
---|---|---|
c8f4eac4 | 1 | /* |
f70aedc4 | 2 | * Copyright (C) 1996-2021 The Squid Software Foundation and contributors |
c8f4eac4 | 3 | * |
bbc27441 AJ |
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. | |
c8f4eac4 | 7 | */ |
8 | ||
bbc27441 AJ |
9 | /* DEBUG: section 03 Configuration File Parsing */ |
10 | ||
c8f4eac4 | 11 | #ifndef SQUID_PARSING_H |
12 | #define SQUID_PARSING_H | |
13 | ||
582c2af2 | 14 | #include "ip/Address.h" |
c8f4eac4 | 15 | |
8a648e8d FC |
16 | double xatof(const char *token); |
17 | int xatoi(const char *token); | |
e398d16e | 18 | unsigned int xatoui(const char *token, char eov = '\0'); |
8a648e8d | 19 | long xatol(const char *token); |
e398d16e | 20 | int64_t xatoll(const char *token, int base, char eov = '\0'); |
c59baaa8 | 21 | uint64_t xatoull(const char *token, int base, char eov = '\0'); |
8a648e8d | 22 | unsigned short xatos(const char *token); |
b1fb3348 AJ |
23 | |
24 | /** | |
25 | * Parse a 64-bit integer value. | |
26 | */ | |
8a648e8d | 27 | int64_t GetInteger64(void); |
b1fb3348 AJ |
28 | |
29 | /** | |
30 | * Parses an integer value. | |
31 | * Uses a method that obeys hexadecimal 0xN syntax needed for certain bitmasks. | |
54a063a2 | 32 | * self_destruct() will be called to abort when invalid tokens are encountered. |
b1fb3348 | 33 | */ |
8a648e8d | 34 | int GetInteger(void); |
b1fb3348 | 35 | |
54a063a2 TX |
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 (%), | |
1454480a | 40 | * and we may further check whether the value is in the range of [0, 100]. |
54a063a2 | 41 | * For example, 20% and 20 are both valid tokens, while 101%, 101, -1 are invalid. |
1454480a AJ |
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 | |
54a063a2 | 46 | */ |
1454480a | 47 | double GetPercentage(bool limit = true); |
54a063a2 | 48 | |
8a648e8d | 49 | unsigned short GetShort(void); |
c8f4eac4 | 50 | |
053b1f59 | 51 | // on success, returns true and sets *p (if any) to the end of the integer |
8a648e8d FC |
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); | |
053b1f59 | 54 | |
82b7abe3 | 55 | /** |
b7ac5457 | 56 | * Parse a socket address (host:port), fill the given Ip::Address object |
82b7abe3 AJ |
57 | * \retval false Failure. |
58 | * \retval true Success. | |
59 | * Destroys token during parse. | |
60 | */ | |
8a648e8d | 61 | bool GetHostWithPort(char *token, Ip::Address *ipa); |
82b7abe3 | 62 | |
c8f4eac4 | 63 | #endif /* SQUID_PARSING_H */ |
f53969cc | 64 |