Parse a number in a string. More...
#include <stdbool.h>
Go to the source code of this file.
Macros | |
#define | make_str_ato_wrappers(flavour, type) |
Functions | |
const char * | mutt_str_atoi (const char *str, int *dst) |
Convert ASCII string to an integer. | |
const char * | mutt_str_atol (const char *str, long *dst) |
Convert ASCII string to a long. | |
const char * | mutt_str_atos (const char *str, short *dst) |
Convert ASCII string to a short. | |
const char * | mutt_str_atoui (const char *str, unsigned int *dst) |
Convert ASCII string to an unsigned integer. | |
const char * | mutt_str_atoul (const char *str, unsigned long *dst) |
Convert ASCII string to an unsigned long. | |
const char * | mutt_str_atoull (const char *str, unsigned long long *dst) |
Convert ASCII string to an unsigned long long. | |
const char * | mutt_str_atous (const char *str, unsigned short *dst) |
Convert ASCII string to an unsigned short. | |
make_str_ato_wrappers (i, int) make_str_ato_wrappers(l | |
long | make_str_ato_wrappers (s, short) make_str_ato_wrappers(ui |
long unsigned int | make_str_ato_wrappers (ul, unsigned long) make_str_ato_wrappers(ull |
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.h.
#define make_str_ato_wrappers | ( | flavour, | |
type | |||
) |
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 |
ptr | endptr |
Condition | Description |
---|---|
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 188 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 |
ptr | endptr |
Condition | Description |
---|---|
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 143 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 161 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 |
ptr | endptr |
Condition | Description |
---|---|
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 214 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 |
ptr | endptr |
Condition | Description |
---|---|
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 240 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 |
ptr | endptr |
Condition | Description |
---|---|
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 292 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 |
ptr | endptr |
Condition | Description |
---|---|
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 266 of file atoi.c.
make_str_ato_wrappers | ( | i | , |
int | |||
) |
long make_str_ato_wrappers | ( | s | , |
short | |||
) |
long unsigned int make_str_ato_wrappers | ( | ul | , |
unsigned long | |||
) |