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

  1. /*
  2.     MDG Multiuser Dungeon Game -- gident.c user 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 = "@(#) gident.c\t(1.2)\tcreated 12/31/90";
  11.  
  12. #include <stdio.h>
  13. #include <string.h>
  14.  
  15. #include "setup.h"
  16. #include "files.h"
  17. #include "messages.h"
  18.  
  19. extern char *progname;
  20.  
  21. extern int errno;
  22. extern char *sys_errlist[];
  23.  
  24.  
  25. int get_player(pname)
  26. char *pname;
  27. {
  28.     char inbuf[80], prog[80], *p;
  29.     FILE *fp;
  30.     int num;
  31.  
  32.     pname[0] = '\0';
  33.  
  34.     strcpy(prog, GAME_HOME);
  35.     strcat(prog, "/");
  36.     strcat(prog, IDENTPROG);
  37.  
  38.     if((fp = popen(prog, "r")) == NULL)
  39.         return -1;
  40.  
  41.     fgets(inbuf, 80, fp);
  42.     fgets(pname, 19, fp);
  43.  
  44.     pclose(fp);
  45.  
  46.     for(p = pname; *p; p++)
  47.         if(*p == '\n')
  48.             *p = '\0';
  49.  
  50.     if(sscanf(inbuf, "%d", &num) != 1)
  51.         return -1;
  52.  
  53.     return num;
  54. }
  55.  
  56.  
  57. /* end of file. */
  58.