src/common/string.c
/**
 * Takes a string which corresponds to a base 10 number as well as a pointer
 * to intmax_t. if the number can be transformed successfully the dest
 * pointer will have the number placed into it.
 *
 * If there is an error it will be returned. Otherwise NO_ERROR is returned
 */
Takes a string which corresponds to a base 10 number as well as a pointer
to intmax_t. if the number can be transformed successfully the dest
pointer will have the number placed into it.

If there is an error it will be returned. Otherwise NO_ERROR is returned
Takes a string which corresponds to a base 10 number as well as a pointer to intmax_t . if the number can be transformed successfully the dest pointer will have the number placed into it . If there is an error it will be returned . Otherwise NO_ERROR is returned
enum natwm_error string_to_number(const char *number_string, intmax_t *dest)
{
        char *endptr = NULL;
        errno = 0;
        intmax_t result = strtoimax(number_string, &endptr, 10);
        if (errno == ERANGE || endptr == number_string || *endptr != '\0') {
                return INVALID_INPUT_ERROR;
        }
        if (errno != 0) {
                LOG_CRITICAL_LONG(natwm_logger, "Unhandleable input received - Exiting...");
                exit(EXIT_FAILURE);
        }
        *dest = result;
        return NO_ERROR;
}
enum natwm_error string_to_number ( const char * number_string , intmax_t * dest ) { char * endptr = NULL ; errno = 0 ; intmax_t result = strtoimax ( number_string , & endptr , 10 ) ; if ( errno == ERANGE || endptr == number_string || * endptr != ' \0 ' ) { return INVALID_INPUT_ERROR ; } if ( errno != 0 ) { LOG_CRITICAL_LONG ( natwm_logger , " " ) ; exit ( EXIT_FAILURE ) ; } * dest = result ; return NO_ERROR ; }
Takes a string which corresponds to a base 10 number as well as a pointer
 to intmax_t.
Takes a string which corresponds to a base 10 number as well as a pointer to intmax_t .
// Reset errno to 0 so we can test for ERANGE