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