7b5121461dd3b383b8ebf164674f4b79106f49a3
[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 #include <wine/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 SetLastError(RtlNtStatusToDosError(Status));
48 return FALSE;
49 }
50 rv = AbortSystemShutdownW(MachineNameW.Buffer);
51 RtlFreeAnsiString(&MachineNameA);
52 RtlFreeUnicodeString(&MachineNameW);
53 SetLastError(ERROR_SUCCESS);
54 return rv;
55 }
56
57
58 /**********************************************************************
59 * InitiateSystemShutdownW
60 *
61 * @unimplemented
62 */
63 BOOL STDCALL
64 InitiateSystemShutdownW(
65 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 /* FIXME: remote machine shutdown not supported yet */
76 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
77 return FALSE;
78 }
79 if (dwTimeout) {
80 }
81 Status = NtShutdownSystem(Action);
82 SetLastError(RtlNtStatusToDosError(Status));
83 return FALSE;
84 }
85
86
87 /**********************************************************************
88 * InitiateSystemShutdownA
89 *
90 * @unimplemented
91 */
92 BOOL
93 STDCALL
94 InitiateSystemShutdownA(
95 LPSTR lpMachineName,
96 LPSTR lpMessage,
97 DWORD dwTimeout,
98 BOOL bForceAppsClosed,
99 BOOL bRebootAfterShutdown)
100 {
101 ANSI_STRING MachineNameA;
102 ANSI_STRING MessageA;
103 UNICODE_STRING MachineNameW;
104 UNICODE_STRING MessageW;
105 NTSTATUS Status;
106 INT LastError;
107 BOOL rv;
108
109 if (lpMachineName) {
110 RtlInitAnsiString(&MachineNameA, lpMachineName);
111 Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE);
112 if (STATUS_SUCCESS != Status) {
113 RtlFreeAnsiString(&MachineNameA);
114 SetLastError(RtlNtStatusToDosError(Status));
115 return FALSE;
116 }
117 }
118 if (lpMessage) {
119 RtlInitAnsiString(&MessageA, lpMessage);
120 Status = RtlAnsiStringToUnicodeString(&MessageW, &MessageA, TRUE);
121 if (STATUS_SUCCESS != Status) {
122 if (MachineNameW.Length) {
123 RtlFreeAnsiString(&MachineNameA);
124 RtlFreeUnicodeString(&MachineNameW);
125 }
126 RtlFreeAnsiString(&MessageA);
127 SetLastError(RtlNtStatusToDosError(Status));
128 return FALSE;
129 }
130 }
131 rv = InitiateSystemShutdownW(
132 MachineNameW.Buffer,
133 MessageW.Buffer,
134 dwTimeout,
135 bForceAppsClosed,
136 bRebootAfterShutdown);
137 LastError = GetLastError();
138 if (lpMachineName) {
139 RtlFreeAnsiString(&MachineNameA);
140 RtlFreeUnicodeString(&MachineNameW);
141 }
142 if (lpMessage) {
143 RtlFreeAnsiString(&MessageA);
144 RtlFreeUnicodeString(&MessageW);
145 }
146 SetLastError(LastError);
147 return rv;
148 }
149
150 /******************************************************************************
151 * InitiateSystemShutdownExW [ADVAPI32.@]
152 *
153 * see InitiateSystemShutdownExA
154 */
155 BOOL WINAPI InitiateSystemShutdownExW( LPWSTR lpMachineName, LPWSTR lpMessage,
156 DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown,
157 DWORD dwReason)
158 {
159 FIXME("%s %s %ld %d %d %ld\n", debugstr_w(lpMachineName),
160 debugstr_w(lpMessage), dwTimeout, bForceAppsClosed,
161 bRebootAfterShutdown, dwReason);
162 return TRUE;
163 }
164
165 /* EOF */