minix/lib/nbsd_libcompat_minix/cuserid.c
Gianluca Guida 6bcf58bab8 Add libcompat_minix for NBSD libc
libcompat_minix is a compatibility layer meant to let existing commands to work
with the new libc.
2011-03-18 16:08:26 +00:00

34 lines
565 B
C

/* cuserid(3)
*
* Author: Terrence W. Holm Sept. 1987
*/
#include <lib.h>
#include <pwd.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#ifndef L_cuserid
#define L_cuserid 9
#endif
char *cuserid(user_name)
char *user_name;
{
PRIVATE char userid[L_cuserid];
struct passwd *pw_entry;
if (user_name == (char *)NULL) user_name = userid;
pw_entry = getpwuid(geteuid());
if (pw_entry == (struct passwd *)NULL) {
*user_name = '\0';
return((char *)NULL);
}
strcpy(user_name, pw_entry->pw_name);
return(user_name);
}