home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / games / volume12 / mdg / part05 / ident.c < prev    next >
C/C++ Source or Header  |  1991-03-04  |  832b  |  59 lines

  1. /*
  2.     MDG Multiuser Dungeon Game -- ident
  3.     
  4.     MDG is Copyright 1990 John C. Gonnerman
  5.     This program is subject to the general MDG 
  6.     copyright statement (see enclosed file, Copyright).
  7. */
  8.  
  9.  
  10. static char *sccsvers = "@(#) ident.c\t(1.1)\tcreated 12/25/90";
  11.  
  12. #include <stdio.h>
  13. #include <pwd.h>
  14. #include <string.h>
  15.  
  16. #include "messages.h"
  17.  
  18. #define USAGE        "Usage: ident [ uid-num ]\n"
  19.  
  20. char *progname;
  21.  
  22. extern char *sys_errlist[];
  23. extern int errno;
  24.  
  25.  
  26. main(argc, argv)
  27. int argc;
  28. char *argv[];
  29. {
  30.     int num;
  31.     struct passwd *ps;
  32.  
  33.  
  34.     if((progname = strrchr(argv[0], '/')) != NULL)
  35.         progname++;
  36.     else
  37.         progname = argv[0];
  38.     
  39.     num = getuid();
  40.  
  41.     if(argc == 2)
  42.         num = atoi(argv[1]);
  43.  
  44.     if((ps = getpwuid(num)) == NULL) {
  45.         puts("-1");
  46.         exit(1);
  47.     }
  48.  
  49.     endpwent();
  50.  
  51.     printf("%d\n", num);
  52.     printf("%s\n", ps->pw_gecos);
  53.  
  54.     exit(0);
  55. }
  56.  
  57.  
  58. /* end of file. */
  59.