]> git.ipfire.org Git - thirdparty/squid.git/blob - compat/xstrto.h
SourceFormat Enforcement
[thirdparty/squid.git] / compat / xstrto.h
1 /*
2 * Copyright (C) 1996-2015 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 #ifndef _SQUID_XSTRTO_H
10 #define _SQUID_XSTRTO_H
11
12 // these functions are not used by the remaining Squid C code.
13 #if defined(__cplusplus)
14
15 #if HAVE_STDBOOL_H
16 #include <stdbool.h>
17 #endif
18
19 /**
20 * xstrtou{i,l} - string to number conversion
21 * \param s input string
22 * \param end like strtoul's "end" pointer
23 * \param value pointer for result. Undefined on failure
24 * \param min minimum accepted value
25 * \param max maximum accepted value
26 *
27 * If @end is NULL, we assume the caller wants a "strict strtoul", and hence
28 * "15a" is rejected.
29 * In either case, the value obtained is compared for min-max compliance.
30 * Base is always 0, i.e. autodetect depending on @s.
31 *
32 * \return true/false whether number was accepted. On failure, *value has
33 * undefined contents.
34 */
35 bool xstrtoul(const char *s, char **end, unsigned long *value,
36 unsigned long min, unsigned long max);
37
38 bool xstrtoui(const char *s, char **end, unsigned int *value,
39 unsigned int min, unsigned int max);
40
41 #endif /* __cplusplus */
42 #endif /* _SQUID_XSTRTO_H */
43