source: trunk/athena/bin/neos/full_name.c @ 13635

Revision 13635, 1.8 KB checked in by danw, 25 years ago (diff)
NEOS clients, from athena/lib/neos/clients
Line 
1/**********************************************************************
2 * full_name module
3 *
4 * $Author
5 * $Id: full_name.c,v 1.1 1999-09-28 22:10:56 danw Exp $
6 *
7 * Copyright 1989, 1990 by the Massachusetts Institute of Technology.
8 *
9 * For copying and distribution information, please see the file
10 * <mit-copyright.h>.
11 **********************************************************************/
12
13#include <mit-copyright.h>
14
15#include <stdio.h>
16#include <string.h>
17#include <hesiod.h>
18
19/**** borrowed from eos sources ****/
20/*
21  Takes a username and tries to find a password entry for it via Hesiod;
22  If the resolve fails or the password entry cannot be parsed, then the
23  original name is returned, else the name given in passwd is returned,
24  with the parameter name following in parentheses;
25  e.g. RealName("jsmith") == "jsmith" || "John Smith (jsmith)";
26*/
27
28char *full_name(name)
29     char *name;
30{
31  char **namelist, *realname, *tmp;
32  static char finalname[256];
33  int i;
34
35  if ((namelist = hes_resolve(name, "passwd")) == NULL) {
36    strcpy(finalname, name);
37    strcat(finalname, " (no hesiod info)");
38  } else {
39    /* Extract name from password entry */
40    realname = *namelist;
41    for (i=0; i<4; i++)
42      if ((realname = strchr(++realname, ':')) == NULL) {
43        /* Password entry is screwy - so give up and return original */
44        strcpy(finalname, name);
45        return finalname;
46      }
47    /* Remove rest of password entry */
48    if ((tmp = strchr(++realname,':')) != NULL)
49      *tmp = '\0';
50    /* Make sure this is just the name, no unneccassry junk */
51    if ((tmp = strchr(realname, ',')) != NULL)
52      *tmp = '\0';
53    /* Just to be nice, add on the original name */
54    strcpy(finalname, realname);
55    strcat(finalname, " (");
56    strcat(finalname, name);
57    strcat(finalname, ")");
58  }
59  return finalname;
60}
Note: See TracBrowser for help on using the repository browser.