Moved poll handling to the generic part of the server objects.
[wine] / server / change.c
1 /*
2  * Server-side change notification management
3  *
4  * Copyright (C) 1998 Alexandre Julliard
5  */
6
7 #include <assert.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10
11 #include "winerror.h"
12 #include "winnt.h"
13
14 #include "handle.h"
15 #include "thread.h"
16 #include "request.h"
17
18 struct change
19 {
20     struct object  obj;      /* object header */
21     int            subtree;  /* watch all the subtree */
22     int            filter;   /* notification filter */
23 };
24
25 static void change_dump( struct object *obj, int verbose );
26 static int change_signaled( struct object *obj, struct thread *thread );
27
28 static const struct object_ops change_ops =
29 {
30     sizeof(struct change),    /* size */
31     change_dump,              /* dump */
32     add_queue,                /* add_queue */
33     remove_queue,             /* remove_queue */
34     change_signaled,          /* signaled */
35     no_satisfied,             /* satisfied */
36     NULL,                     /* get_poll_events */
37     NULL,                     /* poll_event */
38     no_read_fd,               /* get_read_fd */
39     no_write_fd,              /* get_write_fd */
40     no_flush,                 /* flush */
41     no_get_file_info,         /* get_file_info */
42     no_destroy                /* destroy */
43 };
44
45
46 static struct change *create_change_notification( int subtree, int filter )
47 {
48     struct change *change;
49     if ((change = alloc_object( &change_ops, -1 )))
50     {
51         change->subtree = subtree;
52         change->filter  = filter;
53     }
54     return change;
55 }
56
57 static void change_dump( struct object *obj, int verbose )
58 {
59     struct change *change = (struct change *)obj;
60     assert( obj->ops == &change_ops );
61     fprintf( stderr, "Change notification sub=%d filter=%08x\n",
62              change->subtree, change->filter );
63 }
64
65 static int change_signaled( struct object *obj, struct thread *thread )
66 {
67 /*    struct change *change = (struct change *)obj;*/
68     assert( obj->ops == &change_ops );
69     return 0;  /* never signaled for now */
70 }
71
72 /* create a change notification */
73 DECL_HANDLER(create_change_notification)
74 {
75     struct change *change;
76
77     req->handle = -1;
78     if ((change = create_change_notification( req->subtree, req->filter )))
79     {
80         req->handle = alloc_handle( current->process, change,
81                                     STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE, 0 );
82         release_object( change );
83     }
84 }