home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Spezial / SPEZIAL2_97.zip / SPEZIAL2_97.iso / ANWEND / ONLINE / ELM23-2 / ELM23-2.ZIP / src / validname.c < prev   
C/C++ Source or Header  |  1992-05-23  |  2KB  |  69 lines

  1.  
  2. static char rcsid[] = "@(#)$Id: validname.c,v 4.1 90/04/28 22:44:21 syd Exp $";
  3.  
  4. /*******************************************************************************
  5.  *  The Elm Mail System  -  $Revision: 4.1 $   $State: Exp $
  6.  *
  7.  *             Copyright (c) 1986, 1987 Dave Taylor
  8.  *             Copyright (c) 1988, 1989, 1990 USENET Community Trust
  9.  *******************************************************************************
  10.  * Bug reports, patches, comments, suggestions should be sent to:
  11.  *
  12.  *    Syd Weinstein, Elm Coordinator
  13.  *    elm@DSI.COM            dsinc!elm
  14.  *
  15.  *******************************************************************************
  16.  * $Log:    validname.c,v $
  17.  * Revision 4.1  90/04/28  22:44:21  syd
  18.  * checkin of Elm 2.3 as of Release PL0
  19.  *
  20.  *
  21.  ******************************************************************************/
  22.  
  23. #include <stdio.h>
  24.  
  25. #ifndef NOCHECK_VALIDNAME         /* Force a return of valid */
  26. # ifdef PWDINSYS
  27. #  include <sys/pwd.h>
  28. # else
  29. #  include <pwd.h>
  30. # endif
  31. #endif
  32.  
  33. #include "defs.h"
  34.  
  35. int
  36. valid_name(name)
  37. char *name;
  38. {
  39.     /** Determine whether "name" is a valid logname on this system.
  40.         It is valid if there is a password entry, or if there is
  41.         a mail file in the mail spool directory for "name".
  42.      **/
  43.  
  44. #ifdef NOCHECK_VALIDNAME         /* Force a return of valid */
  45.  
  46.     return(TRUE);
  47.  
  48. #else
  49.  
  50.     char filebuf[SLEN];
  51.     struct passwd *getpwnam();
  52.  
  53.     if(getpwnam(name) != NULL)
  54.       return(TRUE);
  55.  
  56. #ifdef OS2
  57.     if (maildir)
  58.         sprintf(filebuf, "%s%s/newmail%s", mailhome, name, mailext);
  59.     else
  60. #endif
  61.     sprintf(filebuf,"%s%s%s", mailhome, name, mailext);
  62.     if (access(filebuf, ACCESS_EXISTS) == 0)
  63.       return(TRUE);
  64.  
  65.     return(FALSE);
  66.  
  67. #endif
  68. }
  69.