ftp.nice.ch/pub/next/unix/admin/msend.1.0.N.bs.tar.gz#/msend/whoami.c

This is whoami.c in view mode; [Download] [Up]

/* whoami.c:
 *
 * this attempts to figure out who ran the program
 *
 * (c) Copyright 1988, 1989, 1990 Jim Frost.  All Rights Reserved.  Please see
 * the accompanying file "Copyright" for more information.
 */

#include "Copyright"
#include "config.h"
#include "msend.h"

char *whoami()
{ struct passwd *pwd;
  static char   name[MAXUSERNAME+1];
  static int    unknown= 1;

  if (unknown) {
    if ((pwd= getpwuid(getuid())) == NULL) {
      if (strcpy(name,getlogin()) == NULL) {
        printf("Who are you?  (No password file entry?)\n");
        exit(1);
      }
    }
    else
      strcpy(name,pwd->pw_name);
    unknown= 0;
  }
  return(name);
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.