migrate substitution keywords to SVN
[reactos.git] / reactos / lib / advapi32 / misc / shutdown.c
1 /* $Id$
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: lib/advapi32/misc/shutdown.c
6 * PURPOSE: System shutdown functions
7 * PROGRAMMER: Emanuele Aliberti
8 * UPDATE HISTORY:
9 * 19990413 EA created
10 * 19990515 EA
11 */
12
13 #include "advapi32.h"
14
15 #define USZ {0,0,0}
16
17 /**********************************************************************
18 * AbortSystemShutdownW
19 *
20 * @unimplemented
21 */
22 BOOL STDCALL
23 AbortSystemShutdownW(LPCWSTR lpMachineName)
24 {
25 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
26 return FALSE;
27 }
28
29
30 /**********************************************************************
31 * AbortSystemShutdownA
32 *
33 * @unimplemented
34 */
35 BOOL STDCALL
36 AbortSystemShutdownA(LPCSTR lpMachineName)
37 {
38 ANSI_STRING MachineNameA;
39 UNICODE_STRING MachineNameW;
40 NTSTATUS Status;
41 BOOL rv;
42
43 RtlInitAnsiString(&MachineNameA, (LPSTR)lpMachineName);
44 Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE);
45 if (STATUS_SUCCESS != Status) {
46 SetLastError(RtlNtStatusToDosError(Status));
47 return FALSE;
48 }
49 rv = AbortSystemShutdownW(MachineNameW.Buffer);
50 RtlFreeAnsiString(&MachineNameA);
51 RtlFreeUnicodeString(&MachineNameW);
52 SetLastError(ERROR_SUCCESS);
53 return rv;
54 }
55
56
57 /**********************************************************************
58 * InitiateSystemShutdownW
59 *
60 * @unimplemented
61 */
62 BOOL STDCALL
63 InitiateSystemShutdownW(
64 LPWSTR lpMachineName,
65 LPWSTR lpMessage,
66 DWORD dwTimeout,
67 BOOL bForceAppsClosed,
68 BOOL bRebootAfterShutdown)
69 {
70 SHUTDOWN_ACTION Action = ShutdownNoReboot;
71 NTSTATUS Status;
72
73 if (lpMachineName) {
74 /* FIXME: remote machine shutdown not supported yet */
75 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
76 return FALSE;
77 }
78 if (dwTimeout) {
79 }
80 Status = NtShutdownSystem(Action);
81 SetLastError(RtlNtStatusToDosError(Status));
82 return FALSE;
83 }
84
85
86 /**********************************************************************
87 * InitiateSystemShutdownA
88 *
89 * @unimplemented
90 */
91 BOOL
92 STDCALL
93 InitiateSystemShutdownA(
94 LPSTR lpMachineName,
95 LPSTR lpMessage,
96 DWORD dwTimeout,
97 BOOL bForceAppsClosed,
98 BOOL bRebootAfterShutdown)
99 {
100 ANSI_STRING MachineNameA;
101 ANSI_STRING MessageA;
102 UNICODE_STRING MachineNameW;
103 UNICODE_STRING MessageW;
104 NTSTATUS Status;
105 INT LastError;
106 BOOL rv;
107
108 if (lpMachineName) {
109 RtlInitAnsiString(&MachineNameA, lpMachineName);
110 Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE);
111 if (STATUS_SUCCESS != Status) {
112 RtlFreeAnsiString(&MachineNameA);
113 SetLastError(RtlNtStatusToDosError(Status));
114 return FALSE;
115 }
116 }
117 if (lpMessage) {
118 RtlInitAnsiString(&MessageA, lpMessage);
119 Status = RtlAnsiStringToUnicodeString(&MessageW, &MessageA, TRUE);
120 if (STATUS_SUCCESS != Status) {
121 if (MachineNameW.Length) {
122 RtlFreeAnsiString(&MachineNameA);
123 RtlFreeUnicodeString(&MachineNameW);
124 }
125 RtlFreeAnsiString(&MessageA);
126 SetLastError(RtlNtStatusToDosError(Status));
127 return FALSE;
128 }
129 }
130 rv = InitiateSystemShutdownW(
131 MachineNameW.Buffer,
132 MessageW.Buffer,
133 dwTimeout,
134 bForceAppsClosed,
135 bRebootAfterShutdown);
136 LastError = GetLastError();
137 if (lpMachineName) {
138 RtlFreeAnsiString(&MachineNameA);
139 RtlFreeUnicodeString(&MachineNameW);
140 }
141 if (lpMessage) {
142 RtlFreeAnsiString(&MessageA);
143 RtlFreeUnicodeString(&MessageW);
144 }
145 SetLastError(LastError);
146 return rv;
147 }
148
149 /* EOF */