Use proper asm name for external functions.
[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 "winternl.h"
32 #include "kernel_private.h"
33 #include "wine/windef16.h"
34 #include "wine/server.h"
35 #include "wine/debug.h"
36
37 WINE_DEFAULT_DEBUG_CHANNEL(file);
38
39 /****************************************************************************
40  *              FindFirstChangeNotificationA (KERNEL32.@)
41  */
42 HANDLE WINAPI FindFirstChangeNotificationA( LPCSTR lpPathName, BOOL bWatchSubtree,
43                                             DWORD dwNotifyFilter )
44 {
45     WCHAR *pathW;
46
47     if (!(pathW = FILE_name_AtoW( lpPathName, FALSE ))) return INVALID_HANDLE_VALUE;
48     return FindFirstChangeNotificationW( pathW, bWatchSubtree, dwNotifyFilter );
49 }
50
51 /****************************************************************************
52  *              FindFirstChangeNotificationW (KERNEL32.@)
53  */
54 HANDLE WINAPI FindFirstChangeNotificationW( LPCWSTR lpPathName, BOOL bWatchSubtree,
55                                             DWORD dwNotifyFilter)
56 {
57     UNICODE_STRING nt_name;
58     OBJECT_ATTRIBUTES attr;
59     IO_STATUS_BLOCK io;
60     NTSTATUS status;
61     HANDLE file, ret = INVALID_HANDLE_VALUE;
62
63     TRACE( "%s %d %lx\n", debugstr_w(lpPathName), bWatchSubtree, dwNotifyFilter );
64
65     if (!RtlDosPathNameToNtPathName_U( lpPathName, &nt_name, NULL, NULL ))
66     {
67         SetLastError( ERROR_PATH_NOT_FOUND );
68         return INVALID_HANDLE_VALUE;
69     }
70
71     attr.Length = sizeof(attr);
72     attr.RootDirectory = 0;
73     attr.Attributes = OBJ_CASE_INSENSITIVE;
74     attr.ObjectName = &nt_name;
75     attr.SecurityDescriptor = NULL;
76     attr.SecurityQualityOfService = NULL;
77
78     status = NtOpenFile( &file, 0, &attr, &io, 0,
79                          FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT );
80     RtlFreeUnicodeString( &nt_name );
81
82     if (status != STATUS_SUCCESS)
83     {
84         SetLastError( RtlNtStatusToDosError(status) );
85         return INVALID_HANDLE_VALUE;
86     }
87
88     SERVER_START_REQ( create_change_notification )
89     {
90         req->handle  = file;
91         req->subtree = bWatchSubtree;
92         req->filter  = dwNotifyFilter;
93         if (!wine_server_call_err( req )) ret = reply->handle;
94     }
95     SERVER_END_REQ;
96     CloseHandle( file );
97     return ret;
98 }
99
100 /****************************************************************************
101  *              FindNextChangeNotification (KERNEL32.@)
102  */
103 BOOL WINAPI FindNextChangeNotification( HANDLE handle )
104 {
105     BOOL ret;
106
107     TRACE("%p\n",handle);
108
109     SERVER_START_REQ( next_change_notification )
110     {
111         req->handle = handle;
112         ret = !wine_server_call_err( req );
113     }
114     SERVER_END_REQ;
115     return ret;
116 }
117
118 /****************************************************************************
119  *              FindCloseChangeNotification (KERNEL32.@)
120  */
121 BOOL WINAPI FindCloseChangeNotification( HANDLE handle )
122 {
123     return CloseHandle( handle );
124 }
125
126 /***********************************************************************
127 *       FileCDR (KERNEL.130)
128 */
129 FARPROC16 WINAPI FileCDR16(FARPROC16 x)
130 {
131     FIXME("(%p): stub\n", x);
132     return (FARPROC16)TRUE;
133 }
134
135 BOOL WINAPI ReadDirectoryChangesW( HANDLE handle, LPVOID buffer, DWORD len, BOOL subtree,
136                                    DWORD filter, LPDWORD returned, LPOVERLAPPED overlapped,
137                                    LPOVERLAPPED_COMPLETION_ROUTINE completion )
138 {
139     FIXME( "%p %p 0x%08lx %d 0x%08lx %p %p %p\n", handle, buffer, len, subtree, filter,
140            returned, overlapped, completion );
141
142     SetLastError( ERROR_INVALID_FUNCTION );
143     return FALSE;
144 }