[Tim Holy][msvcrt]Implement _wtmpnam
Uwe Bonnes
bon at elektron.ikp.physik.tu-darmstadt.de
Mon Jan 25 12:02:00 CST 2010
---
dlls/msvcrt/file.c | 29 +++++++++++++++++++++++++++++
dlls/msvcrt/msvcrt.spec | 2 +-
2 files changed, 30 insertions(+), 1 deletions(-)
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index 655f17e..d9db245 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -89,6 +89,7 @@ static int MSVCRT_umask = 0;
/* 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';
@@ -3176,6 +3177,34 @@ char * CDECL MSVCRT_tmpnam(char *s)
}
/*********************************************************************
+ * 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 --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec
index 2b3d22c..c25a698 100644
--- a/dlls/msvcrt/msvcrt.spec
+++ b/dlls/msvcrt/msvcrt.spec
@@ -610,7 +610,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
--
1.6.4.2
More information about the wine-patches
mailing list