Dmitry Timoshkov : schedsvc: Implement NetrJobEnum.

Alexandre Julliard julliard at winehq.org
Tue Apr 17 14:53:59 CDT 2018


Module: wine
Branch: master
Commit: bab40d15a0cf6424d2026243afe8e0c8696905fb
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=bab40d15a0cf6424d2026243afe8e0c8696905fb

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Tue Apr 17 15:12:13 2018 +0800

schedsvc: Implement NetrJobEnum.

Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/schedsvc/atsvc.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 58 insertions(+), 2 deletions(-)

diff --git a/dlls/schedsvc/atsvc.c b/dlls/schedsvc/atsvc.c
index a843b08..49b203b 100644
--- a/dlls/schedsvc/atsvc.c
+++ b/dlls/schedsvc/atsvc.c
@@ -367,11 +367,67 @@ DWORD __cdecl NetrJobDel(ATSVC_HANDLE server_name, DWORD min_jobid, DWORD max_jo
     return ERROR_NOT_SUPPORTED;
 }
 
+static void free_container(AT_ENUM_CONTAINER *container)
+{
+    DWORD i;
+
+    for (i = 0; i < container->EntriesRead; i++)
+        heap_free(container->Buffer[i].Command);
+
+    heap_free(container->Buffer);
+}
+
 DWORD __cdecl NetrJobEnum(ATSVC_HANDLE server_name, AT_ENUM_CONTAINER *container,
                           DWORD max_length, DWORD *total, DWORD *resume)
 {
-    FIXME("%s,%p,%u,%p,%p: stub\n", debugstr_w(server_name), container, max_length, total, resume);
-    return ERROR_NOT_SUPPORTED;
+    DWORD allocated;
+    struct job_t *job;
+
+    TRACE("%s,%p,%u,%p,%p\n", debugstr_w(server_name), container, max_length, total, resume);
+
+    *total = 0;
+    *resume = 0;
+    container->EntriesRead = 0;
+
+    allocated = 64;
+    container->Buffer = heap_alloc(allocated * sizeof(AT_ENUM));
+    if (!container->Buffer) return ERROR_NOT_ENOUGH_MEMORY;
+
+    EnterCriticalSection(&at_job_list_section);
+
+    LIST_FOR_EACH_ENTRY(job, &at_job_list, struct job_t, entry)
+    {
+        if (container->EntriesRead >= max_length)
+        {
+            *resume = container->EntriesRead;
+            break;
+        }
+
+        if (allocated <= container->EntriesRead)
+        {
+            AT_ENUM *new_buffer;
+
+            allocated *= 2;
+            new_buffer = heap_realloc(container->Buffer, allocated * sizeof(AT_ENUM));
+            if (!new_buffer)
+            {
+                free_container(container);
+                LeaveCriticalSection(&at_job_list_section);
+                return ERROR_NOT_ENOUGH_MEMORY;
+            }
+            container->Buffer = new_buffer;
+        }
+
+        container->Buffer[container->EntriesRead] = job->info;
+        container->Buffer[container->EntriesRead].Command = heap_strdupW(job->info.Command);
+        container->EntriesRead++;
+    }
+
+    LeaveCriticalSection(&at_job_list_section);
+
+    *total = container->EntriesRead;
+
+    return ERROR_SUCCESS;
 }
 
 DWORD __cdecl NetrJobGetInfo(ATSVC_HANDLE server_name, DWORD jobid, AT_INFO **info)




More information about the wine-cvs mailing list