blob: 844e21b25d094d69f46a44949ee6b3d32a13b525 [file] [log] [blame]
Alexandre Julliard63cb0f81998-12-31 15:43:48 +00001/*
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
Alexandre Julliard63cb0f81998-12-31 15:43:48 +000011#include "winnt.h"
Alexandre Julliard43c190e1999-05-15 10:48:19 +000012
13#include "handle.h"
14#include "thread.h"
Alexandre Julliard5bc78081999-06-22 17:26:53 +000015#include "request.h"
Alexandre Julliard63cb0f81998-12-31 15:43:48 +000016
17struct change
18{
19 struct object obj; /* object header */
20 int subtree; /* watch all the subtree */
21 int filter; /* notification filter */
22};
23
24static void change_dump( struct object *obj, int verbose );
25static int change_signaled( struct object *obj, struct thread *thread );
Alexandre Julliard63cb0f81998-12-31 15:43:48 +000026
27static const struct object_ops change_ops =
28{
Alexandre Julliard1dca5e22000-01-01 00:56:27 +000029 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_read_fd, /* get_read_fd */
38 no_write_fd, /* get_write_fd */
39 no_flush, /* flush */
40 no_get_file_info, /* get_file_info */
41 no_destroy /* destroy */
Alexandre Julliard63cb0f81998-12-31 15:43:48 +000042};
43
44
Alexandre Julliardebe29ef1999-06-26 08:43:26 +000045static struct change *create_change_notification( int subtree, int filter )
Alexandre Julliard63cb0f81998-12-31 15:43:48 +000046{
47 struct change *change;
Alexandre Julliard1dca5e22000-01-01 00:56:27 +000048 if ((change = alloc_object( &change_ops, -1 )))
Alexandre Julliardebe29ef1999-06-26 08:43:26 +000049 {
50 change->subtree = subtree;
51 change->filter = filter;
52 }
53 return change;
Alexandre Julliard63cb0f81998-12-31 15:43:48 +000054}
55
56static void change_dump( struct object *obj, int verbose )
57{
58 struct change *change = (struct change *)obj;
59 assert( obj->ops == &change_ops );
Alexandre Julliard05625391999-01-03 11:55:56 +000060 fprintf( stderr, "Change notification sub=%d filter=%08x\n",
61 change->subtree, change->filter );
Alexandre Julliard63cb0f81998-12-31 15:43:48 +000062}
63
64static 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
Alexandre Julliard43c190e1999-05-15 10:48:19 +000071/* create a change notification */
72DECL_HANDLER(create_change_notification)
73{
Alexandre Julliardebe29ef1999-06-26 08:43:26 +000074 struct change *change;
Alexandre Julliard43c190e1999-05-15 10:48:19 +000075
Alexandre Julliardebe29ef1999-06-26 08:43:26 +000076 req->handle = -1;
77 if ((change = create_change_notification( req->subtree, req->filter )))
Alexandre Julliard43c190e1999-05-15 10:48:19 +000078 {
Alexandre Julliardebe29ef1999-06-26 08:43:26 +000079 req->handle = alloc_handle( current->process, change,
80 STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE, 0 );
81 release_object( change );
Alexandre Julliard43c190e1999-05-15 10:48:19 +000082 }
Alexandre Julliard43c190e1999-05-15 10:48:19 +000083}