BSD strtoq(3) and strtouq(3) Functions

BSD is a little different in its large integer conversions. FreeBSD supports its strtoq(3) and strtouq(3) functional equivalents of the strtoll(3) and strtoull(3) functions. The 64-bit C data types that FreeBSD uses are

Signed 64-bit quad_t
Unsigned 64-bit u_quad_t

The function synopsis of the conversion routines for these data types is as follows:

#include <sys/types.h>
#include <stdlib.h>
#include <limits.h>

quad_t strtoq(const char *nptr, char **endptr, int base);

u_quad_t strtouq(const char *nptr, char **endptr, int base);

The C macros that you should use with strtoq(3) are QUAD_MAX and QUAD_MIN, when testing for overflow and underflow, respectively. For strtouq(3), you must use the C macro UQUAD_MAX ...

Get Advanced UNIX Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.