Changed the GDI driver interface to pass an opaque PHYSDEV pointer
[wine] / include / file.h
1 /*
2  * File handling declarations
3  *
4  * Copyright 1996 Alexandre Julliard
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 #ifndef __WINE_FILE_H
22 #define __WINE_FILE_H
23
24 #include <time.h> /* time_t */
25 #include <sys/time.h>
26 #include "winbase.h"
27 #include "wine/windef16.h"  /* HFILE16 */
28
29 #define MAX_PATHNAME_LEN   1024
30
31 /* Definition of a full DOS file name */
32 typedef struct
33 {
34     char  long_name[MAX_PATHNAME_LEN];  /* Long pathname in Unix format */
35     char  short_name[MAX_PATHNAME_LEN]; /* Short pathname in DOS 8.3 format */
36     int   drive;
37 } DOS_FULL_NAME;
38
39 #define IS_END_OF_NAME(ch)  (!(ch) || ((ch) == '/') || ((ch) == '\\'))
40
41 /* DOS device descriptor */
42 typedef struct
43 {
44     char *name;
45     int flags;
46 } DOS_DEVICE;
47
48 /* overlapped private structure */
49 struct async_private;
50 typedef void (*async_handler)(struct async_private *ovp);
51 typedef struct async_private
52 {
53      LPOVERLAPPED  lpOverlapped;
54      HANDLE        handle;
55      HANDLE        event;
56      int           fd;
57      char         *buffer;
58      async_handler func;
59      int           count;
60      int           type;
61      LPOVERLAPPED_COMPLETION_ROUTINE completion_func;
62      struct async_private *next;
63      struct async_private *prev;
64 } async_private;
65
66 extern void WINAPI check_async_list(LPOVERLAPPED ov, DWORD status);
67 extern void finish_async(struct async_private *ovp, DWORD status);
68
69 /* locale-independent case conversion */
70 inline static char FILE_tolower( char c )
71 {
72     if (c >= 'A' && c <= 'Z') c += 32;
73     return c;
74 }
75 inline static char FILE_toupper( char c )
76 {
77     if (c >= 'a' && c <= 'z') c -= 32;
78     return c;
79 }
80
81 inline static int FILE_contains_path (LPCSTR name)
82 {
83     return ((*name && (name[1] == ':')) ||
84             strchr (name, '/') || strchr (name, '\\'));
85 }
86
87 /* files/file.c */
88 extern int FILE_strcasecmp( const char *str1, const char *str2 );
89 extern int FILE_strncasecmp( const char *str1, const char *str2, int len );
90 extern void FILE_SetDosError(void);
91 extern HANDLE FILE_DupUnixHandle( int fd, DWORD access, BOOL inherit );
92 extern int FILE_GetUnixHandle( HANDLE handle, DWORD access );
93 extern BOOL FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info );
94 extern HFILE16 FILE_Dup2( HFILE16 hFile1, HFILE16 hFile2 );
95 extern HANDLE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing,
96                                LPSECURITY_ATTRIBUTES sa, DWORD creation,
97                                DWORD attributes, HANDLE template, BOOL fail_read_only,
98                                UINT drive_type );
99 extern HANDLE FILE_CreateDevice( int client_id, DWORD access, LPSECURITY_ATTRIBUTES sa );
100 extern BOOL FILE_StartAsync(HANDLE handle, LPOVERLAPPED lpOverlapped, DWORD type, DWORD count, DWORD status);
101
102 extern LONG WINAPI WIN16_hread(HFILE16,SEGPTR,LONG);
103
104 /* files/directory.c */
105 extern int DIR_Init(void);
106 extern UINT DIR_GetWindowsUnixDir( LPSTR path, UINT count );
107 extern UINT DIR_GetSystemUnixDir( LPSTR path, UINT count );
108 extern DWORD DIR_SearchAlternatePath( LPCSTR dll_path, LPCSTR name, LPCSTR ext,
109                                       DWORD buflen, LPSTR buffer, LPSTR *lastpart);
110 extern DWORD DIR_SearchPath( LPCSTR path, LPCSTR name, LPCSTR ext,
111                              DOS_FULL_NAME *full_name, BOOL win32 );
112
113 /* files/dos_fs.c */
114 extern void DOSFS_UnixTimeToFileTime( time_t unixtime, LPFILETIME ft,
115                                       DWORD remainder );
116 extern time_t DOSFS_FileTimeToUnixTime( const FILETIME *ft, DWORD *remainder );
117 extern BOOL DOSFS_ToDosFCBFormat( LPCSTR name, LPSTR buffer );
118 extern const DOS_DEVICE *DOSFS_GetDevice( const char *name );
119 extern const DOS_DEVICE *DOSFS_GetDeviceByHandle( HFILE hFile );
120 extern HANDLE DOSFS_OpenDevice( const char *name, DWORD access, DWORD attributes, LPSECURITY_ATTRIBUTES sa);
121 extern BOOL DOSFS_FindUnixName( LPCSTR path, LPCSTR name, LPSTR long_buf,
122                                   INT long_len, LPSTR short_buf,
123                                   BOOL ignore_case );
124 extern BOOL DOSFS_GetFullName( LPCSTR name, BOOL check_last,
125                                  DOS_FULL_NAME *full );
126 extern int DOSFS_FindNext( const char *path, const char *short_mask,
127                            const char *long_mask, int drive, BYTE attr,
128                            int skip, WIN32_FIND_DATAA *entry );
129
130 /* win32/device.c */
131 extern HANDLE DEVICE_Open( LPCSTR filename, DWORD access, LPSECURITY_ATTRIBUTES sa );
132
133 /* ntdll/cdrom.c.c */
134 extern BOOL CDROM_DeviceIoControl(DWORD clientID, HANDLE hDevice, DWORD dwIoControlCode, 
135                                   LPVOID lpInBuffer, DWORD nInBufferSize, 
136                                   LPVOID lpOutBuffer, DWORD nOutBufferSize,
137                                   LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped);
138
139 #endif  /* __WINE_FILE_H */