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
16 #include "server/request.h"
23 struct wait_queue_entry
;
27 /* dump the object (for debugging) */
28 void (*dump
)(struct object
*,int);
29 /* add a thread to the object wait queue */
30 void (*add_queue
)(struct object
*,struct wait_queue_entry
*);
31 /* remove a thread from the object wait queue */
32 void (*remove_queue
)(struct object
*,struct wait_queue_entry
*);
33 /* is object signaled? */
34 int (*signaled
)(struct object
*,struct thread
*);
35 /* wait satisfied; return 1 if abandoned */
36 int (*satisfied
)(struct object
*,struct thread
*);
37 /* destroy on refcount == 0 */
38 void (*destroy
)(struct object
*);
43 unsigned int refcount
;
44 const struct object_ops
*ops
;
45 struct wait_queue_entry
*head
;
46 struct wait_queue_entry
*tail
;
47 struct object_name
*name
;
50 extern void *mem_alloc( size_t size
); /* malloc wrapper */
51 extern struct object
*create_named_object( const char *name
, const struct object_ops
*ops
,
53 extern int init_object( struct object
*obj
, const struct object_ops
*ops
,
55 /* grab/release_object can take any pointer, but you better make sure */
56 /* that the thing pointed to starts with a struct object... */
57 extern struct object
*grab_object( void *obj
);
58 extern void release_object( void *obj
);
59 extern struct object
*find_object( const char *name
);
61 /* request handlers */
66 extern void call_req_handler( struct thread
*thread
, enum request req
,
67 void *data
, int len
, int fd
);
68 extern void call_timeout_handler( struct thread
*thread
);
69 extern void call_kill_handler( struct thread
*thread
, int exit_code
);
71 extern void trace_request( enum request req
, void *data
, int len
, int fd
);
72 extern void trace_timeout(void);
73 extern void trace_kill( int exit_code
);
74 extern void trace_reply( struct thread
*thread
, int type
, int pass_fd
,
75 struct iovec
*vec
, int veclen
);
77 /* select functions */
84 void (*event
)( int fd
, int event
, void *private );
85 void (*timeout
)( int fd
, void *private );
88 extern int add_select_user( int fd
, int events
, const struct select_ops
*ops
, void *private );
89 extern void remove_select_user( int fd
);
90 extern void set_select_timeout( int fd
, struct timeval
*when
);
91 extern void set_select_events( int fd
, int events
);
92 extern void *get_select_private_data( const struct select_ops
*ops
, int fd
);
93 extern void select_loop(void);
95 /* socket functions */
97 extern void server_init( int fd
);
98 extern int add_client( int client_fd
, struct thread
*self
);
99 extern void remove_client( int client_fd
, int exit_code
);
100 extern int get_initial_client_fd(void);
101 extern void set_timeout( int client_fd
, struct timeval
*when
);
102 extern int send_reply_v( int client_fd
, int type
, int pass_fd
,
103 struct iovec
*vec
, int veclen
);
105 /* process functions */
109 extern struct process
*create_process(void);
110 extern struct process
*get_process_from_id( void *id
);
111 extern struct process
*get_process_from_handle( int handle
, unsigned int access
);
112 extern void add_process_thread( struct process
*process
,
113 struct thread
*thread
);
114 extern void remove_process_thread( struct process
*process
,
115 struct thread
*thread
);
116 extern void kill_process( struct process
*process
, int exit_code
);
117 extern void get_process_info( struct process
*process
,
118 struct get_process_info_reply
*reply
);
120 /* handle functions */
122 /* alloc_handle takes a void *obj for convenience, but you better make sure */
123 /* that the thing pointed to starts with a struct object... */
124 extern int alloc_handle( struct process
*process
, void *obj
,
125 unsigned int access
, int inherit
);
126 extern int close_handle( struct process
*process
, int handle
);
127 extern int set_handle_info( struct process
*process
, int handle
,
128 int mask
, int flags
);
129 extern struct object
*get_handle_obj( struct process
*process
, int handle
,
130 unsigned int access
, const struct object_ops
*ops
);
131 extern int duplicate_handle( struct process
*src
, int src_handle
, struct process
*dst
,
132 int dst_handle
, unsigned int access
, int inherit
, int options
);
133 extern int open_object( const char *name
, const struct object_ops
*ops
,
134 unsigned int access
, int inherit
);
136 /* event functions */
138 extern struct object
*create_event( const char *name
, int manual_reset
, int initial_state
);
139 extern int open_event( unsigned int access
, int inherit
, const char *name
);
140 extern int pulse_event( int handle
);
141 extern int set_event( int handle
);
142 extern int reset_event( int handle
);
145 /* mutex functions */
147 extern struct object
*create_mutex( const char *name
, int owned
);
148 extern int open_mutex( unsigned int access
, int inherit
, const char *name
);
149 extern int release_mutex( int handle
);
150 extern void abandon_mutexes( struct thread
*thread
);
153 /* semaphore functions */
155 extern struct object
*create_semaphore( const char *name
, unsigned int initial
, unsigned int max
);
156 extern int open_semaphore( unsigned int access
, int inherit
, const char *name
);
157 extern int release_semaphore( int handle
, unsigned int count
, unsigned int *prev_count
);
162 extern struct object
*create_file( int fd
);
163 extern int file_get_unix_handle( int handle
, unsigned int access
);
164 extern int get_file_info( int handle
, struct get_file_info_reply
*reply
);
166 extern int debug_level
;
168 #endif /* __WINE_SERVER_OBJECT_H */