-/* $Id: shutdown.c,v 1.6 2002/11/14 18:21:03 chorns Exp $\r
- *\r
- * COPYRIGHT: See COPYING in the top level directory\r
- * PROJECT: ReactOS system libraries\r
- * FILE: lib/advapi32/misc/shutdown.c\r
- * PURPOSE: System shutdown functions\r
- * PROGRAMMER: Emanuele Aliberti\r
- * UPDATE HISTORY:\r
- * 19990413 EA created\r
- * 19990515 EA\r
- */\r
-\r
-#include <windows.h>\r
-#define NTOS_MODE_USER\r
-#include <ntos.h>\r
-\r
-#define USZ {0,0,0}\r
-\r
-/**********************************************************************\r
- * AbortSystemShutdownW\r
- */\r
-WINBOOL\r
-STDCALL\r
-AbortSystemShutdownW(\r
- LPCWSTR lpMachineName\r
- )\r
-{\r
- NTSTATUS Status;\r
- \r
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);\r
- return FALSE;\r
-}\r
-\r
-\r
-/**********************************************************************\r
- * AbortSystemShutdownA\r
- */\r
-BOOL\r
-STDCALL\r
-AbortSystemShutdownA(\r
- LPCSTR lpMachineName\r
- )\r
-{\r
- ANSI_STRING MachineNameA;\r
- UNICODE_STRING MachineNameW;\r
- NTSTATUS Status;\r
- BOOL rv;\r
-\r
- RtlInitAnsiString(\r
- & MachineNameA,\r
- lpMachineName\r
- );\r
- Status = RtlAnsiStringToUnicodeString(\r
- & MachineNameW,\r
- & MachineNameA,\r
- TRUE\r
- );\r
- if (STATUS_SUCCESS != Status) \r
- {\r
- SetLastError(RtlNtStatusToDosError(Status));\r
- return FALSE;\r
- }\r
- rv = AbortSystemShutdownW(\r
- MachineNameW.Buffer\r
- );\r
- RtlFreeAnsiString(\r
- & MachineNameA\r
- );\r
- RtlFreeUnicodeString(\r
- & MachineNameW\r
- );\r
- SetLastError(ERROR_SUCCESS);\r
- return rv;\r
-}\r
-\r
-\r
-/**********************************************************************\r
- * InitiateSystemShutdownW\r
- */\r
-BOOL\r
-STDCALL\r
-InitiateSystemShutdownW(\r
- LPWSTR lpMachineName,\r
- LPWSTR lpMessage,\r
- DWORD dwTimeout,\r
- BOOL bForceAppsClosed,\r
- BOOL bRebootAfterShutdown\r
- )\r
-{\r
- SHUTDOWN_ACTION Action = ShutdownNoReboot;\r
- NTSTATUS Status;\r
-\r
- if (lpMachineName)\r
- {\r
- /* FIXME: remote machine shutdown not supported yet */\r
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);\r
- return FALSE;\r
- }\r
- if (dwTimeout)\r
- {\r
- }\r
- Status = NtShutdownSystem(Action);\r
- SetLastError(RtlNtStatusToDosError(Status));\r
- return FALSE;\r
-}\r
-\r
-\r
-/**********************************************************************\r
- * InitiateSystemShutdownA\r
- */\r
-BOOL\r
-STDCALL\r
-InitiateSystemShutdownA(\r
- LPSTR lpMachineName,\r
- LPSTR lpMessage,\r
- DWORD dwTimeout,\r
- BOOL bForceAppsClosed,\r
- BOOL bRebootAfterShutdown\r
- )\r
-{\r
- ANSI_STRING MachineNameA;\r
- ANSI_STRING MessageA;\r
- UNICODE_STRING MachineNameW;\r
- UNICODE_STRING MessageW;\r
- NTSTATUS Status;\r
- INT LastError;\r
- BOOL rv;\r
-\r
- if (lpMachineName)\r
- {\r
- RtlInitAnsiString(\r
- & MachineNameA,\r
- lpMachineName\r
- );\r
- Status = RtlAnsiStringToUnicodeString(\r
- & MachineNameW,\r
- & MachineNameA,\r
- TRUE\r
- );\r
- if (STATUS_SUCCESS != Status)\r
- {\r
- RtlFreeAnsiString(&MachineNameA);\r
- SetLastError(RtlNtStatusToDosError(Status));\r
- return FALSE;\r
- }\r
- }\r
- if (lpMessage)\r
- {\r
- RtlInitAnsiString(\r
- & MessageA,\r
- lpMessage\r
- );\r
- Status = RtlAnsiStringToUnicodeString(\r
- & MessageW,\r
- & MessageA,\r
- TRUE\r
- );\r
- if (STATUS_SUCCESS != Status)\r
- {\r
- if (MachineNameW.Length)\r
- {\r
- RtlFreeAnsiString(&MachineNameA);\r
- RtlFreeUnicodeString(&MachineNameW);\r
- }\r
- RtlFreeAnsiString(&MessageA);\r
- SetLastError(RtlNtStatusToDosError(Status));\r
- return FALSE;\r
- }\r
- }\r
- rv = InitiateSystemShutdownW(\r
- MachineNameW.Buffer,\r
- MessageW.Buffer,\r
- dwTimeout,\r
- bForceAppsClosed,\r
- bRebootAfterShutdown\r
- );\r
- LastError = GetLastError();\r
- if (lpMachineName)\r
- {\r
- RtlFreeAnsiString(&MachineNameA);\r
- RtlFreeUnicodeString(&MachineNameW);\r
- }\r
- if (lpMessage)\r
- {\r
- RtlFreeAnsiString(&MessageA);\r
- RtlFreeUnicodeString(&MessageW);\r
- }\r
- SetLastError(LastError);\r
- return rv;\r
-}\r
-\r
-\r
-/* EOF */\r
-\r
+/* $Id$
+ *
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS system libraries
+ * FILE: lib/advapi32/misc/shutdown.c
+ * PURPOSE: System shutdown functions
+ * PROGRAMMER: Emanuele Aliberti
+ * UPDATE HISTORY:
+ * 19990413 EA created
+ * 19990515 EA
+ */
+
+#include <advapi32.h>
+#include <wine/debug.h>
+
+#define USZ {0,0,0}
+
+/**********************************************************************
+ * AbortSystemShutdownW
+ *
+ * @unimplemented
+ */
+BOOL STDCALL
+AbortSystemShutdownW(LPCWSTR lpMachineName)
+{
+ SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+ return FALSE;
+}
+
+
+/**********************************************************************
+ * AbortSystemShutdownA
+ *
+ * @unimplemented
+ */
+BOOL STDCALL
+AbortSystemShutdownA(LPCSTR lpMachineName)
+{
+ ANSI_STRING MachineNameA;
+ UNICODE_STRING MachineNameW;
+ NTSTATUS Status;
+ BOOL rv;
+
+ RtlInitAnsiString(&MachineNameA, (LPSTR)lpMachineName);
+ Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE);
+ if (STATUS_SUCCESS != Status) {
+ SetLastError(RtlNtStatusToDosError(Status));
+ return FALSE;
+ }
+ rv = AbortSystemShutdownW(MachineNameW.Buffer);
+ RtlFreeUnicodeString(&MachineNameW);
+ SetLastError(ERROR_SUCCESS);
+ return rv;
+}
+
+
+/**********************************************************************
+ * InitiateSystemShutdownW
+ *
+ * @unimplemented
+ */
+BOOL STDCALL
+InitiateSystemShutdownW(
+ LPWSTR lpMachineName,
+ LPWSTR lpMessage,
+ DWORD dwTimeout,
+ BOOL bForceAppsClosed,
+ BOOL bRebootAfterShutdown)
+{
+ SHUTDOWN_ACTION Action = ShutdownNoReboot;
+ NTSTATUS Status;
+
+ if (lpMachineName) {
+ /* FIXME: remote machine shutdown not supported yet */
+ SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+ return FALSE;
+ }
+ if (dwTimeout) {
+ }
+ Status = NtShutdownSystem(Action);
+ SetLastError(RtlNtStatusToDosError(Status));
+ return FALSE;
+}
+
+
+/**********************************************************************
+ * InitiateSystemShutdownA
+ *
+ * @unimplemented
+ */
+BOOL
+STDCALL
+InitiateSystemShutdownA(
+ LPSTR lpMachineName,
+ LPSTR lpMessage,
+ DWORD dwTimeout,
+ BOOL bForceAppsClosed,
+ BOOL bRebootAfterShutdown)
+{
+ ANSI_STRING MachineNameA;
+ ANSI_STRING MessageA;
+ UNICODE_STRING MachineNameW;
+ UNICODE_STRING MessageW;
+ NTSTATUS Status;
+ INT LastError;
+ BOOL rv;
+
+ if (lpMachineName) {
+ RtlInitAnsiString(&MachineNameA, lpMachineName);
+ Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE);
+ if (STATUS_SUCCESS != Status) {
+ SetLastError(RtlNtStatusToDosError(Status));
+ return FALSE;
+ }
+ }
+ if (lpMessage) {
+ RtlInitAnsiString(&MessageA, lpMessage);
+ Status = RtlAnsiStringToUnicodeString(&MessageW, &MessageA, TRUE);
+ if (STATUS_SUCCESS != Status) {
+ if (MachineNameW.Length) {
+ RtlFreeUnicodeString(&MachineNameW);
+ }
+ SetLastError(RtlNtStatusToDosError(Status));
+ return FALSE;
+ }
+ }
+ rv = InitiateSystemShutdownW(
+ MachineNameW.Buffer,
+ MessageW.Buffer,
+ dwTimeout,
+ bForceAppsClosed,
+ bRebootAfterShutdown);
+ LastError = GetLastError();
+ if (lpMachineName) {
+ RtlFreeUnicodeString(&MachineNameW);
+ }
+ if (lpMessage) {
+ RtlFreeUnicodeString(&MessageW);
+ }
+ SetLastError(LastError);
+ return rv;
+}
+
+/******************************************************************************
+ * InitiateSystemShutdownExW [ADVAPI32.@]
+ *
+ * see InitiateSystemShutdownExA
+ */
+BOOL WINAPI InitiateSystemShutdownExW( LPWSTR lpMachineName, LPWSTR lpMessage,
+ DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown,
+ DWORD dwReason)
+{
+ FIXME("%s %s %ld %d %d %ld\n", debugstr_w(lpMachineName),
+ debugstr_w(lpMessage), dwTimeout, bForceAppsClosed,
+ bRebootAfterShutdown, dwReason);
+ return TRUE;
+}
+
+/* EOF */