Back to index

plt-scheme  4.2.1
Functions
Home.cc File Reference
#include "wx.h"
#include <pwd.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>

Go to the source code of this file.

Functions

char * wxGetUserHome (const char *user)

Function Documentation

char* wxGetUserHome ( const char *  user)

Definition at line 34 of file Home.cc.

{
    struct passwd *who = NULL;

    if (user == NULL || *user == '\0') {
       register char *ptr;

       if ((ptr = getenv("HOME")) != NULL) 
           return ptr;
       if ((ptr = getenv("USER")) != NULL
       || (ptr = getenv("LOGNAME")) != NULL) {
           who = getpwnam(ptr);
       }
       // We now make sure the user exists!
       if (who == NULL)
           who = getpwuid(getuid());
    } else
       who = getpwnam (user);
    return who ? who->pw_dir : (char*)NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function: