Sync with trunk (r48008)
[reactos.git] / dll / win32 / 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 #include <debug.h>
15
16 #define USZ {0,0,0}
17
18 /**********************************************************************
19 * AbortSystemShutdownW
20 *
21 * @unimplemented
22 */
23 BOOL WINAPI
24 AbortSystemShutdownW(LPCWSTR lpMachineName)
25 {
26 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
27 return FALSE;
28 }
29
30
31 /**********************************************************************
32 * AbortSystemShutdownA
33 *
34 * @unimplemented
35 */
36 BOOL WINAPI
37 AbortSystemShutdownA(LPCSTR lpMachineName)
38 {
39 ANSI_STRING MachineNameA;
40 UNICODE_STRING MachineNameW;
41 NTSTATUS Status;
42 BOOL rv;
43
44 RtlInitAnsiString(&MachineNameA, (LPSTR)lpMachineName);
45 Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE);
46 if (STATUS_SUCCESS != Status)
47 {
48 SetLastError(RtlNtStatusToDosError(Status));
49 return FALSE;
50 }
51
52 rv = AbortSystemShutdownW(MachineNameW.Buffer);
53 RtlFreeUnicodeString(&MachineNameW);
54 SetLastError(ERROR_SUCCESS);
55 return rv;
56 }
57
58
59 /**********************************************************************
60 * InitiateSystemShutdownW
61 *
62 * @unimplemented
63 */
64 BOOL WINAPI
65 InitiateSystemShutdownW(LPWSTR lpMachineName,
66 LPWSTR lpMessage,
67 DWORD dwTimeout,
68 BOOL bForceAppsClosed,
69 BOOL bRebootAfterShutdown)
70 {
71 SHUTDOWN_ACTION Action = ShutdownNoReboot;
72 NTSTATUS Status;
73
74 if (lpMachineName)
75 {
76 /* FIXME: remote machine shutdown not supported yet */
77 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
78 return FALSE;
79 }
80
81 if (dwTimeout)
82 {
83 }
84
85 Status = NtShutdownSystem(Action);
86 SetLastError(RtlNtStatusToDosError(Status));
87 return FALSE;
88 }
89
90
91 /**********************************************************************
92 * InitiateSystemShutdownA
93 *
94 * @unimplemented
95 */
96 BOOL
97 WINAPI
98 InitiateSystemShutdownA(LPSTR lpMachineName,
99 LPSTR lpMessage,
100 DWORD dwTimeout,
101 BOOL bForceAppsClosed,
102 BOOL bRebootAfterShutdown)
103 {
104 ANSI_STRING MachineNameA;
105 ANSI_STRING MessageA;
106 UNICODE_STRING MachineNameW;
107 UNICODE_STRING MessageW;
108 NTSTATUS Status;
109 INT LastError;
110 BOOL rv;
111
112 MachineNameW.Buffer = NULL;
113 MessageW.Buffer = NULL;
114
115 if (lpMachineName)
116 {
117 RtlInitAnsiString(&MachineNameA, lpMachineName);
118 Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE);
119 if (STATUS_SUCCESS != Status)
120 {
121 SetLastError(RtlNtStatusToDosError(Status));
122 return FALSE;
123 }
124 }
125
126 if (lpMessage)
127 {
128 RtlInitAnsiString(&MessageA, lpMessage);
129 Status = RtlAnsiStringToUnicodeString(&MessageW, &MessageA, TRUE);
130 if (STATUS_SUCCESS != Status)
131 {
132 if (MachineNameW.Buffer)
133 {
134 RtlFreeUnicodeString(&MachineNameW);
135 }
136
137 SetLastError(RtlNtStatusToDosError(Status));
138 return FALSE;
139 }
140 }
141
142 rv = InitiateSystemShutdownW(MachineNameW.Buffer,
143 MessageW.Buffer,
144 dwTimeout,
145 bForceAppsClosed,
146 bRebootAfterShutdown);
147 LastError = GetLastError();
148 if (lpMachineName)
149 {
150 RtlFreeUnicodeString(&MachineNameW);
151 }
152
153 if (lpMessage)
154 {
155 RtlFreeUnicodeString(&MessageW);
156 }
157
158 SetLastError(LastError);
159 return rv;
160 }
161
162 /******************************************************************************
163 * InitiateSystemShutdownExW [ADVAPI32.@]
164 *
165 * see InitiateSystemShutdownExA
166 */
167 BOOL WINAPI
168 InitiateSystemShutdownExW(LPWSTR lpMachineName,
169 LPWSTR lpMessage,
170 DWORD dwTimeout,
171 BOOL bForceAppsClosed,
172 BOOL bRebootAfterShutdown,
173 DWORD dwReason)
174 {
175 UNIMPLEMENTED;
176 return TRUE;
177 }
178
179 BOOL WINAPI
180 InitiateSystemShutdownExA(LPSTR lpMachineName,
181 LPSTR lpMessage,
182 DWORD dwTimeout,
183 BOOL bForceAppsClosed,
184 BOOL bRebootAfterShutdown,
185 DWORD dwReason)
186 {
187 UNIMPLEMENTED;
188 return TRUE;
189 }
190
191 /* EOF */