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"
26 void (*dump
)(struct object
*,int); /* dump the object (for debugging) */
27 int (*signaled
)(struct object
*,struct thread
*); /* is object signaled? */
28 int (*satisfied
)(struct object
*,struct thread
*); /* wait satisfied; return 1 if abandoned */
29 void (*destroy
)(struct object
*); /* destroy on refcount == 0 */
34 unsigned int refcount
;
35 const struct object_ops
*ops
;
36 struct wait_queue_entry
*head
;
37 struct wait_queue_entry
*tail
;
38 struct object_name
*name
;
41 extern void *mem_alloc( size_t size
); /* malloc wrapper */
42 extern struct object
*create_named_object( const char *name
, const struct object_ops
*ops
,
44 extern int init_object( struct object
*obj
, const struct object_ops
*ops
,
46 /* grab/release_object can take any pointer, but you better make sure */
47 /* that the thing pointed to starts with a struct object... */
48 extern struct object
*grab_object( void *obj
);
49 extern void release_object( void *obj
);
50 extern struct object
*find_object( const char *name
);
52 /* request handlers */
57 extern void call_req_handler( struct thread
*thread
, enum request req
,
58 void *data
, int len
, int fd
);
59 extern void call_timeout_handler( struct thread
*thread
);
60 extern void call_kill_handler( struct thread
*thread
, int exit_code
);
62 extern void trace_request( enum request req
, void *data
, int len
, int fd
);
63 extern void trace_timeout(void);
64 extern void trace_kill( int exit_code
);
65 extern void trace_reply( struct thread
*thread
, int type
, int pass_fd
,
66 struct iovec
*vec
, int veclen
);
68 /* socket functions */
70 extern int add_client( int client_fd
, struct thread
*self
);
71 extern void remove_client( int client_fd
, int exit_code
);
72 extern int get_initial_client_fd(void);
73 extern void set_timeout( int client_fd
, struct timeval
*when
);
74 extern int send_reply_v( int client_fd
, int type
, int pass_fd
,
75 struct iovec
*vec
, int veclen
);
77 /* process functions */
81 extern struct process
*create_process(void);
82 extern struct process
*get_process_from_id( void *id
);
83 extern struct process
*get_process_from_handle( int handle
, unsigned int access
);
84 extern void add_process_thread( struct process
*process
,
85 struct thread
*thread
);
86 extern void remove_process_thread( struct process
*process
,
87 struct thread
*thread
);
88 extern void kill_process( struct process
*process
, int exit_code
);
89 extern void get_process_info( struct process
*process
,
90 struct get_process_info_reply
*reply
);
92 /* handle functions */
94 /* alloc_handle takes a void *obj for convenience, but you better make sure */
95 /* that the thing pointed to starts with a struct object... */
96 extern int alloc_handle( struct process
*process
, void *obj
,
97 unsigned int access
, int inherit
);
98 extern int close_handle( struct process
*process
, int handle
);
99 extern int set_handle_info( struct process
*process
, int handle
,
100 int mask
, int flags
);
101 extern struct object
*get_handle_obj( struct process
*process
, int handle
,
102 unsigned int access
, const struct object_ops
*ops
);
103 extern int duplicate_handle( struct process
*src
, int src_handle
, struct process
*dst
,
104 int dst_handle
, unsigned int access
, int inherit
, int options
);
105 extern int open_object( const char *name
, const struct object_ops
*ops
,
106 unsigned int access
, int inherit
);
108 /* event functions */
110 extern struct object
*create_event( const char *name
, int manual_reset
, int initial_state
);
111 extern int open_event( unsigned int access
, int inherit
, const char *name
);
112 extern int pulse_event( int handle
);
113 extern int set_event( int handle
);
114 extern int reset_event( int handle
);
117 /* mutex functions */
119 extern struct object
*create_mutex( const char *name
, int owned
);
120 extern int open_mutex( unsigned int access
, int inherit
, const char *name
);
121 extern int release_mutex( int handle
);
122 extern void abandon_mutexes( struct thread
*thread
);
125 /* semaphore functions */
127 extern struct object
*create_semaphore( const char *name
, unsigned int initial
, unsigned int max
);
128 extern int open_semaphore( unsigned int access
, int inherit
, const char *name
);
129 extern int release_semaphore( int handle
, unsigned int count
, unsigned int *prev_count
);
131 extern int debug_level
;
133 #endif /* __WINE_SERVER_OBJECT_H */