aboutsummaryrefslogtreecommitdiff
path: root/src/unistd/getlogin_r.c
blob: 168d25e5b07567ba207b851cbdf6a4e665f4d2ef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#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;
}


#ifdef TEST
int
main(void) {
	return 0;
}
#endif