diff options
| author | Markus Uhlin <markus@nifty-networks.net> | 2026-03-05 19:16:38 +0100 |
|---|---|---|
| committer | Markus Uhlin <markus@nifty-networks.net> | 2026-03-05 19:16:38 +0100 |
| commit | 0f1d8f3ffffc6e6a63fd57b773f4a8fd1a975a20 (patch) | |
| tree | 8061e92f369a1a659b711b7bebca23a9fc153cde | |
| parent | c247927e89f2cf8f5642d54cbc05d96e5b2911a1 (diff) | |
Added get_uint()
| -rw-r--r-- | FICS/playerdb.c | 12 | ||||
| -rw-r--r-- | FICS/playerdb.h | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/FICS/playerdb.c b/FICS/playerdb.c index 5f8dfd6..bdad800 100644 --- a/FICS/playerdb.c +++ b/FICS/playerdb.c @@ -61,6 +61,7 @@ #include <errno.h> #include <fcntl.h> #include <inttypes.h> +#include <limits.h> #include <stdint.h> #include "command.h" @@ -80,6 +81,7 @@ #include "utils.h" #if __linux__ +#include <bsd/stdlib.h> #include <bsd/string.h> #endif @@ -714,6 +716,16 @@ ReadV1PlayerFmt(int p, player *pp, FILE *fp, char *file, int version) } } +PUBLIC unsigned int +get_uint(const char *nptr) +{ + const char *errstr = NULL; + const unsigned int val = (unsigned int) strtonum(nptr, + 0, UINT_MAX, &errstr); + + return (errstr ? 0 : val); +} + PRIVATE int got_attr_value_player(int p, char *attr, char *value, FILE *fp, char *file) { diff --git a/FICS/playerdb.h b/FICS/playerdb.h index 1ccae61..56f9007 100644 --- a/FICS/playerdb.h +++ b/FICS/playerdb.h @@ -278,4 +278,5 @@ extern void player_pend_print(int, pending *); extern void player_write_login(int); extern void player_write_logout(int); +extern unsigned int get_uint(const char *); #endif /* _PLAYERDB_H */ |
