Bug fixes.
[wine/multimedia.git] / include / server / object.h
blob933afe7bb54364ee101937fef8ce327cbc79378f
1 /*
2 * Wine server objects
4 * Copyright (C) 1998 Alexandre Julliard
5 */
7 #ifndef __WINE_SERVER_OBJECT_H
8 #define __WINE_SERVER_OBJECT_H
10 #ifndef __WINE_SERVER__
11 #error This file can only be used in the Wine server
12 #endif
14 #include <sys/time.h>
15 #include "server.h"
16 #include "server/request.h"
18 /* kernel objects */
20 struct object;
21 struct object_name;
22 struct thread;
23 struct process;
24 struct file;
25 struct wait_queue_entry;
27 /* operations valid on all objects */
28 struct object_ops
30 /* dump the object (for debugging) */
31 void (*dump)(struct object *,int);
32 /* add a thread to the object wait queue */
33 int (*add_queue)(struct object *,struct wait_queue_entry *);
34 /* remove a thread from the object wait queue */
35 void (*remove_queue)(struct object *,struct wait_queue_entry *);
36 /* is object signaled? */
37 int (*signaled)(struct object *,struct thread *);
38 /* wait satisfied; return 1 if abandoned */
39 int (*satisfied)(struct object *,struct thread *);
40 /* return a Unix fd that can be used to read from the object */
41 int (*get_read_fd)(struct object *);
42 /* return a Unix fd that can be used to write to the object */
43 int (*get_write_fd)(struct object *);
44 /* flush the object buffers */
45 int (*flush)(struct object *);
46 /* get file information */
47 int (*get_file_info)(struct object *,struct get_file_info_reply *);
48 /* destroy on refcount == 0 */
49 void (*destroy)(struct object *);
52 struct object
54 unsigned int refcount;
55 const struct object_ops *ops;
56 struct wait_queue_entry *head;
57 struct wait_queue_entry *tail;
58 struct object_name *name;
61 extern void *mem_alloc( size_t size ); /* malloc wrapper */
62 extern struct object *create_named_object( const char *name, const struct object_ops *ops,
63 size_t size );
64 extern int init_object( struct object *obj, const struct object_ops *ops, const char *name );
65 extern const char *get_object_name( struct object *obj );
66 /* grab/release_object can take any pointer, but you better make sure */
67 /* that the thing pointed to starts with a struct object... */
68 extern struct object *grab_object( void *obj );
69 extern void release_object( void *obj );
70 extern struct object *find_object( const char *name );
71 extern int no_add_queue( struct object *obj, struct wait_queue_entry *entry );
72 extern int no_satisfied( struct object *obj, struct thread *thread );
73 extern int no_read_fd( struct object *obj );
74 extern int no_write_fd( struct object *obj );
75 extern int no_flush( struct object *obj );
76 extern int no_get_file_info( struct object *obj, struct get_file_info_reply *info );
77 extern void default_select_event( int fd, int event, void *private );
79 /* request handlers */
81 struct iovec;
82 struct thread;
84 extern void call_req_handler( struct thread *thread, enum request req,
85 void *data, int len, int fd );
86 extern void call_timeout_handler( struct thread *thread );
87 extern void call_kill_handler( struct thread *thread, int exit_code );
89 extern void trace_request( enum request req, void *data, int len, int fd );
90 extern void trace_timeout(void);
91 extern void trace_kill( int exit_code );
92 extern void trace_reply( struct thread *thread, int type, int pass_fd,
93 struct iovec *vec, int veclen );
95 /* select functions */
97 #define READ_EVENT 1
98 #define WRITE_EVENT 2
100 struct select_ops
102 void (*event)( int fd, int event, void *private );
103 void (*timeout)( int fd, void *private );
106 extern int add_select_user( int fd, int events, const struct select_ops *ops, void *private );
107 extern void remove_select_user( int fd );
108 extern void set_select_timeout( int fd, struct timeval *when );
109 extern void set_select_events( int fd, int events );
110 extern void *get_select_private_data( const struct select_ops *ops, int fd );
111 extern void select_loop(void);
113 /* socket functions */
115 extern int add_client( int client_fd, struct thread *self );
116 extern void remove_client( int client_fd, int exit_code );
117 extern void set_timeout( int client_fd, struct timeval *when );
118 extern int send_reply_v( int client_fd, int type, int pass_fd,
119 struct iovec *vec, int veclen );
121 /* event functions */
123 extern struct object *create_event( const char *name, int manual_reset, int initial_state );
124 extern int open_event( unsigned int access, int inherit, const char *name );
125 extern int pulse_event( int handle );
126 extern int set_event( int handle );
127 extern int reset_event( int handle );
130 /* mutex functions */
132 extern struct object *create_mutex( const char *name, int owned );
133 extern int open_mutex( unsigned int access, int inherit, const char *name );
134 extern int release_mutex( int handle );
135 extern void abandon_mutexes( struct thread *thread );
138 /* semaphore functions */
140 extern struct object *create_semaphore( const char *name, unsigned int initial, unsigned int max );
141 extern int open_semaphore( unsigned int access, int inherit, const char *name );
142 extern int release_semaphore( int handle, unsigned int count, unsigned int *prev_count );
145 /* file functions */
147 extern struct object *create_file( int fd, const char *name, unsigned int access,
148 unsigned int sharing, int create, unsigned int attrs );
149 extern struct file *get_file_obj( struct process *process, int handle,
150 unsigned int access );
151 extern int file_get_mmap_fd( struct file *file );
152 extern int set_file_pointer( int handle, int *low, int *high, int whence );
153 extern int truncate_file( int handle );
154 extern int grow_file( struct file *file, int size_high, int size_low );
155 extern struct file *create_temp_file( int access );
156 extern int set_file_time( int handle, time_t access_time, time_t write_time );
157 extern int file_lock( struct file *file, int offset_high, int offset_low,
158 int count_high, int count_low );
159 extern int file_unlock( struct file *file, int offset_high, int offset_low,
160 int count_high, int count_low );
161 extern void file_set_error(void);
164 /* pipe functions */
166 extern int create_pipe( struct object *obj[2] );
169 /* console functions */
171 struct tagINPUT_RECORD;
172 extern int create_console( int fd, struct object *obj[2] );
173 extern int set_console_fd( int handle, int fd, int pid );
174 extern int get_console_mode( int handle, int *mode );
175 extern int set_console_mode( int handle, int mode );
176 extern int set_console_info( int handle, struct set_console_info_request *req,
177 const char *title );
178 extern int get_console_info( int handle, struct get_console_info_reply *reply,
179 const char **title );
180 extern int write_console_input( int handle, int count, struct tagINPUT_RECORD *records );
181 extern int read_console_input( int handle, int count, int flush );
184 /* change notification functions */
186 extern struct object *create_change_notification( int subtree, int filter );
189 /* file mapping functions */
190 extern struct object *create_mapping( int size_high, int size_low, int protect,
191 int handle, const char *name );
192 extern int open_mapping( unsigned int access, int inherit, const char *name );
193 extern int get_mapping_info( int handle, struct get_mapping_info_reply *reply );
196 /* device functions */
197 extern struct object *create_device( int id );
200 /* snapshot functions */
201 extern struct object *create_snapshot( int flags );
202 extern int snapshot_next_process( int handle, int reset, struct next_process_reply *reply );
204 extern int debug_level;
206 #endif /* __WINE_SERVER_OBJECT_H */