Parse a number in a string. More...
#include "config.h"
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include "atoi.h"
Go to the source code of this file.
Functions | |
static const char * | str_atol_clamp (const char *str, long *dst, long lmin, long lmax) |
Convert ASCII string to a long and clamp. More... | |
static const char * | str_atoull_clamp (const char *str, unsigned long long *dst, unsigned long long ullmax) |
Convert ASCII string to an unsigned long long and clamp. More... | |
const char * | mutt_str_atol (const char *str, long *dst) |
Convert ASCII string to a long. More... | |
const char * | mutt_str_atos (const char *str, short *dst) |
Convert ASCII string to a short. More... | |
const char * | mutt_str_atoi (const char *str, int *dst) |
Convert ASCII string to an integer. More... | |
const char * | mutt_str_atoui (const char *str, unsigned int *dst) |
Convert ASCII string to an unsigned integer. More... | |
const char * | mutt_str_atoul (const char *str, unsigned long *dst) |
Convert ASCII string to an unsigned long. More... | |
const char * | mutt_str_atous (const char *str, unsigned short *dst) |
Convert ASCII string to an unsigned short. More... | |
const char * | mutt_str_atoull (const char *str, unsigned long long *dst) |
Convert ASCII string to an unsigned long long. More... | |
Parse a number in a string.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file atoi.c.
|
static |
Convert ASCII string to a long and clamp.
[in] | str | String to read |
[in] | lmin | Lower bound |
[in] | lmax | Upper bound |
[out] | dst | Store the result |
endptr |
endptr == NULL -> no conversion happened, or overflow endptr[0] == '\0' -> str was fully converted endptr[0] != '\0' -> endptr points to first non converted char in str
This is a strtol() wrapper with range checking. errno may be set on error, e.g. ERANGE
Definition at line 51 of file atoi.c.
|
static |
Convert ASCII string to an unsigned long long and clamp.
[in] | str | String to read |
[in] | ullmax | Upper bound |
[out] | dst | Store the result |
endptr |
endptr == NULL -> no conversion happened, or overflow endptr[0] == '\0' -> str was fully converted endptr[0] != '\0' -> endptr points to first non converted char in str
This is a strtoull() wrapper with range checking. errno may be set on error, e.g. ERANGE
Definition at line 94 of file atoi.c.
const char * mutt_str_atol | ( | const char * | str, |
long * | dst | ||
) |
Convert ASCII string to a long.
[in] | str | String to read |
[out] | dst | Store the result |
endptr |
endptr == NULL -> no conversion happened, or overflow endptr[0] == '\0' -> str was fully converted endptr[0] != '\0' -> endptr points to first non converted char in str
This is a strtol() wrapper with range checking. errno may be set on error, e.g. ERANGE
Definition at line 136 of file atoi.c.
const char * mutt_str_atos | ( | const char * | str, |
short * | dst | ||
) |
Convert ASCII string to a short.
[in] | str | String to read |
[out] | dst | Store the result |
0 | Success |
-1 | Error |
-2 | Error, overflow |
This is a strtol() wrapper with range checking. If dst is NULL, the string will be tested only (without conversion).
errno may be set on error, e.g. ERANGE
Definition at line 154 of file atoi.c.
const char * mutt_str_atoi | ( | const char * | str, |
int * | dst | ||
) |
Convert ASCII string to an integer.
[in] | str | String to read |
[out] | dst | Store the result |
endptr |
endptr == NULL -> no conversion happened, or overflow endptr[0] == '\0' -> str was fully converted endptr[0] != '\0' -> endptr points to first non converted char in str
This is a strtol() wrapper with range checking. If dst is NULL, the string will be tested only (without conversion). errno may be set on error, e.g. ERANGE
Definition at line 179 of file atoi.c.
const char * mutt_str_atoui | ( | const char * | str, |
unsigned int * | dst | ||
) |
Convert ASCII string to an unsigned integer.
[in] | str | String to read |
[out] | dst | Store the result |
endptr |
endptr == NULL -> no conversion happened, or overflow endptr[0] == '\0' -> str was fully converted endptr[0] != '\0' -> endptr points to first non converted char in str
Definition at line 203 of file atoi.c.
const char * mutt_str_atoul | ( | const char * | str, |
unsigned long * | dst | ||
) |
Convert ASCII string to an unsigned long.
[in] | str | String to read |
[out] | dst | Store the result |
endptr |
endptr == NULL -> no conversion happened, or overflow endptr[0] == '\0' -> str was fully converted endptr[0] != '\0' -> endptr points to first non converted char in str
Definition at line 227 of file atoi.c.
const char * mutt_str_atous | ( | const char * | str, |
unsigned short * | dst | ||
) |
Convert ASCII string to an unsigned short.
[in] | str | String to read |
[out] | dst | Store the result |
endptr |
endptr == NULL -> no conversion happened, or overflow endptr[0] == '\0' -> str was fully converted endptr[0] != '\0' -> endptr points to first non converted char in str
Definition at line 251 of file atoi.c.
const char * mutt_str_atoull | ( | const char * | str, |
unsigned long long * | dst | ||
) |
Convert ASCII string to an unsigned long long.
[in] | str | String to read |
[out] | dst | Store the result |
endptr |
endptr == NULL -> no conversion happened, or overflow endptr[0] == '\0' -> str was fully converted endptr[0] != '\0' -> endptr points to first non converted char in str
Definition at line 275 of file atoi.c.