don't try to free the ansi strings passed by the caller
[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 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 SetLastError(RtlNtStatusToDosError(Status));
113 return FALSE;
114 }
115 }
116 if (lpMessage) {
117 RtlInitAnsiString(&MessageA, lpMessage);
118 Status = RtlAnsiStringToUnicodeString(&MessageW, &MessageA, TRUE);
119 if (STATUS_SUCCESS != Status) {
120 if (MachineNameW.Length) {
121 RtlFreeUnicodeString(&MachineNameW);
122 }
123 SetLastError(RtlNtStatusToDosError(Status));
124 return FALSE;
125 }
126 }
127 rv = InitiateSystemShutdownW(
128 MachineNameW.Buffer,
129 MessageW.Buffer,
130 dwTimeout,
131 bForceAppsClosed,
132 bRebootAfterShutdown);
133 LastError = GetLastError();
134 if (lpMachineName) {
135 RtlFreeUnicodeString(&MachineNameW);
136 }
137 if (lpMessage) {
138 RtlFreeUnicodeString(&MessageW);
139 }
140 SetLastError(LastError);
141 return rv;
142 }
143
144 /******************************************************************************
145 * InitiateSystemShutdownExW [ADVAPI32.@]
146 *
147 * see InitiateSystemShutdownExA
148 */
149 BOOL WINAPI InitiateSystemShutdownExW( LPWSTR lpMachineName, LPWSTR lpMessage,
150 DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown,
151 DWORD dwReason)
152 {
153 FIXME("%s %s %ld %d %d %ld\n", debugstr_w(lpMachineName),
154 debugstr_w(lpMessage), dwTimeout, bForceAppsClosed,
155 bRebootAfterShutdown, dwReason);
156 return TRUE;
157 }
158
159 /* EOF */