blob: 50f193eded79cdcfcd9003b758e5cf7629acadd3 [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
11#include "winerror.h"
12#include "winnt.h"
Alexandre Julliard43c190e1999-05-15 10:48:19 +000013
14#include "handle.h"
15#include "thread.h"
Alexandre Julliard5bc78081999-06-22 17:26:53 +000016#include "request.h"
Alexandre Julliard63cb0f81998-12-31 15:43:48 +000017
18struct change
19{
20 struct object obj; /* object header */
21 int subtree; /* watch all the subtree */
22 int filter; /* notification filter */
23};
24
25static void change_dump( struct object *obj, int verbose );
26static int change_signaled( struct object *obj, struct thread *thread );
Alexandre Julliard63cb0f81998-12-31 15:43:48 +000027
28static const struct object_ops change_ops =
29{
Alexandre Julliard5bc78081999-06-22 17:26:53 +000030 sizeof(struct change),
Alexandre Julliard63cb0f81998-12-31 15:43:48 +000031 change_dump,
32 add_queue,
33 remove_queue,
34 change_signaled,
35 no_satisfied,
36 no_read_fd,
37 no_write_fd,
38 no_flush,
Alexandre Julliard05625391999-01-03 11:55:56 +000039 no_get_file_info,
Alexandre Julliard5bc78081999-06-22 17:26:53 +000040 no_destroy
Alexandre Julliard63cb0f81998-12-31 15:43:48 +000041};
42
43
Alexandre Julliardebe29ef1999-06-26 08:43:26 +000044static struct change *create_change_notification( int subtree, int filter )
Alexandre Julliard63cb0f81998-12-31 15:43:48 +000045{
46 struct change *change;
Alexandre Julliardebe29ef1999-06-26 08:43:26 +000047 if ((change = alloc_object( &change_ops )))
48 {
49 change->subtree = subtree;
50 change->filter = filter;
51 }
52 return change;
Alexandre Julliard63cb0f81998-12-31 15:43:48 +000053}
54
55static void change_dump( struct object *obj, int verbose )
56{
57 struct change *change = (struct change *)obj;
58 assert( obj->ops == &change_ops );
Alexandre Julliard05625391999-01-03 11:55:56 +000059 fprintf( stderr, "Change notification sub=%d filter=%08x\n",
60 change->subtree, change->filter );
Alexandre Julliard63cb0f81998-12-31 15:43:48 +000061}
62
63static int change_signaled( struct object *obj, struct thread *thread )
64{
65/* struct change *change = (struct change *)obj;*/
66 assert( obj->ops == &change_ops );
67 return 0; /* never signaled for now */
68}
69
Alexandre Julliard43c190e1999-05-15 10:48:19 +000070/* create a change notification */
71DECL_HANDLER(create_change_notification)
72{
Alexandre Julliardebe29ef1999-06-26 08:43:26 +000073 struct change *change;
Alexandre Julliard43c190e1999-05-15 10:48:19 +000074
Alexandre Julliardebe29ef1999-06-26 08:43:26 +000075 req->handle = -1;
76 if ((change = create_change_notification( req->subtree, req->filter )))
Alexandre Julliard43c190e1999-05-15 10:48:19 +000077 {
Alexandre Julliardebe29ef1999-06-26 08:43:26 +000078 req->handle = alloc_handle( current->process, change,
79 STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE, 0 );
80 release_object( change );
Alexandre Julliard43c190e1999-05-15 10:48:19 +000081 }
Alexandre Julliard43c190e1999-05-15 10:48:19 +000082}