home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / ABUSESRC.ZIP / AbuseSrc / macabuse / src / username.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-20  |  466 b   |  30 lines

  1. #include "system.h"
  2.  
  3. #if defined( __WATCOMC__ ) || defined( __MAC__ )
  4. char *get_username() { return "DOS user"; }
  5.  
  6. #else
  7.   
  8. #include    <stdio.h>
  9. #include    <pwd.h>
  10. #include    <sys/types.h>
  11. #include        <unistd.h>
  12.  
  13. char *get_username()
  14. {
  15.   struct passwd        *pw;
  16.   char            *name;
  17.  
  18.   if (!(name = getlogin()))
  19.   {
  20.     if ((pw = getpwuid (getuid())))
  21.       return pw->pw_name;
  22.     else
  23.       return "UNIX user";
  24.   } else return name; 
  25. }
  26.  
  27. #endif
  28.  
  29.  
  30.