#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#if 0
char *getlogin (void)
{
  char *user = getenv("USER");

  return user ? user : "amiga";
}
char *cuserid (char *s)
{
  char *user = getenv("USER");

  if (user == NULL)
    user = "amiga";
  if (s)
    strcpy (s, user);

  return s ? s : user;
}
#endif
#include <pwd.h>
#include <unistd.h>
char *cuserid (char *s)
{
    struct passwd *pwd;

    if ((pwd = getpwuid(geteuid())) == NULL) {
	if (s) {
	    *s = '\0';
	    return s;
	}
    }

    if (s) {
	strncpy(s,pwd->pw_name,L_cuserid);
	return s;
    }
    return pwd->pw_name;
}
