From 4abab5ad6c8465a7528ccdd5f49367da05f78bbd Mon Sep 17 00:00:00 2001 From: Vladimir Azarov Date: Tue, 1 Oct 2024 15:47:05 +0200 Subject: Initial version --- src/passwd/getspnam.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/passwd/getspnam.c (limited to 'src/passwd/getspnam.c') diff --git a/src/passwd/getspnam.c b/src/passwd/getspnam.c new file mode 100644 index 0000000..709b526 --- /dev/null +++ b/src/passwd/getspnam.c @@ -0,0 +1,18 @@ +#include "pwf.h" + +#define LINE_LIM 256 + +struct spwd *getspnam(const char *name) +{ + static struct spwd sp; + static char *line; + struct spwd *res; + int e; + int orig_errno = errno; + + if (!line) line = malloc(LINE_LIM); + if (!line) return 0; + e = getspnam_r(name, &sp, line, LINE_LIM, &res); + errno = e ? e : orig_errno; + return res; +} -- cgit v1.2.3