[FORMATTING] No code changes!
[reactos.git] / reactos / 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 STDCALL
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 STDCALL
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 STDCALL
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 STDCALL
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 if (lpMachineName)
113 {
114 RtlInitAnsiString(&MachineNameA, lpMachineName);
115 Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE);
116 if (STATUS_SUCCESS != Status)
117 {
118 SetLastError(RtlNtStatusToDosError(Status));
119 return FALSE;
120 }
121 }
122
123 if (lpMessage)
124 {
125 RtlInitAnsiString(&MessageA, lpMessage);
126 Status = RtlAnsiStringToUnicodeString(&MessageW, &MessageA, TRUE);
127 if (STATUS_SUCCESS != Status)
128 {
129 if (MachineNameW.Length)
130 {
131 RtlFreeUnicodeString(&MachineNameW);
132 }
133
134 SetLastError(RtlNtStatusToDosError(Status));
135 return FALSE;
136 }
137 }
138
139 rv = InitiateSystemShutdownW(MachineNameW.Buffer,
140 MessageW.Buffer,
141 dwTimeout,
142 bForceAppsClosed,
143 bRebootAfterShutdown);
144 LastError = GetLastError();
145 if (lpMachineName)
146 {
147 RtlFreeUnicodeString(&MachineNameW);
148 }
149
150 if (lpMessage)
151 {
152 RtlFreeUnicodeString(&MessageW);
153 }
154
155 SetLastError(LastError);
156 return rv;
157 }
158
159 /******************************************************************************
160 * InitiateSystemShutdownExW [ADVAPI32.@]
161 *
162 * see InitiateSystemShutdownExA
163 */
164 BOOL WINAPI
165 InitiateSystemShutdownExW(LPWSTR lpMachineName,
166 LPWSTR lpMessage,
167 DWORD dwTimeout,
168 BOOL bForceAppsClosed,
169 BOOL bRebootAfterShutdown,
170 DWORD dwReason)
171 {
172 UNIMPLEMENTED;
173 return TRUE;
174 }
175
176 /* EOF */