Fixes for -Wmissing-declaration and -Wwrite-string warnings.
[wine] / dlls / kernel / change.c
1 /*
2  * Win32 file change notification functions
3  *
4  * Copyright 1998 Ulrich Weigand
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "config.h"
22
23 #include <stdarg.h>
24 #include <stdlib.h>
25 #include <string.h>
26
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winerror.h"
30 #include "ntstatus.h"
31 #include "winreg.h"
32 #include "winternl.h"
33 #include "kernel_private.h"
34 #include "wine/windef16.h"
35 #include "wine/server.h"
36 #include "wine/debug.h"
37
38 WINE_DEFAULT_DEBUG_CHANNEL(file);
39
40 /****************************************************************************
41  *              FindFirstChangeNotificationA (KERNEL32.@)
42  */
43 HANDLE WINAPI FindFirstChangeNotificationA( LPCSTR lpPathName, BOOL bWatchSubtree,
44                                             DWORD dwNotifyFilter )
45 {
46     WCHAR *pathW;
47
48     if (!(pathW = FILE_name_AtoW( lpPathName, FALSE ))) return INVALID_HANDLE_VALUE;
49     return FindFirstChangeNotificationW( pathW, bWatchSubtree, dwNotifyFilter );
50 }
51
52 /****************************************************************************
53  *              FindFirstChangeNotificationW (KERNEL32.@)
54  */
55 HANDLE WINAPI FindFirstChangeNotificationW( LPCWSTR lpPathName, BOOL bWatchSubtree,
56                                             DWORD dwNotifyFilter)
57 {
58     UNICODE_STRING nt_name;
59     OBJECT_ATTRIBUTES attr;
60     IO_STATUS_BLOCK io;
61     NTSTATUS status;
62     HANDLE file, ret = INVALID_HANDLE_VALUE;
63
64     TRACE( "%s %d %lx\n", debugstr_w(lpPathName), bWatchSubtree, dwNotifyFilter );
65
66     if (!RtlDosPathNameToNtPathName_U( lpPathName, &nt_name, NULL, NULL ))
67     {
68         SetLastError( ERROR_PATH_NOT_FOUND );
69         return INVALID_HANDLE_VALUE;
70     }
71
72     attr.Length = sizeof(attr);
73     attr.RootDirectory = 0;
74     attr.Attributes = OBJ_CASE_INSENSITIVE;
75     attr.ObjectName = &nt_name;
76     attr.SecurityDescriptor = NULL;
77     attr.SecurityQualityOfService = NULL;
78
79     status = NtOpenFile( &file, 0, &attr, &io, 0,
80                          FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT );
81     RtlFreeUnicodeString( &nt_name );
82
83     if (status != STATUS_SUCCESS)
84     {
85         SetLastError( RtlNtStatusToDosError(status) );
86         return INVALID_HANDLE_VALUE;
87     }
88
89     SERVER_START_REQ( create_change_notification )
90     {
91         req->handle  = file;
92         req->subtree = bWatchSubtree;
93         req->filter  = dwNotifyFilter;
94         if (!wine_server_call_err( req )) ret = reply->handle;
95     }
96     SERVER_END_REQ;
97     CloseHandle( file );
98     return ret;
99 }
100
101 /****************************************************************************
102  *              FindNextChangeNotification (KERNEL32.@)
103  */
104 BOOL WINAPI FindNextChangeNotification( HANDLE handle )
105 {
106     BOOL ret;
107
108     TRACE("%p\n",handle);
109
110     SERVER_START_REQ( next_change_notification )
111     {
112         req->handle = handle;
113         ret = !wine_server_call_err( req );
114     }
115     SERVER_END_REQ;
116     return ret;
117 }
118
119 /****************************************************************************
120  *              FindCloseChangeNotification (KERNEL32.@)
121  */
122 BOOL WINAPI FindCloseChangeNotification( HANDLE handle )
123 {
124     return CloseHandle( handle );
125 }
126
127 /***********************************************************************
128 *       FileCDR (KERNEL.130)
129 */
130 FARPROC16 WINAPI FileCDR16(FARPROC16 x)
131 {
132     FIXME("(0x%8x): stub\n", (int) x);
133     return (FARPROC16)TRUE;
134 }
135
136 BOOL WINAPI ReadDirectoryChangesW( HANDLE handle, LPVOID buffer, DWORD len, BOOL subtree,
137                                    DWORD filter, LPDWORD returned, LPOVERLAPPED overlapped,
138                                    LPOVERLAPPED_COMPLETION_ROUTINE completion )
139 {
140     FIXME( "%p %p 0x%08lx %d 0x%08lx %p %p %p\n", handle, buffer, len, subtree, filter,
141            returned, overlapped, completion );
142
143     SetLastError( ERROR_INVALID_FUNCTION );
144     return FALSE;
145 }