imap/src/osdep/nt/env_nt.c
/* Return my user name
 * Accepts: pointer to optional flags
 * Returns: my user name
 */
Return my user name
Accepts: pointer to optional flags
Returns: my user name
Return my user name Accepts : pointer to optional flags Returns : my user name
char *myusername_full (unsigned long *flags)
{
  UCHAR usr[MAILTMPLEN];
  DWORD len = MAILTMPLEN;
  char *user,*path,*d,*p,pth[MAILTMPLEN];
  char *ret = "SYSTEM";
  if (!myUserName && !server_nli &&
      ((mailusername && (user = (char *) (*mailusername) ())) ||
       (GetUserName (usr,&len) && _stricmp (user = (char *) usr,"SYSTEM")))) {
    if (block_env_init) {	
      if (flags) *flags = MU_LOGGEDIN;
      return user;
    }
    if (p = getenv ("HOMEPATH"))
      sprintf (path = pth,"%s%s",
	       (d = getenv ("HOMEDRIVE")) ? d : defaultDrive (),p);
    else if (!(path = getenv ("HOME")))
      sprintf (path = pth,"%s\\My Documents",defaultDrive ());
    if ((*(p = path + strlen (path) -1) == '\\') || (*p == '/')) *p = '\0';
    env_init (user,path);	
  }
  if (myUserName) {		
    if (flags)			
      *flags = _stricmp (myUserName,"Guest") ? MU_LOGGEDIN : MU_ANONYMOUS;
    ret = myUserName;		
  }
  else if (flags) *flags = MU_NOTLOGGEDIN;
  return ret;
}
char * myusername_full ( unsigned long * flags ) { UCHAR usr [ MAILTMPLEN ] ; DWORD len = MAILTMPLEN ; char * user , * path , * d , * p , pth [ MAILTMPLEN ] ; char * ret = " " ; if ( ! myUserName && ! server_nli && ( ( mailusername && ( user = ( char * ) ( * mailusername ) ( ) ) ) || ( GetUserName ( usr , & len ) && _stricmp ( user = ( char * ) usr , " " ) ) ) ) { if ( block_env_init ) { if ( flags ) * flags = MU_LOGGEDIN ; return user ; } if ( p = getenv ( " " ) ) sprintf ( path = pth , " " , ( d = getenv ( " " ) ) ? d : defaultDrive ( ) , p ) ; else if ( ! ( path = getenv ( " " ) ) ) sprintf ( path = pth , " \\ " , defaultDrive ( ) ) ; if ( ( * ( p = path + strlen ( path ) - 1 ) == ' \\ ' ) || ( * p == ' ' ) ) * p = ' \0 ' ; env_init ( user , path ) ; } if ( myUserName ) { if ( flags ) * flags = _stricmp ( myUserName , " " ) ? MU_LOGGEDIN : MU_ANONYMOUS ; ret = myUserName ; } else if ( flags ) * flags = MU_NOTLOGGEDIN ; return ret ; }
Return my user name
 Accepts: pointer to optional flags
 Returns: my user name
Return my user name Accepts : pointer to optional flags Returns : my user name
/* get user name if don't have it yet */ /* use callback, else logon name */ /* don't env_init if blocked */ /* try HOMEPATH, then HOME */ /* make sure doesn't end with delimiter */ /* initialize environment */ /* logged in? */ /* Guest is an anonymous user */ /* return user name */