Re: [Openvpn-devel] [PATCH 2/2] Use %SystemRoot% instead of hard-codedC:\WINDOWS for temp directory path

2011-04-08 Thread Alon Bar-Lev
On Fri, Apr 8, 2011 at 7:03 PM, Gisle Vanem  wrote:
> Why not a bit simpler; GetTempPath() (kernel32.dll) already does these tests.
> Ref: http://msdn.microsoft.com/en-us/library/aa364992(v=vs.85).aspx :

Good catch.

Alon.



Re: [Openvpn-devel] [PATCH 2/2] Use %SystemRoot% instead of hard-codedC:\WINDOWS for temp directory path

2011-04-08 Thread Gisle Vanem

"David Sommerseth"  wrote:


-  /* Try to use %TEMP% or %TMP% */
-  tmpdir = getenv("TEMP");
-  if( !tmpdir ) {
-tmpdir = getenv("TMP");
+  CLEAR (tmpdir);
+
+  /* Try to use %TEMP%, %TMP% or %SystemRoot%\Temp */
+  envptr = getenv("TEMP");
+  if( envptr ) {
+return envptr;
  }
-  if( !tmpdir ) {
-/* Warn if we're using a hard coded path */
-msg (M_WARN, "Could not find %TEMP% or %TMP% environment variables.  "
- "Falling back to %s.  Consider to use --tmp-dir", DEFAULT_TMPDIR);
-tmpdir = DEFAULT_TMPDIR;


Why not a bit simpler; GetTempPath() (kernel32.dll) already does these tests. 
Ref: http://msdn.microsoft.com/en-us/library/aa364992(v=vs.85).aspx :


The GetTempPath function checks for the existence of environment 
variables in the following order and uses the first path found:

 1.. The path specified by the TMP environment variable.
 2.. The path specified by the TEMP environment variable.
 3.. The path specified by the USERPROFILE environment variable.
 4.. The Windows directory.

--gv