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"
25 struct wait_queue_entry
;
27 /* operations valid on all objects */
30 /* dump the object (for debugging) */
31 void (*dump
)(struct object
*,int);
32 /* add a thread to the object wait queue */
33 int (*add_queue
)(struct object
*,struct wait_queue_entry
*);
34 /* remove a thread from the object wait queue */
35 void (*remove_queue
)(struct object
*,struct wait_queue_entry
*);
36 /* is object signaled? */
37 int (*signaled
)(struct object
*,struct thread
*);
38 /* wait satisfied; return 1 if abandoned */
39 int (*satisfied
)(struct object
*,struct thread
*);
40 /* return a Unix fd that can be used to read from the object */
41 int (*get_read_fd
)(struct object
*);
42 /* return a Unix fd that can be used to write to the object */
43 int (*get_write_fd
)(struct object
*);
44 /* flush the object buffers */
45 int (*flush
)(struct object
*);
46 /* get file information */
47 int (*get_file_info
)(struct object
*,struct get_file_info_reply
*);
48 /* destroy on refcount == 0 */
49 void (*destroy
)(struct object
*);
54 unsigned int refcount
;
55 const struct object_ops
*ops
;
56 struct wait_queue_entry
*head
;
57 struct wait_queue_entry
*tail
;
58 struct object_name
*name
;
61 extern void *mem_alloc( size_t size
); /* malloc wrapper */
62 extern struct object
*create_named_object( const char *name
, const struct object_ops
*ops
,
64 extern int init_object( struct object
*obj
, const struct object_ops
*ops
, const char *name
);
65 extern const char *get_object_name( struct object
*obj
);
66 /* grab/release_object can take any pointer, but you better make sure */
67 /* that the thing pointed to starts with a struct object... */
68 extern struct object
*grab_object( void *obj
);
69 extern void release_object( void *obj
);
70 extern struct object
*find_object( const char *name
);
71 extern int no_add_queue( struct object
*obj
, struct wait_queue_entry
*entry
);
72 extern int no_satisfied( struct object
*obj
, struct thread
*thread
);
73 extern int no_read_fd( struct object
*obj
);
74 extern int no_write_fd( struct object
*obj
);
75 extern int no_flush( struct object
*obj
);
76 extern int no_get_file_info( struct object
*obj
, struct get_file_info_reply
*info
);
77 extern void default_select_event( int fd
, int event
, void *private );
79 /* request handlers */
84 extern void call_req_handler( struct thread
*thread
, enum request req
,
85 void *data
, int len
, int fd
);
86 extern void call_timeout_handler( struct thread
*thread
);
87 extern void call_kill_handler( struct thread
*thread
, int exit_code
);
89 extern void trace_request( enum request req
, void *data
, int len
, int fd
);
90 extern void trace_timeout(void);
91 extern void trace_kill( int exit_code
);
92 extern void trace_reply( struct thread
*thread
, int type
, int pass_fd
,
93 struct iovec
*vec
, int veclen
);
95 /* select functions */
102 void (*event
)( int fd
, int event
, void *private );
103 void (*timeout
)( int fd
, void *private );
106 extern int add_select_user( int fd
, int events
, const struct select_ops
*ops
, void *private );
107 extern void remove_select_user( int fd
);
108 extern void set_select_timeout( int fd
, struct timeval
*when
);
109 extern void set_select_events( int fd
, int events
);
110 extern void *get_select_private_data( const struct select_ops
*ops
, int fd
);
111 extern void select_loop(void);
113 /* socket functions */
115 extern void server_init( int fd
);
116 extern int add_client( int client_fd
, struct thread
*self
);
117 extern void remove_client( int client_fd
, int exit_code
);
118 extern int get_initial_client_fd(void);
119 extern void set_timeout( int client_fd
, struct timeval
*when
);
120 extern int send_reply_v( int client_fd
, int type
, int pass_fd
,
121 struct iovec
*vec
, int veclen
);
123 /* event functions */
125 extern struct object
*create_event( const char *name
, int manual_reset
, int initial_state
);
126 extern int open_event( unsigned int access
, int inherit
, const char *name
);
127 extern int pulse_event( int handle
);
128 extern int set_event( int handle
);
129 extern int reset_event( int handle
);
132 /* mutex functions */
134 extern struct object
*create_mutex( const char *name
, int owned
);
135 extern int open_mutex( unsigned int access
, int inherit
, const char *name
);
136 extern int release_mutex( int handle
);
137 extern void abandon_mutexes( struct thread
*thread
);
140 /* semaphore functions */
142 extern struct object
*create_semaphore( const char *name
, unsigned int initial
, unsigned int max
);
143 extern int open_semaphore( unsigned int access
, int inherit
, const char *name
);
144 extern int release_semaphore( int handle
, unsigned int count
, unsigned int *prev_count
);
149 extern struct object
*create_file( int fd
, const char *name
, unsigned int access
,
150 unsigned int sharing
, int create
, unsigned int attrs
);
151 extern struct file
*get_file_obj( struct process
*process
, int handle
,
152 unsigned int access
);
153 extern int file_get_mmap_fd( struct file
*file
);
154 extern int set_file_pointer( int handle
, int *low
, int *high
, int whence
);
155 extern int truncate_file( int handle
);
156 extern int grow_file( struct file
*file
, int size_high
, int size_low
);
157 extern struct file
*create_temp_file( int access
);
158 extern int set_file_time( int handle
, time_t access_time
, time_t write_time
);
159 extern int file_lock( struct file
*file
, int offset_high
, int offset_low
,
160 int count_high
, int count_low
);
161 extern int file_unlock( struct file
*file
, int offset_high
, int offset_low
,
162 int count_high
, int count_low
);
163 extern void file_set_error(void);
168 extern int create_pipe( struct object
*obj
[2] );
171 /* console functions */
173 struct tagINPUT_RECORD
;
174 extern int create_console( int fd
, struct object
*obj
[2] );
175 extern int set_console_fd( int handle
, int fd
, int pid
);
176 extern int get_console_mode( int handle
, int *mode
);
177 extern int set_console_mode( int handle
, int mode
);
178 extern int set_console_info( int handle
, struct set_console_info_request
*req
,
180 extern int get_console_info( int handle
, struct get_console_info_reply
*reply
,
181 const char **title
);
182 extern int write_console_input( int handle
, int count
, struct tagINPUT_RECORD
*records
);
183 extern int read_console_input( int handle
, int count
, int flush
);
186 /* change notification functions */
188 extern struct object
*create_change_notification( int subtree
, int filter
);
191 /* file mapping functions */
192 extern struct object
*create_mapping( int size_high
, int size_low
, int protect
,
193 int handle
, const char *name
);
194 extern int open_mapping( unsigned int access
, int inherit
, const char *name
);
195 extern int get_mapping_info( int handle
, struct get_mapping_info_reply
*reply
);
198 /* device functions */
199 extern struct object
*create_device( int id
);
202 /* snapshot functions */
203 extern struct object
*create_snapshot( int flags
);
204 extern int snapshot_next_process( int handle
, int reset
, struct next_process_reply
*reply
);
206 extern int debug_level
;
208 #endif /* __WINE_SERVER_OBJECT_H */