musl-tcc/src/unistd/getlogin_r.c

13 lines
255 B
C
Raw Normal View History

2022-03-20 04:48:53 -04:00
#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;
}