Added YUV routines needed for v4l driver, and in the future possibly
[wine/gsoc-2012-control.git] / dlls / advapi32 / advapi.c
blob04c88272e0fa8e435658308d95ac1a45034bf252
1 /*
2 * Win32 advapi functions
4 * Copyright 1995 Sven Verdoolaege
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
22 #include "wine/port.h"
24 #include <errno.h>
25 #include <stdio.h>
26 #include <string.h>
27 #include <stdarg.h>
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winnls.h"
32 #include "winreg.h"
33 #include "winerror.h"
35 #include "wine/library.h"
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
40 /******************************************************************************
41 * GetUserNameA [ADVAPI32.@]
43 * Get the current user name.
45 * PARAMS
46 * lpszName [O] Destination for the user name.
47 * lpSize [I/O] Size of lpszName.
49 * RETURNS
50 * Success: The length of the user name, including terminating NUL.
51 * Failure: ERROR_MORE_DATA if *lpSize is too small.
53 BOOL WINAPI
54 GetUserNameA( LPSTR lpszName, LPDWORD lpSize )
56 WCHAR *buffer;
57 BOOL ret;
58 DWORD sizeW = *lpSize * 2;
60 if (!(buffer = HeapAlloc( GetProcessHeap(), 0, sizeW * sizeof(WCHAR) )))
62 SetLastError( ERROR_NOT_ENOUGH_MEMORY );
63 return FALSE;
65 ret = GetUserNameW( buffer, &sizeW );
66 if (ret)
68 if (!(*lpSize = WideCharToMultiByte( CP_ACP, 0, buffer, -1, lpszName, *lpSize, NULL, NULL )))
70 *lpSize = WideCharToMultiByte( CP_ACP, 0, buffer, -1, NULL, 0, NULL, NULL );
71 SetLastError( ERROR_MORE_DATA );
72 ret = FALSE;
75 else *lpSize = sizeW * 2;
76 HeapFree( GetProcessHeap(), 0, buffer );
77 return ret;
80 /******************************************************************************
81 * GetUserNameW [ADVAPI32.@]
83 * See GetUserNameA.
85 BOOL WINAPI
86 GetUserNameW( LPWSTR lpszName, LPDWORD lpSize )
88 const char *name = wine_get_user_name();
89 DWORD len = MultiByteToWideChar( CP_UNIXCP, 0, name, -1, NULL, 0 );
91 if (len > *lpSize)
93 SetLastError(ERROR_MORE_DATA);
94 *lpSize = len;
95 return FALSE;
98 *lpSize = len;
99 MultiByteToWideChar( CP_UNIXCP, 0, name, -1, lpszName, len );
100 return TRUE;
103 /******************************************************************************
104 * GetCurrentHwProfileA [ADVAPI32.@]
106 * Get the current hardware profile.
108 * PARAMS
109 * pInfo [O] Destination for hardware profile information.
111 * RETURNS
112 * Success: TRUE. pInfo is updated with the hardware profile details.
113 * Failure: FALSE.
115 BOOL WINAPI GetCurrentHwProfileA(LPHW_PROFILE_INFOA pInfo)
117 FIXME("(%p) semi-stub\n", pInfo);
118 pInfo->dwDockInfo = DOCKINFO_DOCKED;
119 strcpy(pInfo->szHwProfileGuid,"{12340001-1234-1234-1234-1233456789012}");
120 strcpy(pInfo->szHwProfileName,"Wine Profile");
121 return 1;
124 /******************************************************************************
125 * GetCurrentHwProfileW [ADVAPI32.@]
127 * See GetCurrentHwProfileA.
129 BOOL WINAPI GetCurrentHwProfileW(LPHW_PROFILE_INFOW pInfo)
131 FIXME("(%p)\n", pInfo);
132 return FALSE;
135 /******************************************************************************
136 * AbortSystemShutdownA [ADVAPI32.@]
138 * Stop a system shutdown if one is in progress.
140 * PARAMS
141 * lpMachineName [I] Name of machine to not shutdown.
143 * RETURNS
144 * Success: TRUE.
145 * Failure: FALSE.
147 * NOTES
148 * The Wine implementation of this function is a harmless stub.
150 BOOL WINAPI AbortSystemShutdownA( LPSTR lpMachineName )
152 TRACE("stub %s (harmless)\n", lpMachineName);
153 return TRUE;
156 /******************************************************************************
157 * AbortSystemShutdownW [ADVAPI32.@]
159 * See AbortSystemShutdownA.
161 BOOL WINAPI AbortSystemShutdownW( LPWSTR lpMachineName )
163 TRACE("stub %s (harmless)\n", debugstr_w(lpMachineName));
164 return TRUE;
167 /******************************************************************************
168 * InitiateSystemShutdownExA [ADVAPI32.@]
170 * Initiate a shutdown or optionally restart the computer.
172 * PARAMS
173 * lpMachineName [I] Network name of machine to shutdown.
174 * lpMessage [I] Message displayed in shutdown dialog box.
175 * dwTimeout [I] Number of seconds dialog is displayed before shutdown.
176 * bForceAppsClosed [I] If TRUE, apps close without saving, else dialog is
177 * displayed requesting user to close apps.
178 * bRebootAfterShutdown [I] If TRUE, system reboots after restart, else the
179 * system flushes all caches to disk and clears
180 * the screen
181 * dwReason [I] Reason for shutting down. Must be a system shutdown reason
182 * code.
184 * RETURNS
185 * Success: TRUE
186 * Failure: FALSE
188 * NOTES
189 * if lpMachineName is NULL, the local computer is shutdown.
191 BOOL WINAPI InitiateSystemShutdownExA( LPSTR lpMachineName, LPSTR lpMessage,
192 DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown,
193 DWORD dwReason)
195 FIXME("%s %s %ld %d %d %ld\n", debugstr_a(lpMachineName),
196 debugstr_a(lpMessage), dwTimeout, bForceAppsClosed,
197 bRebootAfterShutdown, dwReason);
198 return TRUE;
201 /******************************************************************************
202 * InitiateSystemShutdownExW [ADVAPI32.@]
204 * see InitiateSystemShutdownExA
206 BOOL WINAPI InitiateSystemShutdownExW( LPWSTR lpMachineName, LPWSTR lpMessage,
207 DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown,
208 DWORD dwReason)
210 FIXME("%s %s %ld %d %d %ld\n", debugstr_w(lpMachineName),
211 debugstr_w(lpMessage), dwTimeout, bForceAppsClosed,
212 bRebootAfterShutdown, dwReason);
213 return TRUE;
216 BOOL WINAPI InitiateSystemShutdownA( LPSTR lpMachineName, LPSTR lpMessage, DWORD dwTimeout,
217 BOOL bForceAppsClosed, BOOL bRebootAfterShutdown )
219 return InitiateSystemShutdownExA( lpMachineName, lpMessage, dwTimeout,
220 bForceAppsClosed, bRebootAfterShutdown,
221 SHTDN_REASON_MAJOR_LEGACY_API );
224 BOOL WINAPI InitiateSystemShutdownW( LPWSTR lpMachineName, LPWSTR lpMessage, DWORD dwTimeout,
225 BOOL bForceAppsClosed, BOOL bRebootAfterShutdown )
227 return InitiateSystemShutdownExW( lpMachineName, lpMessage, dwTimeout,
228 bForceAppsClosed, bRebootAfterShutdown,
229 SHTDN_REASON_MAJOR_LEGACY_API );
232 BOOL WINAPI LogonUserA( LPCSTR lpszUsername, LPCSTR lpszDomain, LPCSTR lpszPassword,
233 DWORD dwLogonType, DWORD dwLogonProvider, PHANDLE phToken )
235 FIXME("%s %s %p 0x%08lx 0x%08lx %p - stub\n", debugstr_a(lpszUsername),
236 debugstr_a(lpszDomain), lpszPassword, dwLogonType, dwLogonProvider, phToken);
238 return TRUE;
241 BOOL WINAPI LogonUserW( LPCWSTR lpszUsername, LPCWSTR lpszDomain, LPCWSTR lpszPassword,
242 DWORD dwLogonType, DWORD dwLogonProvider, PHANDLE phToken )
244 FIXME("%s %s %p 0x%08lx 0x%08lx %p - stub\n", debugstr_w(lpszUsername),
245 debugstr_w(lpszDomain), lpszPassword, dwLogonType, dwLogonProvider, phToken);
247 return TRUE;
250 DWORD WINAPI CommandLineFromMsiDescriptor(WCHAR *Descriptor, WCHAR *CommandLine,
251 DWORD *CommandLineLength)
253 FIXME("stub (%s)\n", debugstr_w(Descriptor));
254 return ERROR_CALL_NOT_IMPLEMENTED;