From 7c3a571168e3bef61b689524937af89e7efb07b0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 21 Aug 2012 14:30:41 -0500 Subject: Getting the directory using the home environment variable --- socket-sucker.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/socket-sucker.c b/socket-sucker.c index 0b1ee27..b5fb543 100644 --- a/socket-sucker.c +++ b/socket-sucker.c @@ -17,11 +17,16 @@ main (int argc, char * argv[]) bzero((char *)&serv_addr, sizeof(serv_addr)); + const char * home = getenv("HOME"); + if (home == NULL) { + return -1; + } + serv_addr.sun_family = AF_UNIX; - strcpy(serv_addr.sun_path, "/home/ted/.freerdp-socket"); + snprintf(serv_addr.sun_path, sizeof(serv_addr.sun_path), "%s/%s", home, ".freerdp-socket"); servlen = strlen(serv_addr.sun_path) + sizeof(serv_addr.sun_family); - if ((socket_fd = socket(AF_UNIX, SOCK_STREAM,0)) < 0) { + if ((socket_fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { return -1; } -- cgit v1.2.3