wtmpnam implemented

Tim Holy holy at wustl.edu
Sat Nov 29 14:33:43 CST 2008


This patch implements the wtmpnam function in msvcrt. Thanks to Juan Lang 
for his help.

Best,
--Tim


-------------- next part --------------
diff -U 3 -r winecopy/wine-1.1.8/dlls/msvcrt/file.c wine-1.1.8/dlls/msvcrt/file.c
--- winecopy/wine-1.1.8/dlls/msvcrt/file.c	2008-11-07 10:09:33.000000000 -0600
+++ wine-1.1.8/dlls/msvcrt/file.c	2008-11-29 14:19:17.000000000 -0600
@@ -88,6 +88,7 @@
 
 /* INTERNAL: Static buffer for temp file name */
 static char MSVCRT_tmpname[MAX_PATH];
+static MSVCRT_wchar_t MSVCRT_wtmpname[MAX_PATH];
 
 static const unsigned int EXE = 'e' << 16 | 'x' << 8 | 'e';
 static const unsigned int BAT = 'b' << 16 | 'a' << 8 | 't';
@@ -2990,6 +2991,34 @@
 }
 
 /*********************************************************************
+ *		wtmpnam (MSVCRT.@)
+ */
+MSVCRT_wchar_t * CDECL MSVCRT_wtmpnam(MSVCRT_wchar_t *s)
+{
+  static int unique;
+  char tmpstr[16];
+  MSVCRT_wchar_t wtmpstr[16];
+  MSVCRT_wchar_t *p;
+  int count;
+  static const MSVCRT_wchar_t tmpFmt[] = { '\\','s','%','s','.',0 };
+
+  if (s == 0)
+    s = MSVCRT_wtmpname;
+  msvcrt_int_to_base32(GetCurrentProcessId(), tmpstr);
+  p = s + MSVCRT_vsnwprintf(s, 16, tmpFmt, tmpstr);
+  for (count = 0; count < MSVCRT_TMP_MAX; count++)
+  {
+    msvcrt_int_to_base32(unique++, tmpstr);
+    MultiByteToWideChar(CP_ACP, 0, tmpstr, strlen(tmpstr), wtmpstr, 16);
+    strcpyW(p, wtmpstr);
+    if (GetFileAttributesW(s) == INVALID_FILE_ATTRIBUTES &&
+        GetLastError() == ERROR_FILE_NOT_FOUND)
+      break;
+  }
+  return s;
+}
+
+/*********************************************************************
  *		tmpfile (MSVCRT.@)
  */
 MSVCRT_FILE* CDECL MSVCRT_tmpfile(void)
diff -U 3 -r winecopy/wine-1.1.8/dlls/msvcrt/msvcrt.spec wine-1.1.8/dlls/msvcrt/msvcrt.spec
--- winecopy/wine-1.1.8/dlls/msvcrt/msvcrt.spec	2008-11-07 10:09:33.000000000 -0600
+++ wine-1.1.8/dlls/msvcrt/msvcrt.spec	2008-11-29 10:32:02.000000000 -0600
@@ -579,7 +579,7 @@
 @ cdecl _wstrtime(ptr)
 @ cdecl _wsystem(wstr)
 @ cdecl _wtempnam(wstr wstr)
-@ stub _wtmpnam #(ptr)
+@ cdecl _wtmpnam(ptr) MSVCRT_wtmpnam
 @ cdecl _wtoi(wstr) ntdll._wtoi
 @ cdecl _wtoi64(wstr) ntdll._wtoi64
 @ cdecl _wtol(wstr) ntdll._wtol


More information about the wine-patches mailing list