blob: 53866c6dce4077d8a53ba118a6460c2f2e6f55ee (
plain)
1
2
3
4
5
6
7
8
9
10
11
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;
}
|