From aeac3de6549f57ca2af215c217749aa9b2adc95f Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Wed, 19 Nov 2025 20:30:23 +0100 Subject: Added is_numeric() --- FICS/settings.cpp | 14 ++++++++++++++ FICS/settings.h | 1 + 2 files changed, 15 insertions(+) (limited to 'FICS') diff --git a/FICS/settings.cpp b/FICS/settings.cpp index de25098..ad1cc02 100644 --- a/FICS/settings.cpp +++ b/FICS/settings.cpp @@ -112,6 +112,20 @@ check_some_settings_strictly(void) errx(1, "error: sysgroup: invalid group name"); } +bool +is_numeric(const char *string) +{ + if (string == nullptr || *string == '\0') + return false; + + for (const char *cp = &string[0]; *cp != '\0'; cp++) { + if (!isdigit(*cp)) + return false; + } + + return true; +} + bool is_valid_hostname(const char *p_str, err_reason_t *p_reason) { diff --git a/FICS/settings.h b/FICS/settings.h index 4b1f15e..b5aad98 100644 --- a/FICS/settings.h +++ b/FICS/settings.h @@ -14,6 +14,7 @@ void settings_init(void); void settings_deinit(void); void check_some_settings_strictly(void); +bool is_numeric(const char *); bool is_valid_hostname(const char *, err_reason_t *); bool is_valid_username(const char *, err_reason_t *); const char *settings_get(const char *set_name); -- cgit v1.2.3