Eliminated warnings.
[wine] / dlls / advapi32 / advapi.c
1 /*
2  * Win32 advapi functions
3  *
4  * Copyright 1995 Sven Verdoolaege
5  */
6
7 #include <stdio.h>
8 #include <unistd.h>
9 #include <string.h>
10
11 #include "winbase.h"
12 #include "windef.h"
13 #include "winerror.h"
14 #include "wine/winestring.h"
15
16 #include "debugtools.h"
17
18
19 /******************************************************************************
20  * GetUserName32A [ADVAPI32.67]
21  */
22 BOOL WINAPI
23 GetUserNameA( LPSTR lpszName, LPDWORD lpSize )
24 {
25   size_t len;
26   char *name;
27
28   name=getlogin();
29 #if 0
30   /* FIXME: should use getpwuid() here */
31   if (!name) name=cuserid(NULL);
32 #endif
33   len = name ? strlen(name) : 0;
34   if (!len || !lpSize || len > *lpSize) {
35     if (lpszName) *lpszName = 0;
36     return 0;
37   }
38   *lpSize=len;
39   strcpy(lpszName, name);
40   return 1;
41 }
42
43 /******************************************************************************
44  * GetUserName32W [ADVAPI32.68]
45  *
46  * PARAMS
47  *   lpszName []
48  *   lpSize   []
49  */
50 BOOL WINAPI
51 GetUserNameW( LPWSTR lpszName, LPDWORD lpSize )
52 {
53         LPSTR name = (LPSTR)HeapAlloc( GetProcessHeap(), 0, *lpSize );
54         DWORD   size = *lpSize;
55         BOOL res = GetUserNameA(name,lpSize);
56
57         lstrcpynAtoW(lpszName,name,size);
58         HeapFree( GetProcessHeap(), 0, name );
59         return res;
60 }