|
Tor 0.4.9.8
|
Locale-independent minimal implementation of sscanf(). More...
#include "lib/string/scanf.h"#include "lib/string/compat_ctype.h"#include "lib/cc/torint.h"#include "lib/err/torerr.h"#include <stdlib.h>Go to the source code of this file.
Macros | |
| #define | MAX_SCANF_WIDTH 9999 |
Functions | |
| static int | digit_to_num (char d) |
| static int | scan_unsigned (const char **bufp, unsigned long *out, int width, unsigned base) |
| static int | scan_signed (const char **bufp, long *out, int width) |
| static int | scan_double (const char **bufp, double *out, int width) |
| static int | scan_string (const char **bufp, char *out, int width) |
| int | tor_vsscanf (const char *buf, const char *pattern, va_list ap) |
| int | tor_sscanf (const char *buf, const char *pattern,...) |
Locale-independent minimal implementation of sscanf().
Definition in file scanf.c.
|
static |
Helper: given an ASCII-encoded decimal digit, return its numeric value. NOTE: requires that its input be in-bounds.
Definition at line 23 of file scanf.c.
Referenced by scan_double(), scan_unsigned(), and tor_vsscanf().
|
static |
Helper: Read a decimal-formatted double from *bufp of up to width characters. (Handle arbitrary width if width is less than 0.) On success, store the result in out, advance bufp to the next character, and return 0. On failure, return -1.
Definition at line 117 of file scanf.c.
Referenced by tor_vsscanf().
|
static |
Helper: Read an signed int from *bufp of up to width characters. (Handle arbitrary width if width is less than 0.) On success, store the result in out, advance bufp to the next character, and return 0. On failure, return -1.
Definition at line 72 of file scanf.c.
Referenced by tor_vsscanf().
|
static |
Helper: copy up to width non-space characters from bufp to out. Make sure out is nul-terminated. Advance bufp to the next non-space character or the EOS.
Definition at line 162 of file scanf.c.
Referenced by tor_vsscanf().
|
static |
Helper: Read an unsigned int from *bufp of up to width characters. (Handle arbitrary width if width is less than 0.) On success, store the result in out, advance bufp to the next character, and return 0. On failure, return -1.
Definition at line 35 of file scanf.c.
Referenced by scan_signed(), and tor_vsscanf().
| int tor_sscanf | ( | const char * | buf, |
| const char * | pattern, | ||
| ... ) |
Minimal sscanf replacement: parse buf according to pattern and store the results in the corresponding argument fields. Differs from sscanf in that:
(As with other locale-independent functions, we need this to parse data that is in ASCII without worrying that the C library's locale-handling will make miscellaneous characters look like numbers, spaces, and so on.)
Definition at line 309 of file scanf.c.
Referenced by geoip_parse_entry(), parse_http_command(), parse_http_response(), parse_http_time(), parse_iso_time_(), parse_rfc1123_time(), rep_hist_load_mtbf_data(), tor_inet_aton(), and tor_inet_pton().
| int tor_vsscanf | ( | const char * | buf, |
| const char * | pattern, | ||
| va_list | ap ) |
Locale-independent, minimal, no-surprises scanf variant, accepting only a restricted pattern format. For more info on what it supports, see tor_sscanf() documentation.
Definition at line 179 of file scanf.c.
Referenced by tor_sscanf().