4 * Copyright (C) 1998 Alexandre Julliard
7 #ifndef __WINE_SERVER_OBJECT_H
8 #define __WINE_SERVER_OBJECT_H
12 #include "wine/server_protocol.h"
23 struct wait_queue_entry;
27 /* operations valid on all objects */
30 /* size of this object type */
32 /* dump the object (for debugging) */
33 void (*dump)(struct object *,int);
34 /* add a thread to the object wait queue */
35 int (*add_queue)(struct object *,struct wait_queue_entry *);
36 /* remove a thread from the object wait queue */
37 void (*remove_queue)(struct object *,struct wait_queue_entry *);
38 /* is object signaled? */
39 int (*signaled)(struct object *,struct thread *);
40 /* wait satisfied; return 1 if abandoned */
41 int (*satisfied)(struct object *,struct thread *);
42 /* get the events we want to poll() for on this object */
43 int (*get_poll_events)(struct object *);
44 /* a poll() event occured */
45 void (*poll_event)(struct object *,int event);
46 /* return a Unix fd that can be used to read/write from the object */
47 int (*get_fd)(struct object *);
48 /* flush the object buffers */
49 int (*flush)(struct object *);
50 /* get file information */
51 int (*get_file_info)(struct object *,struct get_file_info_reply *);
52 /* queue an async operation */
53 struct async_queue* (*queue_async)(struct object *, struct async *async, int type, int count);
54 /* destroy on refcount == 0 */
55 void (*destroy)(struct object *);
60 unsigned int refcount; /* reference count */
61 int fd; /* file descriptor */
62 int select; /* select() user id */
63 const struct object_ops *ops;
64 struct wait_queue_entry *head;
65 struct wait_queue_entry *tail;
66 struct object_name *name;
73 struct wait_queue_entry
75 struct wait_queue_entry *next;
76 struct wait_queue_entry *prev;
78 struct thread *thread;
81 extern void *mem_alloc( size_t size ); /* malloc wrapper */
82 extern void *memdup( const void *data, size_t len );
83 extern void *alloc_object( const struct object_ops *ops, int fd );
84 extern void dump_object_name( struct object *obj );
85 extern void *create_named_object( const struct object_ops *ops, const WCHAR *name, size_t len );
86 /* grab/release_object can take any pointer, but you better make sure */
87 /* that the thing pointed to starts with a struct object... */
88 extern struct object *grab_object( void *obj );
89 extern void release_object( void *obj );
90 extern struct object *find_object( const WCHAR *name, size_t len );
91 extern int no_add_queue( struct object *obj, struct wait_queue_entry *entry );
92 extern int no_satisfied( struct object *obj, struct thread *thread );
93 extern int no_get_fd( struct object *obj );
94 extern int no_flush( struct object *obj );
95 extern int no_get_file_info( struct object *obj, struct get_file_info_reply *info );
96 extern void no_destroy( struct object *obj );
97 extern int default_poll_add_queue( struct object *obj, struct wait_queue_entry *entry );
98 extern void default_poll_remove_queue( struct object *obj, struct wait_queue_entry *entry );
99 extern int default_poll_signaled( struct object *obj, struct thread *thread );
100 extern void default_poll_event( struct object *obj, int event );
102 extern void dump_objects(void);
105 /* select functions */
107 extern int add_select_user( struct object *obj );
108 extern void remove_select_user( struct object *obj );
109 extern void change_select_fd( struct object *obj, int fd, int events );
110 extern void set_select_events( struct object *obj, int events );
111 extern int check_select_events( int fd, int events );
112 extern void select_loop(void);
114 /* timeout functions */
118 typedef void (*timeout_callback)( void *private );
120 extern struct timeout_user *add_timeout_user( struct timeval *when,
121 timeout_callback func, void *private );
122 extern void remove_timeout_user( struct timeout_user *user );
123 extern void add_timeout( struct timeval *when, int timeout );
124 /* return 1 if t1 is before t2 */
125 static inline int time_before( struct timeval *t1, struct timeval *t2 )
127 return ((t1->tv_sec < t2->tv_sec) ||
128 ((t1->tv_sec == t2->tv_sec) && (t1->tv_usec < t2->tv_usec)));
131 /* event functions */
135 extern struct event *create_event( const WCHAR *name, size_t len,
136 int manual_reset, int initial_state );
137 extern struct event *get_event_obj( struct process *process, handle_t handle, unsigned int access );
138 extern void pulse_event( struct event *event );
139 extern void set_event( struct event *event );
140 extern void reset_event( struct event *event );
142 /* mutex functions */
144 extern void abandon_mutexes( struct thread *thread );
148 extern struct file *get_file_obj( struct process *process, handle_t handle,
149 unsigned int access );
150 extern int is_same_file( struct file *file1, struct file *file2 );
151 extern int get_file_drive_type( struct file *file );
152 extern int grow_file( struct file *file, int size_high, int size_low );
153 extern int create_anonymous_file(void);
154 extern struct file *create_temp_file( int access );
155 extern void file_set_error(void);
157 /* serial functions */
159 int get_serial_async_timeout(struct object *obj, int type, int count);
161 /* debugger functions */
163 extern int set_process_debugger( struct process *process, struct thread *debugger );
164 extern void generate_debug_event( struct thread *thread, int code, void *arg );
165 extern void generate_startup_debug_events( struct process *process, void *entry );
166 extern void debug_exit_thread( struct thread *thread );
168 /* mapping functions */
170 extern int get_page_size(void);
172 /* registry functions */
174 extern void init_registry(void);
175 extern void close_registry(void);
179 extern void close_atom_table(void);
180 extern int grab_global_atom( atom_t atom );
181 extern void release_global_atom( atom_t atom );
183 /* global variables */
185 /* command-line options */
186 extern int debug_level;
187 extern int persistent_server;
189 /* server start time used for GetTickCount() */
190 extern unsigned int server_start_ticks;
192 #endif /* __WINE_SERVER_OBJECT_H */