- New implementation of SendMessage, ReceiveMessage, ReplyMessage functions
[wine] / files / change.c
1 /*
2  * Win32 file change notification functions
3  *
4  * Copyright 1998 Ulrich Weigand
5  */
6
7 #include <assert.h>
8 #include <stdlib.h>
9 #include <unistd.h>
10 #include <string.h>
11 #include <time.h>
12 #include "winbase.h"
13 #include "winerror.h"
14 #include "process.h"
15 #include "thread.h"
16 #include "heap.h"
17 #include "server.h"
18 #include "debug.h"
19
20 /* The change notification object */
21 typedef struct
22 {
23     K32OBJ       header;
24 } CHANGE_OBJECT;
25
26
27 /****************************************************************************
28  *              FindFirstChangeNotification32A (KERNEL32.248)
29  */
30 HANDLE32 WINAPI FindFirstChangeNotification32A( LPCSTR lpPathName,
31                                                 BOOL32 bWatchSubtree,
32                                                 DWORD dwNotifyFilter ) 
33 {
34     CHANGE_OBJECT *change;
35     struct create_change_notification_request req;
36     struct create_change_notification_reply reply;
37
38     req.subtree = bWatchSubtree;
39     req.filter  = dwNotifyFilter;
40     CLIENT_SendRequest( REQ_CREATE_CHANGE_NOTIFICATION, -1, 1, &req, sizeof(req) );
41     CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
42     if (reply.handle == -1) return INVALID_HANDLE_VALUE32;
43
44     change = HeapAlloc( SystemHeap, 0, sizeof(CHANGE_OBJECT) );
45     if (!change)
46     {
47         CLIENT_CloseHandle( reply.handle );
48         return INVALID_HANDLE_VALUE32;
49     }
50     change->header.type = K32OBJ_CHANGE;
51     change->header.refcount = 1;
52     return HANDLE_Alloc( PROCESS_Current(), &change->header, 
53                          STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE /*FIXME*/,
54                          FALSE, reply.handle );
55 }
56
57 /****************************************************************************
58  *              FindFirstChangeNotification32W (KERNEL32.249)
59  */
60 HANDLE32 WINAPI FindFirstChangeNotification32W( LPCWSTR lpPathName,
61                                                 BOOL32 bWatchSubtree,
62                                                 DWORD dwNotifyFilter) 
63 {
64     LPSTR nameA = HEAP_strdupWtoA( GetProcessHeap(), 0, lpPathName );
65     HANDLE32 ret = FindFirstChangeNotification32A( nameA, bWatchSubtree, 
66                                                           dwNotifyFilter );
67     if (nameA) HeapFree( GetProcessHeap(), 0, nameA );
68     return ret;
69 }
70
71 /****************************************************************************
72  *              FindNextChangeNotification (KERNEL32.252)
73  */
74 BOOL32 WINAPI FindNextChangeNotification( HANDLE32 handle ) 
75 {
76     if (HANDLE_GetServerHandle( PROCESS_Current(), handle,
77                                 K32OBJ_FILE, 0 ) == -1)
78         return FALSE;
79     /* FIXME: do something */
80     return TRUE;
81 }
82
83 /****************************************************************************
84  *              FindCloseChangeNotification (KERNEL32.247)
85  */
86 BOOL32 WINAPI FindCloseChangeNotification( HANDLE32 handle) 
87 {
88     return CloseHandle( handle );
89 }
90