Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
2a3484a2
Commit
2a3484a2
authored
May 03, 2011
by
Piotr Caban
Committed by
Alexandre Julliard
May 03, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Added _wtmpnam implementation.
parent
3a91df11
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
7 deletions
+59
-7
file.c
dlls/msvcrt/file.c
+58
-6
msvcrt.spec
dlls/msvcrt/msvcrt.spec
+1
-1
No files found.
dlls/msvcrt/file.c
View file @
2a3484a2
...
...
@@ -88,8 +88,10 @@ static int MSVCRT_stream_idx;
/* INTERNAL: process umask */
static
int
MSVCRT_umask
=
0
;
/* INTERNAL: Static buffer for temp file name */
/* INTERNAL: static data for tmpnam and _wtmpname functions */
static
int
tmpnam_unique
;
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'
;
...
...
@@ -455,7 +457,7 @@ static void msvcrt_alloc_buffer(MSVCRT_FILE* file)
}
/* INTERNAL: Convert integer to base32 string (0-9a-v), 0 becomes "" */
static
void
msvcrt_int_to_base32
(
int
num
,
char
*
str
)
static
int
msvcrt_int_to_base32
(
int
num
,
char
*
str
)
{
char
*
p
;
int
n
=
num
;
...
...
@@ -475,6 +477,33 @@ static void msvcrt_int_to_base32(int num, char *str)
*
p
+=
(
'a'
-
'0'
-
10
);
num
>>=
5
;
}
return
digits
;
}
/* INTERNAL: wide character version of msvcrt_int_to_base32 */
static
int
msvcrt_int_to_base32_w
(
int
num
,
MSVCRT_wchar_t
*
str
)
{
MSVCRT_wchar_t
*
p
;
int
n
=
num
;
int
digits
=
0
;
while
(
n
!=
0
)
{
n
>>=
5
;
digits
++
;
}
p
=
str
+
digits
;
*
p
=
0
;
while
(
--
p
>=
str
)
{
*
p
=
(
num
&
31
)
+
'0'
;
if
(
*
p
>
'9'
)
*
p
+=
(
'a'
-
'0'
-
10
);
num
>>=
5
;
}
return
digits
;
}
/*********************************************************************
...
...
@@ -3336,18 +3365,17 @@ void CDECL MSVCRT_setbuf(MSVCRT_FILE* file, char *buf)
*/
char
*
CDECL
MSVCRT_tmpnam
(
char
*
s
)
{
static
int
unique
;
char
tmpstr
[
16
];
char
*
p
;
int
count
;
int
count
,
size
;
if
(
s
==
0
)
s
=
MSVCRT_tmpname
;
msvcrt_int_to_base32
(
GetCurrentProcessId
(),
tmpstr
);
p
=
s
+
sprintf
(
s
,
"
\\
s%s."
,
tmpstr
);
for
(
count
=
0
;
count
<
MSVCRT_TMP_MAX
;
count
++
)
{
msvcrt_int_to_base32
(
unique
++
,
tmpstr
);
strcpy
(
p
,
tmpstr
);
size
=
msvcrt_int_to_base32
(
tmpnam_
unique
++
,
tmpstr
);
memcpy
(
p
,
tmpstr
,
size
);
if
(
GetFileAttributesA
(
s
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
)
break
;
...
...
@@ -3356,6 +3384,30 @@ char * CDECL MSVCRT_tmpnam(char *s)
}
/*********************************************************************
* _wtmpnam (MSVCRT.@)
*/
MSVCRT_wchar_t
*
MSVCRT_wtmpnam
(
MSVCRT_wchar_t
*
s
)
{
static
const
MSVCRT_wchar_t
format
[]
=
{
'\\'
,
's'
,
'%'
,
's'
,
'.'
,
0
};
MSVCRT_wchar_t
tmpstr
[
16
];
MSVCRT_wchar_t
*
p
;
int
count
,
size
;
if
(
s
==
0
)
s
=
MSVCRT_wtmpname
;
msvcrt_int_to_base32_w
(
GetCurrentProcessId
(),
tmpstr
);
p
=
s
+
MSVCRT__snwprintf
(
s
,
MAX_PATH
,
format
,
tmpstr
);
for
(
count
=
0
;
count
<
MSVCRT_TMP_MAX
;
count
++
)
{
size
=
msvcrt_int_to_base32_w
(
tmpnam_unique
++
,
tmpstr
);
memcpy
(
p
,
tmpstr
,
size
*
sizeof
(
MSVCRT_wchar_t
));
if
(
GetFileAttributesW
(
s
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
)
break
;
}
return
s
;
}
/*********************************************************************
* tmpfile (MSVCRT.@)
*/
MSVCRT_FILE
*
CDECL
MSVCRT_tmpfile
(
void
)
...
...
dlls/msvcrt/msvcrt.spec
View file @
2a3484a2
...
...
@@ -1192,7 +1192,7 @@
@ cdecl _wsystem(wstr)
@ cdecl _wtempnam(wstr wstr)
# stub _wtempnam_dbg(wstr wstr long str long)
@
stub _wtmpnam(ptr)
@
cdecl _wtmpnam(ptr) MSVCRT_wtmpnam
# stub _wtmpnam_s(ptr long)
@ cdecl _wtof(wstr) MSVCRT__wtof
@ cdecl _wtof_l(wstr ptr) MSVCRT__wtof_l
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment