Use libwine and libwine_unicode directly from their build directory
[wine/multimedia.git] / server / object.h
blob746b7f6641b73475f2b21310e7ae867a20ba5043
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/poll.h>
15 #include <sys/time.h>
16 #include "server.h"
18 #define DEBUG_OBJECTS
20 /* kernel objects */
22 struct object;
23 struct object_name;
24 struct thread;
25 struct process;
26 struct file;
27 struct wait_queue_entry;
28 struct async;
30 /* operations valid on all objects */
31 struct object_ops
33 /* size of this object type */
34 size_t size;
35 /* dump the object (for debugging) */
36 void (*dump)(struct object *,int);
37 /* add a thread to the object wait queue */
38 int (*add_queue)(struct object *,struct wait_queue_entry *);
39 /* remove a thread from the object wait queue */
40 void (*remove_queue)(struct object *,struct wait_queue_entry *);
41 /* is object signaled? */
42 int (*signaled)(struct object *,struct thread *);
43 /* wait satisfied; return 1 if abandoned */
44 int (*satisfied)(struct object *,struct thread *);
45 /* get the events we want to poll() for on this object */
46 int (*get_poll_events)(struct object *);
47 /* a poll() event occured */
48 void (*poll_event)(struct object *,int event);
49 /* return a Unix fd that can be used to read from the object */
50 int (*get_read_fd)(struct object *);
51 /* return a Unix fd that can be used to write to the object */
52 int (*get_write_fd)(struct object *);
53 /* flush the object buffers */
54 int (*flush)(struct object *);
55 /* get file information */
56 int (*get_file_info)(struct object *,struct get_file_info_request *);
57 /* destroy on refcount == 0 */
58 void (*destroy)(struct object *);
61 struct object
63 unsigned int refcount; /* reference count */
64 int fd; /* file descriptor */
65 int select; /* select() user id */
66 const struct object_ops *ops;
67 struct wait_queue_entry *head;
68 struct wait_queue_entry *tail;
69 struct object_name *name;
70 #ifdef DEBUG_OBJECTS
71 struct object *prev;
72 struct object *next;
73 #endif
76 struct wait_queue_entry
78 struct wait_queue_entry *next;
79 struct wait_queue_entry *prev;
80 struct object *obj;
81 struct thread *thread;
84 extern void *mem_alloc( size_t size ); /* malloc wrapper */
85 extern void *memdup( const void *data, size_t len );
86 extern void *alloc_object( const struct object_ops *ops, int fd );
87 extern void dump_object_name( struct object *obj );
88 extern void *create_named_object( const struct object_ops *ops, const WCHAR *name, size_t len );
89 /* grab/release_object can take any pointer, but you better make sure */
90 /* that the thing pointed to starts with a struct object... */
91 extern struct object *grab_object( void *obj );
92 extern void release_object( void *obj );
93 extern struct object *find_object( const WCHAR *name, size_t len );
94 extern int no_add_queue( struct object *obj, struct wait_queue_entry *entry );
95 extern int no_satisfied( struct object *obj, struct thread *thread );
96 extern int no_read_fd( struct object *obj );
97 extern int no_write_fd( struct object *obj );
98 extern int no_flush( struct object *obj );
99 extern int no_get_file_info( struct object *obj, struct get_file_info_request *info );
100 extern void no_destroy( struct object *obj );
101 extern int default_poll_add_queue( struct object *obj, struct wait_queue_entry *entry );
102 extern void default_poll_remove_queue( struct object *obj, struct wait_queue_entry *entry );
103 extern int default_poll_signaled( struct object *obj, struct thread *thread );
104 extern void default_poll_event( struct object *obj, int event );
105 #ifdef DEBUG_OBJECTS
106 extern void dump_objects(void);
107 #endif
109 /* select functions */
111 extern int add_select_user( struct object *obj );
112 extern void remove_select_user( struct object *obj );
113 extern void change_select_fd( struct object *obj, int fd );
114 extern void set_select_events( struct object *obj, int events );
115 extern int check_select_events( int fd, int events );
116 extern void select_loop(void);
118 /* timeout functions */
120 struct timeout_user;
122 typedef void (*timeout_callback)( void *private );
124 extern struct timeout_user *add_timeout_user( struct timeval *when,
125 timeout_callback func, void *private );
126 extern void remove_timeout_user( struct timeout_user *user );
127 extern void add_timeout( struct timeval *when, int timeout );
128 /* return 1 if t1 is before t2 */
129 static inline int time_before( struct timeval *t1, struct timeval *t2 )
131 return ((t1->tv_sec < t2->tv_sec) ||
132 ((t1->tv_sec == t2->tv_sec) && (t1->tv_usec < t2->tv_usec)));
135 /* event functions */
137 struct event;
139 extern struct event *create_event( const WCHAR *name, size_t len,
140 int manual_reset, int initial_state );
141 extern struct event *get_event_obj( struct process *process, int handle, unsigned int access );
142 extern void pulse_event( struct event *event );
143 extern void set_event( struct event *event );
144 extern void reset_event( struct event *event );
146 /* mutex functions */
148 extern void abandon_mutexes( struct thread *thread );
150 /* file functions */
152 extern struct file *get_file_obj( struct process *process, int handle,
153 unsigned int access );
154 extern int file_get_mmap_fd( struct file *file );
155 extern int grow_file( struct file *file, int size_high, int size_low );
156 extern int create_anonymous_file(void);
157 extern struct file *create_temp_file( int access );
158 extern void file_set_error(void);
160 /* async functions */
162 void async_add_timeout(struct async *ov, int timeout);
163 int async_count(struct async *ov);
164 int async_type(struct async *ov);
165 int async_get_eventmask(struct async *ov);
166 int async_set_eventmask(struct async *ov, int eventmask);
168 /* serial functions */
170 int serial_async_setup(struct object *obj, struct async *ov);
171 int serial_async_get_poll_events( struct async *ov );
172 int serial_async_poll_event(struct object *obj, int event);
174 /* console functions */
176 extern int alloc_console( struct process *process );
177 extern int free_console( struct process *process );
179 /* debugger functions */
181 extern int set_process_debugger( struct process *process, struct thread *debugger );
182 extern void generate_debug_event( struct thread *thread, int code, void *arg );
183 extern void generate_startup_debug_events( struct process *process, void *entry );
184 extern void debug_exit_thread( struct thread *thread );
186 /* mapping functions */
188 extern int get_page_size(void);
190 /* registry functions */
192 extern void init_registry(void);
193 extern void close_registry(void);
195 /* atom functions */
197 extern void close_atom_table(void);
199 /* global variables */
201 /* command-line options */
202 extern int debug_level;
203 extern int persistent_server;
205 /* server start time used for GetTickCount() */
206 extern unsigned int server_start_ticks;
208 #endif /* __WINE_SERVER_OBJECT_H */