Remove unused character width array.
[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 #include <pwd.h>
11
12 #include "winbase.h"
13 #include "windef.h"
14 #include "winnls.h"
15 #include "winerror.h"
16
17 #include "debugtools.h"
18
19
20 /******************************************************************************
21  * GetUserNameA [ADVAPI32.@]
22  */
23 BOOL WINAPI
24 GetUserNameA( LPSTR lpszName, LPDWORD lpSize )
25 {
26   size_t len;
27   char *name;
28
29   struct passwd *pwd = getpwuid( getuid() );
30   if (!pwd) return 0;
31   name = pwd->pw_name;
32   len = name ? strlen(name) : 0;
33   if (!len || !lpSize || len > *lpSize) {
34     if (lpszName) *lpszName = 0;
35     return 0;
36   }
37   *lpSize=len;
38   strcpy(lpszName, name);
39   return 1;
40 }
41
42 /******************************************************************************
43  * GetUserNameW [ADVAPI32.@]
44  *
45  * PARAMS
46  *   lpszName []
47  *   lpSize   []
48  */
49 BOOL WINAPI
50 GetUserNameW( LPWSTR lpszName, LPDWORD lpSize )
51 {
52         LPSTR name = (LPSTR)HeapAlloc( GetProcessHeap(), 0, *lpSize );
53         DWORD   size = *lpSize;
54         BOOL res = GetUserNameA(name,lpSize);
55
56         /* FIXME: should set lpSize in WCHARs */
57         if (size && !MultiByteToWideChar( CP_ACP, 0, name, -1, lpszName, size ))
58             lpszName[size-1] = 0;
59         HeapFree( GetProcessHeap(), 0, name );
60         return res;
61 }