Save the registry before exiting on a SIGTERM.
[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 "winnt.h"
12
13 #include "handle.h"
14 #include "thread.h"
15 #include "request.h"
16
17 struct change
18 {
19     struct object  obj;      /* object header */
20     int            subtree;  /* watch all the subtree */
21     int            filter;   /* notification filter */
22 };
23
24 static void change_dump( struct object *obj, int verbose );
25 static int change_signaled( struct object *obj, struct thread *thread );
26
27 static const struct object_ops change_ops =
28 {
29     sizeof(struct change),    /* size */
30     change_dump,              /* dump */
31     add_queue,                /* add_queue */
32     remove_queue,             /* remove_queue */
33     change_signaled,          /* signaled */
34     no_satisfied,             /* satisfied */
35     NULL,                     /* get_poll_events */
36     NULL,                     /* poll_event */
37     no_get_fd,                /* get_fd */
38     no_flush,                 /* flush */
39     no_get_file_info,         /* get_file_info */
40     NULL,                     /* queue_async */
41     no_destroy                /* destroy */
42 };
43
44
45 static struct change *create_change_notification( int subtree, int filter )
46 {
47     struct change *change;
48     if ((change = alloc_object( &change_ops, -1 )))
49     {
50         change->subtree = subtree;
51         change->filter  = filter;
52     }
53     return change;
54 }
55
56 static void change_dump( struct object *obj, int verbose )
57 {
58     struct change *change = (struct change *)obj;
59     assert( obj->ops == &change_ops );
60     fprintf( stderr, "Change notification sub=%d filter=%08x\n",
61              change->subtree, change->filter );
62 }
63
64 static int change_signaled( struct object *obj, struct thread *thread )
65 {
66 /*    struct change *change = (struct change *)obj;*/
67     assert( obj->ops == &change_ops );
68     return 0;  /* never signaled for now */
69 }
70
71 /* create a change notification */
72 DECL_HANDLER(create_change_notification)
73 {
74     struct change *change;
75
76     reply->handle = 0;
77     if ((change = create_change_notification( req->subtree, req->filter )))
78     {
79         reply->handle = alloc_handle( current->process, change,
80                                       STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE, 0 );
81         release_object( change );
82     }
83 }