xref: /reactos/dll/win32/netapi32/schedule.c (revision c2c66aff)
1*c2c66affSColin Finck /*
2*c2c66affSColin Finck  * COPYRIGHT:       See COPYING in the top level directory
3*c2c66affSColin Finck  * PROJECT:         NetAPI DLL
4*c2c66affSColin Finck  * FILE:            reactos/dll/win32/netapi32/schedule.c
5*c2c66affSColin Finck  * PURPOSE:         Scheduler service interface code
6*c2c66affSColin Finck  *
7*c2c66affSColin Finck  * PROGRAMMERS:     Eric Kohl
8*c2c66affSColin Finck  */
9*c2c66affSColin Finck 
10*c2c66affSColin Finck /* INCLUDES ******************************************************************/
11*c2c66affSColin Finck 
12*c2c66affSColin Finck #include "netapi32.h"
13*c2c66affSColin Finck #include "atsvc_c.h"
14*c2c66affSColin Finck 
15*c2c66affSColin Finck WINE_DEFAULT_DEBUG_CHANNEL(netapi32);
16*c2c66affSColin Finck 
17*c2c66affSColin Finck /* FUNCTIONS *****************************************************************/
18*c2c66affSColin Finck 
19*c2c66affSColin Finck handle_t __RPC_USER
ATSVC_HANDLE_bind(ATSVC_HANDLE pszSystemName)20*c2c66affSColin Finck ATSVC_HANDLE_bind(ATSVC_HANDLE pszSystemName)
21*c2c66affSColin Finck {
22*c2c66affSColin Finck     handle_t hBinding = NULL;
23*c2c66affSColin Finck     LPWSTR pszStringBinding;
24*c2c66affSColin Finck     RPC_STATUS status;
25*c2c66affSColin Finck 
26*c2c66affSColin Finck     TRACE("ATSVC_HANDLE_bind() called\n");
27*c2c66affSColin Finck 
28*c2c66affSColin Finck     status = RpcStringBindingComposeW(NULL,
29*c2c66affSColin Finck                                       L"ncacn_np",
30*c2c66affSColin Finck                                       (RPC_WSTR)pszSystemName,
31*c2c66affSColin Finck                                       L"\\pipe\\atsvc",
32*c2c66affSColin Finck                                       NULL,
33*c2c66affSColin Finck                                       &pszStringBinding);
34*c2c66affSColin Finck     if (status)
35*c2c66affSColin Finck     {
36*c2c66affSColin Finck         TRACE("RpcStringBindingCompose returned 0x%x\n", status);
37*c2c66affSColin Finck         return NULL;
38*c2c66affSColin Finck     }
39*c2c66affSColin Finck 
40*c2c66affSColin Finck     /* Set the binding handle that will be used to bind to the server. */
41*c2c66affSColin Finck     status = RpcBindingFromStringBindingW(pszStringBinding,
42*c2c66affSColin Finck                                           &hBinding);
43*c2c66affSColin Finck     if (status)
44*c2c66affSColin Finck     {
45*c2c66affSColin Finck         TRACE("RpcBindingFromStringBinding returned 0x%x\n", status);
46*c2c66affSColin Finck     }
47*c2c66affSColin Finck 
48*c2c66affSColin Finck     status = RpcStringFreeW(&pszStringBinding);
49*c2c66affSColin Finck     if (status)
50*c2c66affSColin Finck     {
51*c2c66affSColin Finck //        TRACE("RpcStringFree returned 0x%x\n", status);
52*c2c66affSColin Finck     }
53*c2c66affSColin Finck 
54*c2c66affSColin Finck     return hBinding;
55*c2c66affSColin Finck }
56*c2c66affSColin Finck 
57*c2c66affSColin Finck 
58*c2c66affSColin Finck void __RPC_USER
ATSVC_HANDLE_unbind(ATSVC_HANDLE pszSystemName,handle_t hBinding)59*c2c66affSColin Finck ATSVC_HANDLE_unbind(ATSVC_HANDLE pszSystemName,
60*c2c66affSColin Finck                     handle_t hBinding)
61*c2c66affSColin Finck {
62*c2c66affSColin Finck     RPC_STATUS status;
63*c2c66affSColin Finck 
64*c2c66affSColin Finck     TRACE("ATSVC_HANDLE_unbind() called\n");
65*c2c66affSColin Finck 
66*c2c66affSColin Finck     status = RpcBindingFree(&hBinding);
67*c2c66affSColin Finck     if (status)
68*c2c66affSColin Finck     {
69*c2c66affSColin Finck         TRACE("RpcBindingFree returned 0x%x\n", status);
70*c2c66affSColin Finck     }
71*c2c66affSColin Finck }
72*c2c66affSColin Finck 
73*c2c66affSColin Finck 
74*c2c66affSColin Finck NET_API_STATUS
75*c2c66affSColin Finck WINAPI
NetScheduleJobAdd(LPCWSTR ServerName,LPBYTE Buffer,LPDWORD JobId)76*c2c66affSColin Finck NetScheduleJobAdd(
77*c2c66affSColin Finck     LPCWSTR ServerName,
78*c2c66affSColin Finck     LPBYTE Buffer,
79*c2c66affSColin Finck     LPDWORD JobId)
80*c2c66affSColin Finck {
81*c2c66affSColin Finck     NET_API_STATUS status;
82*c2c66affSColin Finck 
83*c2c66affSColin Finck     TRACE("NetScheduleJobAdd(%s, %p, %p)\n", debugstr_w(ServerName),
84*c2c66affSColin Finck           Buffer, JobId);
85*c2c66affSColin Finck 
86*c2c66affSColin Finck     RpcTryExcept
87*c2c66affSColin Finck     {
88*c2c66affSColin Finck         status = NetrJobAdd(ServerName,
89*c2c66affSColin Finck                             (LPAT_INFO)Buffer,
90*c2c66affSColin Finck                             JobId);
91*c2c66affSColin Finck     }
92*c2c66affSColin Finck     RpcExcept(EXCEPTION_EXECUTE_HANDLER)
93*c2c66affSColin Finck     {
94*c2c66affSColin Finck         status = I_RpcMapWin32Status(RpcExceptionCode());
95*c2c66affSColin Finck     }
96*c2c66affSColin Finck     RpcEndExcept;
97*c2c66affSColin Finck 
98*c2c66affSColin Finck     return status;
99*c2c66affSColin Finck }
100*c2c66affSColin Finck 
101*c2c66affSColin Finck 
102*c2c66affSColin Finck NET_API_STATUS
103*c2c66affSColin Finck WINAPI
NetScheduleJobDel(LPCWSTR ServerName,DWORD MinJobId,DWORD MaxJobId)104*c2c66affSColin Finck NetScheduleJobDel(
105*c2c66affSColin Finck     LPCWSTR ServerName,
106*c2c66affSColin Finck     DWORD MinJobId,
107*c2c66affSColin Finck     DWORD MaxJobId)
108*c2c66affSColin Finck {
109*c2c66affSColin Finck     NET_API_STATUS status;
110*c2c66affSColin Finck 
111*c2c66affSColin Finck     TRACE("NetScheduleJobDel(%s, %d, %d)\n", debugstr_w(ServerName),
112*c2c66affSColin Finck           MinJobId, MaxJobId);
113*c2c66affSColin Finck 
114*c2c66affSColin Finck     RpcTryExcept
115*c2c66affSColin Finck     {
116*c2c66affSColin Finck         status = NetrJobDel(ServerName,
117*c2c66affSColin Finck                             MinJobId,
118*c2c66affSColin Finck                             MaxJobId);
119*c2c66affSColin Finck     }
120*c2c66affSColin Finck     RpcExcept(EXCEPTION_EXECUTE_HANDLER)
121*c2c66affSColin Finck     {
122*c2c66affSColin Finck         status = I_RpcMapWin32Status(RpcExceptionCode());
123*c2c66affSColin Finck     }
124*c2c66affSColin Finck     RpcEndExcept;
125*c2c66affSColin Finck 
126*c2c66affSColin Finck     return status;
127*c2c66affSColin Finck }
128*c2c66affSColin Finck 
129*c2c66affSColin Finck 
130*c2c66affSColin Finck NET_API_STATUS
131*c2c66affSColin Finck WINAPI
NetScheduleJobEnum(LPCWSTR ServerName,LPBYTE * PointerToBuffer,DWORD PreferredMaximumLength,LPDWORD EntriesRead,LPDWORD TotalEntries,LPDWORD ResumeHandle)132*c2c66affSColin Finck NetScheduleJobEnum(
133*c2c66affSColin Finck     LPCWSTR ServerName,
134*c2c66affSColin Finck     LPBYTE *PointerToBuffer,
135*c2c66affSColin Finck     DWORD PreferredMaximumLength,
136*c2c66affSColin Finck     LPDWORD EntriesRead,
137*c2c66affSColin Finck     LPDWORD TotalEntries,
138*c2c66affSColin Finck     LPDWORD ResumeHandle)
139*c2c66affSColin Finck {
140*c2c66affSColin Finck     AT_ENUM_CONTAINER EnumContainer;
141*c2c66affSColin Finck     NET_API_STATUS status;
142*c2c66affSColin Finck 
143*c2c66affSColin Finck     TRACE("NetScheduleJobEnum(%s, %p, %d, %p, %p, %p)\n", debugstr_w(ServerName),
144*c2c66affSColin Finck           PointerToBuffer, PreferredMaximumLength, EntriesRead, TotalEntries, ResumeHandle);
145*c2c66affSColin Finck 
146*c2c66affSColin Finck     EnumContainer.EntriesRead = 0;
147*c2c66affSColin Finck     EnumContainer.Buffer = NULL;
148*c2c66affSColin Finck 
149*c2c66affSColin Finck     RpcTryExcept
150*c2c66affSColin Finck     {
151*c2c66affSColin Finck         status = NetrJobEnum(ServerName,
152*c2c66affSColin Finck                              &EnumContainer,
153*c2c66affSColin Finck                              PreferredMaximumLength,
154*c2c66affSColin Finck                              TotalEntries,
155*c2c66affSColin Finck                              ResumeHandle);
156*c2c66affSColin Finck         if (status == NERR_Success || status == ERROR_MORE_DATA)
157*c2c66affSColin Finck         {
158*c2c66affSColin Finck             *PointerToBuffer = (LPBYTE)EnumContainer.Buffer;
159*c2c66affSColin Finck             *EntriesRead = EnumContainer.EntriesRead;
160*c2c66affSColin Finck         }
161*c2c66affSColin Finck     }
162*c2c66affSColin Finck     RpcExcept(EXCEPTION_EXECUTE_HANDLER)
163*c2c66affSColin Finck     {
164*c2c66affSColin Finck         status = I_RpcMapWin32Status(RpcExceptionCode());
165*c2c66affSColin Finck     }
166*c2c66affSColin Finck     RpcEndExcept;
167*c2c66affSColin Finck 
168*c2c66affSColin Finck     return status;
169*c2c66affSColin Finck }
170*c2c66affSColin Finck 
171*c2c66affSColin Finck 
172*c2c66affSColin Finck NET_API_STATUS
173*c2c66affSColin Finck WINAPI
NetScheduleJobGetInfo(LPCWSTR ServerName,DWORD JobId,LPBYTE * PointerToBuffer)174*c2c66affSColin Finck NetScheduleJobGetInfo(
175*c2c66affSColin Finck     LPCWSTR ServerName,
176*c2c66affSColin Finck     DWORD JobId,
177*c2c66affSColin Finck     LPBYTE *PointerToBuffer)
178*c2c66affSColin Finck {
179*c2c66affSColin Finck     NET_API_STATUS status;
180*c2c66affSColin Finck 
181*c2c66affSColin Finck     TRACE("NetScheduleJobGetInfo(%s, %d, %p)\n", debugstr_w(ServerName),
182*c2c66affSColin Finck           JobId, PointerToBuffer);
183*c2c66affSColin Finck 
184*c2c66affSColin Finck     RpcTryExcept
185*c2c66affSColin Finck     {
186*c2c66affSColin Finck         status = NetrJobGetInfo(ServerName,
187*c2c66affSColin Finck                                 JobId,
188*c2c66affSColin Finck                                 (LPAT_INFO *)PointerToBuffer);
189*c2c66affSColin Finck     }
190*c2c66affSColin Finck     RpcExcept(EXCEPTION_EXECUTE_HANDLER)
191*c2c66affSColin Finck     {
192*c2c66affSColin Finck         status = I_RpcMapWin32Status(RpcExceptionCode());
193*c2c66affSColin Finck     }
194*c2c66affSColin Finck     RpcEndExcept;
195*c2c66affSColin Finck 
196*c2c66affSColin Finck     return status;
197*c2c66affSColin Finck }
198*c2c66affSColin Finck 
199*c2c66affSColin Finck /* EOF */
200