Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
Conversion utility functions. More...
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <inttypes.h>
#include <stdio.h>
#include "asterisk/conversions.h"
Go to the source code of this file.
Functions | |
int | ast_str_to_imax (const char *str, intmax_t *res) |
Convert the given string to a signed max size integer. More... | |
int | ast_str_to_int (const char *str, int *res) |
Convert the given string to a signed integer. More... | |
int | ast_str_to_long (const char *str, long *res) |
Convert the given string to a signed long. More... | |
int | ast_str_to_uint (const char *str, unsigned int *res) |
Convert the given string to an unsigned integer. More... | |
int | ast_str_to_ulong (const char *str, unsigned long *res) |
Convert the given string to an unsigned long. More... | |
int | ast_str_to_umax (const char *str, uintmax_t *res) |
Convert the given string to an unsigned max size integer. More... | |
static int | str_is_negative (const char **str) |
Conversion utility functions.
Definition in file conversions.c.
int ast_str_to_imax | ( | const char * | str, |
intmax_t * | res | ||
) |
Convert the given string to a signed max size integer.
This function will return failure for the following reasons:
The given string to convert is NULL The given string to convert is empty. The given string to convert contains non numeric values Once converted the number is out of range (less than INTMAX_MIN or greater than INTMAX_MAX)
str | The string to convert | |
[out] | res | The converted value |
Definition at line 92 of file conversions.c.
References end, errno, and str.
Referenced by ast_str_to_int(), ast_str_to_long(), and AST_TEST_DEFINE().
int ast_str_to_int | ( | const char * | str, |
int * | res | ||
) |
Convert the given string to a signed integer.
This function will return failure for the following reasons:
The given string to convert is NULL The given string to convert is empty. The given string to convert contains non numeric values Once converted the number is out of range (less than INT_MIN or greater than INT_MAX)
str | The string to convert | |
[out] | res | The converted value |
Definition at line 44 of file conversions.c.
References ast_str_to_imax(), and str.
Referenced by AST_TEST_DEFINE(), category_set_sublevels(), detect_write(), dtmfstore_exec(), freq_parser(), json_decode_read(), parse_node(), pbx_builtin_saynumber(), pbx_builtin_sayordinal(), read_sf_exec(), response_code_validator(), sayfile_exec(), scan_exec(), sendsf_exec(), set_id_from_oli(), and wait_exec().
int ast_str_to_long | ( | const char * | str, |
long * | res | ||
) |
Convert the given string to a signed long.
This function will return failure for the following reasons:
The given string to convert is NULL The given string to convert is empty. The given string to convert contains non numeric values Once converted the number is out of range (less than LONG_MIN or greater than LONG_MAX)
str | The string to convert | |
[out] | res | The converted value |
Definition at line 68 of file conversions.c.
References ast_str_to_imax(), and str.
Referenced by AST_TEST_DEFINE().
int ast_str_to_uint | ( | const char * | str, |
unsigned int * | res | ||
) |
Convert the given string to an unsigned integer.
This function will return failure for the following reasons:
The given string to convert is NULL The given string to convert is empty. The given string to convert is negative (starts with a '-') The given string to convert contains non numeric values Once converted the number is out of range (greater than UINT_MAX)
str | The string to convert | |
[out] | res | The converted value |
Definition at line 56 of file conversions.c.
References ast_str_to_umax(), and str.
Referenced by add_cert_expiration_to_astdb(), AST_TEST_DEFINE(), func_get_parkingslot_channel(), func_read(), and stream_echo_exec().
int ast_str_to_ulong | ( | const char * | str, |
unsigned long * | res | ||
) |
Convert the given string to an unsigned long.
This function will return failure for the following reasons:
The given string to convert is NULL The given string to convert is empty. The given string to convert is negative (starts with a '-') The given string to convert contains non numeric values Once converted the number is out of range (greater than ULONG_MAX)
str | The string to convert | |
[out] | res | The converted value |
Definition at line 80 of file conversions.c.
References ast_str_to_umax(), and str.
Referenced by AST_TEST_DEFINE(), and is_cert_cache_entry_expired().
int ast_str_to_umax | ( | const char * | str, |
uintmax_t * | res | ||
) |
Convert the given string to an unsigned max size integer.
This function will return failure for the following reasons:
The given string to convert is NULL The given string to convert is empty. The given string to convert is negative (starts with a '-') The given string to convert contains non numeric values Once converted the number is out of range (greater than UINTMAX_MAX)
str | The string to convert | |
[out] | res | The converted value |
Definition at line 119 of file conversions.c.
References end, errno, str, and str_is_negative().
Referenced by ast_str_to_uint(), ast_str_to_ulong(), AST_TEST_DEFINE(), create_foo_type_message(), mailbox_to_num(), and validate_data().
|
static |
Definition at line 34 of file conversions.c.
References str.
Referenced by ast_str_to_umax().