#include <stdio.h>
#include <unistd.h>

char *PutHome (char path_with_home[])
{
    char *Home;                 /* the HOME environment variable */
    char *realpath;

/* home dir ? */
                        if (strncmp(path_with_home, "~/", 2) == 0) {
/* get home */
                                Home = (char *) getenv("HOME");
                                if (Home == NULL)
                                        Home = "./";
/* alloc it */
                                realpath = (char *) safemalloc(strlen(Home) + strlen(&path_with_home[2]) + 3);
/* put it */
                                strcpy(realpath, Home);
                                strcat(realpath, "/");
                                strcat(realpath, &path_with_home[2]);
                        }
                        else
                        realpath  = path_with_home;

return realpath;
}
