]> git.ipfire.org Git - thirdparty/squid.git/blob - src/Parsing.h
Boilerplate: update copyright blurbs on src/
[thirdparty/squid.git] / src / Parsing.h
1 /*
2 * Copyright (C) 1996-2014 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_PARSING_H
12 #define SQUID_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 unsigned short xatos(const char *token);
22
23 /**
24 * Parse a 64-bit integer value.
25 */
26 int64_t GetInteger64(void);
27
28 /**
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.
32 */
33 int GetInteger(void);
34
35 /**
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 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.
41 */
42 int GetPercentage(void);
43
44 unsigned short GetShort(void);
45
46 // on success, returns true and sets *p (if any) to the end of the integer
47 bool StringToInt(const char *str, int &result, const char **p, int base);
48 bool StringToInt64(const char *str, int64_t &result, const char **p, int base);
49
50 /**
51 * Parse a socket address (host:port), fill the given Ip::Address object
52 * \retval false Failure.
53 * \retval true Success.
54 * Destroys token during parse.
55 */
56 bool GetHostWithPort(char *token, Ip::Address *ipa);
57
58 #endif /* SQUID_PARSING_H */