4 * Copyright (C) 1998 Alexandre Julliard
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
26 struct wait_queue_entry
;
28 /* operations valid on all objects */
31 /* size of this object type */
33 /* dump the object (for debugging) */
34 void (*dump
)(struct object
*,int);
35 /* add a thread to the object wait queue */
36 int (*add_queue
)(struct object
*,struct wait_queue_entry
*);
37 /* remove a thread from the object wait queue */
38 void (*remove_queue
)(struct object
*,struct wait_queue_entry
*);
39 /* is object signaled? */
40 int (*signaled
)(struct object
*,struct thread
*);
41 /* wait satisfied; return 1 if abandoned */
42 int (*satisfied
)(struct object
*,struct thread
*);
43 /* return a Unix fd that can be used to read from the object */
44 int (*get_read_fd
)(struct object
*);
45 /* return a Unix fd that can be used to write to the object */
46 int (*get_write_fd
)(struct object
*);
47 /* flush the object buffers */
48 int (*flush
)(struct object
*);
49 /* get file information */
50 int (*get_file_info
)(struct object
*,struct get_file_info_request
*);
51 /* destroy on refcount == 0 */
52 void (*destroy
)(struct object
*);
57 unsigned int refcount
;
58 const struct object_ops
*ops
;
59 struct wait_queue_entry
*head
;
60 struct wait_queue_entry
*tail
;
61 struct object_name
*name
;
68 extern void *mem_alloc( size_t size
); /* malloc wrapper */
69 extern void *memdup( const void *data
, size_t len
);
70 extern void *alloc_object( const struct object_ops
*ops
);
71 extern void dump_object_name( struct object
*obj
);
72 extern void *create_named_object( const struct object_ops
*ops
, const WCHAR
*name
, size_t len
);
73 /* grab/release_object can take any pointer, but you better make sure */
74 /* that the thing pointed to starts with a struct object... */
75 extern struct object
*grab_object( void *obj
);
76 extern void release_object( void *obj
);
77 extern struct object
*find_object( const WCHAR
*name
, size_t len
);
78 extern int no_add_queue( struct object
*obj
, struct wait_queue_entry
*entry
);
79 extern int no_satisfied( struct object
*obj
, struct thread
*thread
);
80 extern int no_read_fd( struct object
*obj
);
81 extern int no_write_fd( struct object
*obj
);
82 extern int no_flush( struct object
*obj
);
83 extern int no_get_file_info( struct object
*obj
, struct get_file_info_request
*info
);
84 extern void no_destroy( struct object
*obj
);
85 extern void default_select_event( int event
, void *private );
87 extern void dump_objects(void);
90 /* select functions */
94 #define EXCEPT_EVENT 4
99 void (*func
)(int event
, void *private); /* callback function */
100 void *private; /* callback private data */
103 extern void register_select_user( struct select_user
*user
);
104 extern void unregister_select_user( struct select_user
*user
);
105 extern void set_select_events( struct select_user
*user
, int events
);
106 extern int check_select_events( struct select_user
*user
, int events
);
107 extern void select_loop(void);
109 /* timeout functions */
113 typedef void (*timeout_callback
)( void *private );
115 extern struct timeout_user
*add_timeout_user( struct timeval
*when
,
116 timeout_callback func
, void *private );
117 extern void remove_timeout_user( struct timeout_user
*user
);
118 extern void make_timeout( struct timeval
*when
, int timeout
);
120 /* socket functions */
124 extern struct client
*add_client( int client_fd
, struct thread
*self
);
125 extern void remove_client( struct client
*client
, int exit_code
);
126 extern void client_pass_fd( struct client
*client
, int pass_fd
);
127 extern void client_reply( struct client
*client
, unsigned int res
);
129 /* event functions */
133 extern struct event
*get_event_obj( struct process
*process
, int handle
, unsigned int access
);
134 extern void pulse_event( struct event
*event
);
135 extern void set_event( struct event
*event
);
136 extern void reset_event( struct event
*event
);
138 /* mutex functions */
140 extern void abandon_mutexes( struct thread
*thread
);
144 extern struct file
*get_file_obj( struct process
*process
, int handle
,
145 unsigned int access
);
146 extern int file_get_mmap_fd( struct file
*file
);
147 extern int grow_file( struct file
*file
, int size_high
, int size_low
);
148 extern int create_anonymous_file(void);
149 extern struct file
*create_temp_file( int access
);
150 extern void file_set_error(void);
152 /* console functions */
154 extern int alloc_console( struct process
*process
);
155 extern int free_console( struct process
*process
);
157 /* debugger functions */
159 extern int debugger_attach( struct process
*process
, struct thread
*debugger
);
160 extern void debug_exit_thread( struct thread
*thread
, int exit_code
);
162 /* mapping functions */
164 extern int get_page_size(void);
166 /* registry functions */
168 extern void close_registry(void);
170 extern int debug_level
;
172 #endif /* __WINE_SERVER_OBJECT_H */