Revision: 4177
          http://tigervnc.svn.sourceforge.net/tigervnc/?rev=4177&view=rev
Author:   atkac
Date:     2010-10-29 12:17:19 +0000 (Fri, 29 Oct 2010)

Log Message:
-----------
[Development] Use gethomedir() function in vncpasswd and vncviewer.

Modified Paths:
--------------
    trunk/unix/vncpasswd/Makefile.am
    trunk/unix/vncpasswd/vncpasswd.cxx
    trunk/unix/vncviewer/Makefile.am
    trunk/unix/vncviewer/vncviewer.cxx

Modified: trunk/unix/vncpasswd/Makefile.am
===================================================================
--- trunk/unix/vncpasswd/Makefile.am    2010-10-29 12:07:14 UTC (rev 4176)
+++ trunk/unix/vncpasswd/Makefile.am    2010-10-29 12:17:19 UTC (rev 4177)
@@ -7,6 +7,7 @@
 vncpasswd_CPPFLAGS = -I$(top_srcdir)/common
 
 vncpasswd_LDADD = $(top_builddir)/common/rfb/librfb.la \
-       $(top_builddir)/common/rdr/librdr.la
+       $(top_builddir)/common/rdr/librdr.la \
+       $(top_builddir)/common/os/libos.la
 
 EXTRA_DIST = vncpasswd.man

Modified: trunk/unix/vncpasswd/vncpasswd.cxx
===================================================================
--- trunk/unix/vncpasswd/vncpasswd.cxx  2010-10-29 12:07:14 UTC (rev 4176)
+++ trunk/unix/vncpasswd/vncpasswd.cxx  2010-10-29 12:17:19 UTC (rev 4177)
@@ -23,6 +23,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#include <os/os.h>
 #include <rfb/Password.h>
 #include <rfb/util.h>
 
@@ -100,14 +101,16 @@
   }
 
   if (!fname) {
-    if (!getenv("HOME")) {
-      fprintf(stderr,"HOME is not set\n");
+    char *homeDir = NULL;
+    if (gethomedir(&homeDir) == -1) {
+      fprintf(stderr, "Can't obtain home directory\n");
       exit(1);
     }
-    fname = new char[strlen(getenv("HOME")) + 20];
-    sprintf(fname, "%s/.vnc", getenv("HOME"));
+    fname = new char[strlen(homeDir) + 20];
+    sprintf(fname, "%s/.vnc", homeDir);
     mkdir(fname, 0777);
-    sprintf(fname, "%s/.vnc/passwd", getenv("HOME"));
+    sprintf(fname, "%s/.vnc/passwd", homeDir);
+    delete [] homeDir;
   }
 
   while (true) {

Modified: trunk/unix/vncviewer/Makefile.am
===================================================================
--- trunk/unix/vncviewer/Makefile.am    2010-10-29 12:07:14 UTC (rev 4176)
+++ trunk/unix/vncviewer/Makefile.am    2010-10-29 12:17:19 UTC (rev 4177)
@@ -16,6 +16,7 @@
        $(top_builddir)/common/rfb/librfb.la \
        $(top_builddir)/common/network/libnetwork.la \
        $(top_builddir)/common/rdr/librdr.la \
+       $(top_builddir)/common/os/libos.la \
        @X_PRE_LIBS@ @X_LIBS@ -lXext -lX11 @X_EXTRA_LIBS@ @GNUTLS_LIBS@ # 
@LIBINTL@
 
 if INCLUDED_ZLIB

Modified: trunk/unix/vncviewer/vncviewer.cxx
===================================================================
--- trunk/unix/vncviewer/vncviewer.cxx  2010-10-29 12:07:14 UTC (rev 4176)
+++ trunk/unix/vncviewer/vncviewer.cxx  2010-10-29 12:17:19 UTC (rev 4177)
@@ -31,6 +31,7 @@
 #include <errno.h>
 #include <signal.h>
 #include <locale.h>
+#include <os/os.h>
 #include <rfb/Logger_stdio.h>
 #include <rfb/LogWriter.h>
 #include <network/TcpSocket.h>
@@ -323,15 +324,17 @@
   }
 
   // Create .vnc in the user's home directory if it doesn't already exist
-  char* homeDir = getenv("HOME");
-  if (homeDir) {
+  char* homeDir = NULL;
+  if (gethomedir(&homeDir) == -1)
+    vlog.error("Could not create .vnc directory: can't obtain home directory 
path.");
+  else {
     CharArray vncDir(strlen(homeDir)+6);
     sprintf(vncDir.buf, "%s/.vnc", homeDir);
     int result =  mkdir(vncDir.buf, 0755);
     if (result == -1 && errno != EEXIST)
       vlog.error("Could not create .vnc directory: %s.", strerror(errno));
-  } else
-    vlog.error("Could not create .vnc directory: environment variable $HOME 
not set.");
+    delete [] homeDir;
+  }
 
   if (!::autoSelect.hasBeenSet()) {
     // Default to AutoSelect=0 if -PreferredEncoding or -FullColor is used


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Tigervnc-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tigervnc-commits

Reply via email to