Alexandre Julliard | 63cb0f8 | 1998-12-31 15:43:48 +0000 | [diff] [blame] | 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" |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 13 | |
| 14 | #include "handle.h" |
| 15 | #include "thread.h" |
Alexandre Julliard | 5bc7808 | 1999-06-22 17:26:53 +0000 | [diff] [blame] | 16 | #include "request.h" |
Alexandre Julliard | 63cb0f8 | 1998-12-31 15:43:48 +0000 | [diff] [blame] | 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 ); |
Alexandre Julliard | 63cb0f8 | 1998-12-31 15:43:48 +0000 | [diff] [blame] | 27 | |
| 28 | static const struct object_ops change_ops = |
| 29 | { |
Alexandre Julliard | 5bc7808 | 1999-06-22 17:26:53 +0000 | [diff] [blame] | 30 | sizeof(struct change), |
Alexandre Julliard | 63cb0f8 | 1998-12-31 15:43:48 +0000 | [diff] [blame] | 31 | 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 Julliard | 0562539 | 1999-01-03 11:55:56 +0000 | [diff] [blame] | 39 | no_get_file_info, |
Alexandre Julliard | 5bc7808 | 1999-06-22 17:26:53 +0000 | [diff] [blame] | 40 | no_destroy |
Alexandre Julliard | 63cb0f8 | 1998-12-31 15:43:48 +0000 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | |
Alexandre Julliard | ebe29ef | 1999-06-26 08:43:26 +0000 | [diff] [blame] | 44 | static struct change *create_change_notification( int subtree, int filter ) |
Alexandre Julliard | 63cb0f8 | 1998-12-31 15:43:48 +0000 | [diff] [blame] | 45 | { |
| 46 | struct change *change; |
Alexandre Julliard | ebe29ef | 1999-06-26 08:43:26 +0000 | [diff] [blame] | 47 | if ((change = alloc_object( &change_ops ))) |
| 48 | { |
| 49 | change->subtree = subtree; |
| 50 | change->filter = filter; |
| 51 | } |
| 52 | return change; |
Alexandre Julliard | 63cb0f8 | 1998-12-31 15:43:48 +0000 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | static void change_dump( struct object *obj, int verbose ) |
| 56 | { |
| 57 | struct change *change = (struct change *)obj; |
| 58 | assert( obj->ops == &change_ops ); |
Alexandre Julliard | 0562539 | 1999-01-03 11:55:56 +0000 | [diff] [blame] | 59 | fprintf( stderr, "Change notification sub=%d filter=%08x\n", |
| 60 | change->subtree, change->filter ); |
Alexandre Julliard | 63cb0f8 | 1998-12-31 15:43:48 +0000 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | static 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 Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 70 | /* create a change notification */ |
| 71 | DECL_HANDLER(create_change_notification) |
| 72 | { |
Alexandre Julliard | ebe29ef | 1999-06-26 08:43:26 +0000 | [diff] [blame] | 73 | struct change *change; |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 74 | |
Alexandre Julliard | ebe29ef | 1999-06-26 08:43:26 +0000 | [diff] [blame] | 75 | req->handle = -1; |
| 76 | if ((change = create_change_notification( req->subtree, req->filter ))) |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 77 | { |
Alexandre Julliard | ebe29ef | 1999-06-26 08:43:26 +0000 | [diff] [blame] | 78 | req->handle = alloc_handle( current->process, change, |
| 79 | STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE, 0 ); |
| 80 | release_object( change ); |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 81 | } |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 82 | } |