Changed fd operations to take a struct fd instead of a struct object.
[wine] / server / file.h
1 /*
2  * Server-side file definitions
3  *
4  * Copyright (C) 2003 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_SERVER_FILE_H
22 #define __WINE_SERVER_FILE_H
23
24 #include "object.h"
25
26 struct fd;
27
28 /* operations valid on file descriptor objects */
29 struct fd_ops
30 {
31     /* get the events we want to poll() for on this object */
32     int  (*get_poll_events)(struct fd *);
33     /* a poll() event occured */
34     void (*poll_event)(struct fd *,int event);
35     /* flush the object buffers */
36     int  (*flush)(struct fd *);
37     /* get file information */
38     int  (*get_file_info)(struct fd *,struct get_file_info_reply *, int *flags);
39     /* queue an async operation - see register_async handler in async.c*/
40     void (*queue_async)(struct fd *, void* ptr, unsigned int status, int type, int count);
41 };
42
43 /* file descriptor functions */
44
45 extern void *alloc_fd_object( const struct object_ops *ops,
46                               const struct fd_ops *fd_user_ops, int unix_fd );
47 extern void *get_fd_user( struct fd *fd );
48 extern int get_unix_fd( struct fd *fd );
49 extern void set_unix_fd( struct object *obj, int unix_fd );
50 extern void fd_poll_event( struct object *obj, int event );
51 extern int check_fd_events( struct fd *fd, int events );
52
53 extern int default_fd_add_queue( struct object *obj, struct wait_queue_entry *entry );
54 extern void default_fd_remove_queue( struct object *obj, struct wait_queue_entry *entry );
55 extern int default_fd_signaled( struct object *obj, struct thread *thread );
56 extern void default_poll_event( struct fd *fd, int event );
57 extern int no_flush( struct fd *fd );
58 extern int no_get_file_info( struct fd *fd, struct get_file_info_reply *info, int *flags );
59 extern void no_queue_async( struct fd *fd, void* ptr, unsigned int status, int type, int count );
60
61 inline static struct fd *get_obj_fd( struct object *obj ) { return obj->ops->get_fd( obj ); }
62
63 /* file functions */
64
65 extern struct file *get_file_obj( struct process *process, obj_handle_t handle,
66                                   unsigned int access );
67 extern int get_file_unix_fd( struct file *file );
68 extern int is_same_file( struct file *file1, struct file *file2 );
69 extern int get_file_drive_type( struct file *file );
70 extern int grow_file( struct file *file, int size_high, int size_low );
71 extern int create_anonymous_file(void);
72 extern struct file *create_temp_file( int access );
73 extern void file_set_error(void);
74
75 #endif  /* __WINE_SERVER_FILE_H */