summaryrefslogtreecommitdiff
path: root/clients/xzwrite/gethomedir.c
blob: ffd25bf113e775083398ff400612241e4d8ff745 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <stdio.h>
#include <pwd.h>
#include "xzwrite.h"

char *get_home_dir()
{
     struct passwd    *pwuid;
     static char      *h = NULL;

     if (h) return h;
     
     if ((h = getenv("HOME")) != NULL) return h;
     
     pwuid = getpwuid(getuid());
     return (pwuid->pw_dir);
}