diff options
Diffstat (limited to 'src/unistd/getlogin_r.c')
-rw-r--r-- | src/unistd/getlogin_r.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/unistd/getlogin_r.c b/src/unistd/getlogin_r.c new file mode 100644 index 0000000..53866c6 --- /dev/null +++ b/src/unistd/getlogin_r.c @@ -0,0 +1,12 @@ +#include <unistd.h> +#include <string.h> +#include <errno.h> + +int getlogin_r(char *name, size_t size) +{ + char *logname = getlogin(); + if (!logname) return ENXIO; /* or...? */ + if (strlen(logname) >= size) return ERANGE; + strcpy(name, logname); + return 0; +} |