From a484dadf4a6521dcb57c26b7e0bf767aa4166783 Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Thu, 10 Apr 2014 17:41:33 +0900 Subject: [PATCH] schedsvc: Add support for generating new task name in SchRpcRegisterTask. --- dlls/schedsvc/Makefile.in | 2 +- dlls/schedsvc/schedsvc.c | 44 ++++++++++++++++++++++-------------- dlls/schedsvc/tests/rpcapi.c | 4 ---- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/dlls/schedsvc/Makefile.in b/dlls/schedsvc/Makefile.in index d1ee5c3ffae..32ee4e33f82 100644 --- a/dlls/schedsvc/Makefile.in +++ b/dlls/schedsvc/Makefile.in @@ -1,5 +1,5 @@ MODULE = schedsvc.dll -IMPORTS = rpcrt4 advapi32 +IMPORTS = rpcrt4 advapi32 ole32 C_SRCS = \ schedsvc.c \ diff --git a/dlls/schedsvc/schedsvc.c b/dlls/schedsvc/schedsvc.c index 5ce7d1da9ff..3f11d167f05 100644 --- a/dlls/schedsvc/schedsvc.c +++ b/dlls/schedsvc/schedsvc.c @@ -180,27 +180,37 @@ HRESULT __cdecl SchRpcRegisterTask(const WCHAR *path, const WCHAR *xml, DWORD fl /* FIXME: assume that validation is performed on the client side */ if (flags & TASK_VALIDATE_ONLY) return S_OK; - if (!path) + if (path) { - FIXME("NULL name is not supported\n"); - return E_INVALIDARG; - } + full_name = get_full_name(path, &relative_path); + if (!full_name) return E_OUTOFMEMORY; - full_name = get_full_name(path, &relative_path); - if (!full_name) return E_OUTOFMEMORY; - - if (strchrW(path, '\\') || strchrW(path, '/')) - { - WCHAR *p = strrchrW(full_name, '/'); - if (!p) p = strrchrW(full_name, '\\'); - *p = 0; - hr = create_directory(full_name); - if (hr != S_OK && hr != HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS)) + if (strchrW(path, '\\') || strchrW(path, '/')) { - heap_free(full_name); - return hr; + WCHAR *p = strrchrW(full_name, '/'); + if (!p) p = strrchrW(full_name, '\\'); + *p = 0; + hr = create_directory(full_name); + if (hr != S_OK && hr != HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS)) + { + heap_free(full_name); + return hr; + } + *p = '\\'; } - *p = '\\'; + } + else + { + IID iid; + WCHAR uuid_str[39]; + + UuidCreate(&iid); + StringFromGUID2(&iid, uuid_str, 39); + + full_name = get_full_name(uuid_str, &relative_path); + if (!full_name) return E_OUTOFMEMORY; + /* skip leading '\' */ + relative_path++; } switch (flags & (TASK_CREATE | TASK_UPDATE)) diff --git a/dlls/schedsvc/tests/rpcapi.c b/dlls/schedsvc/tests/rpcapi.c index beaf7da70e5..b3007f71119 100644 --- a/dlls/schedsvc/tests/rpcapi.c +++ b/dlls/schedsvc/tests/rpcapi.c @@ -521,17 +521,13 @@ todo_wine path = NULL; info = NULL; hr = SchRpcRegisterTask(NULL, xmlW, TASK_CREATE, NULL, TASK_LOGON_NONE, 0, NULL, &path, &info); -todo_wine ok(hr == S_OK, "expected S_OK, got %#x\n", hr); ok(!info, "expected NULL, info %p\n", info); -if (hr == S_OK) -{ hr = IIDFromString(path, &iid); ok(hr == S_OK, "IIDFromString(%s) error %#x\n", wine_dbgstr_w(path), hr); hr = SchRpcDelete(path, 0); ok(hr == S_OK, "expected S_OK, got %#x\n", hr); MIDL_user_free(path); -} hr = RpcBindingFree(&rpc_handle); ok(hr == RPC_S_OK, "RpcBindingFree error %#x\n", hr);