Removed dependency on 16-bit file I/O functions.
[wine/multimedia.git] / server / request.h
blob14dc2e3bafece89328cfc4d9ddc0cae9cef0759e
1 /*
2 * Wine server requests
4 * Copyright (C) 1999 Alexandre Julliard
5 */
7 #ifndef __WINE_SERVER_REQUEST_H
8 #define __WINE_SERVER_REQUEST_H
10 #ifndef __WINE_SERVER__
11 #error This file can only be used in the Wine server
12 #endif
14 #include "thread.h"
16 /* max request length */
17 #define MAX_REQUEST_LENGTH 8192
19 /* request handler definition */
20 #define DECL_HANDLER(name) void req_##name( struct name##_request *req )
22 /* request functions */
24 #ifdef __GNUC__
25 extern void fatal_protocol_error( struct thread *thread,
26 const char *err, ... ) __attribute__((format (printf,2,3)));
27 #else
28 extern void fatal_protocol_error( struct thread *thread, const char *err, ... );
29 #endif
31 extern void fatal_error( const char *err, ... ) WINE_NORETURN;
32 extern void fatal_perror( const char *err, ... ) WINE_NORETURN;
33 extern const char *get_config_dir(void);
34 extern void read_request( struct thread *thread );
35 extern int write_request( struct thread *thread );
36 extern void set_reply_fd( struct thread *thread, int pass_fd );
37 extern void send_reply( struct thread *thread );
38 extern void open_master_socket(void);
39 extern void close_master_socket(void);
40 extern void lock_master_socket( int locked );
42 extern void trace_request( enum request req );
43 extern void trace_reply( struct thread *thread );
45 /* get the request buffer */
46 static inline void *get_req_ptr( struct thread *thread )
48 return thread->buffer;
51 /* get the request vararg data */
52 inline static void *get_req_data( const void *req )
54 return ((union generic_request *)req + 1);
57 /* get the request vararg size */
58 inline static size_t get_req_data_size( const void *req )
60 return ((struct request_header *)req)->var_size;
63 /* set the request vararg size */
64 inline static void set_req_data_size( const void *req, size_t size )
66 ((struct request_header *)req)->var_size = size;
70 #define REQUEST_END(req) ((char *)(req) + MAX_REQUEST_LENGTH - sizeof(struct server_buffer_info))
72 /* get the remaining size in the request buffer for object of a given size */
73 static inline int get_req_size( const void *req, const void *ptr, size_t typesize )
75 return (REQUEST_END(req) - (char *)ptr) / typesize;
78 /* get the length of a request string, without going past the end of the request */
79 static inline size_t get_req_strlen( const void *req, const char *str )
81 const char *p = str;
82 while (*p && (p < REQUEST_END(req) - 1)) p++;
83 return p - str;
86 /* same as above for Unicode */
87 static inline size_t get_req_strlenW( const void *req, const WCHAR *str )
89 const WCHAR *p = str;
90 while (*p && (p < (WCHAR *)REQUEST_END(req) - 1)) p++;
91 return p - str;
94 /* Everything below this line is generated automatically by tools/make_requests */
95 /* ### make_requests begin ### */
97 DECL_HANDLER(new_process);
98 DECL_HANDLER(wait_process);
99 DECL_HANDLER(new_thread);
100 DECL_HANDLER(boot_done);
101 DECL_HANDLER(init_process);
102 DECL_HANDLER(init_process_done);
103 DECL_HANDLER(init_thread);
104 DECL_HANDLER(get_thread_buffer);
105 DECL_HANDLER(terminate_process);
106 DECL_HANDLER(terminate_thread);
107 DECL_HANDLER(get_process_info);
108 DECL_HANDLER(set_process_info);
109 DECL_HANDLER(get_thread_info);
110 DECL_HANDLER(set_thread_info);
111 DECL_HANDLER(suspend_thread);
112 DECL_HANDLER(resume_thread);
113 DECL_HANDLER(load_dll);
114 DECL_HANDLER(unload_dll);
115 DECL_HANDLER(queue_apc);
116 DECL_HANDLER(get_apc);
117 DECL_HANDLER(close_handle);
118 DECL_HANDLER(get_handle_info);
119 DECL_HANDLER(set_handle_info);
120 DECL_HANDLER(dup_handle);
121 DECL_HANDLER(open_process);
122 DECL_HANDLER(select);
123 DECL_HANDLER(create_event);
124 DECL_HANDLER(event_op);
125 DECL_HANDLER(open_event);
126 DECL_HANDLER(create_mutex);
127 DECL_HANDLER(release_mutex);
128 DECL_HANDLER(open_mutex);
129 DECL_HANDLER(create_semaphore);
130 DECL_HANDLER(release_semaphore);
131 DECL_HANDLER(open_semaphore);
132 DECL_HANDLER(create_file);
133 DECL_HANDLER(alloc_file_handle);
134 DECL_HANDLER(get_read_fd);
135 DECL_HANDLER(get_write_fd);
136 DECL_HANDLER(set_file_pointer);
137 DECL_HANDLER(truncate_file);
138 DECL_HANDLER(set_file_time);
139 DECL_HANDLER(flush_file);
140 DECL_HANDLER(get_file_info);
141 DECL_HANDLER(lock_file);
142 DECL_HANDLER(unlock_file);
143 DECL_HANDLER(create_pipe);
144 DECL_HANDLER(create_socket);
145 DECL_HANDLER(accept_socket);
146 DECL_HANDLER(set_socket_event);
147 DECL_HANDLER(get_socket_event);
148 DECL_HANDLER(enable_socket_event);
149 DECL_HANDLER(alloc_console);
150 DECL_HANDLER(free_console);
151 DECL_HANDLER(open_console);
152 DECL_HANDLER(set_console_fd);
153 DECL_HANDLER(get_console_mode);
154 DECL_HANDLER(set_console_mode);
155 DECL_HANDLER(set_console_info);
156 DECL_HANDLER(get_console_info);
157 DECL_HANDLER(write_console_input);
158 DECL_HANDLER(read_console_input);
159 DECL_HANDLER(create_change_notification);
160 DECL_HANDLER(create_mapping);
161 DECL_HANDLER(open_mapping);
162 DECL_HANDLER(get_mapping_info);
163 DECL_HANDLER(create_device);
164 DECL_HANDLER(create_snapshot);
165 DECL_HANDLER(next_process);
166 DECL_HANDLER(next_thread);
167 DECL_HANDLER(next_module);
168 DECL_HANDLER(wait_debug_event);
169 DECL_HANDLER(exception_event);
170 DECL_HANDLER(output_debug_string);
171 DECL_HANDLER(continue_debug_event);
172 DECL_HANDLER(debug_process);
173 DECL_HANDLER(read_process_memory);
174 DECL_HANDLER(write_process_memory);
175 DECL_HANDLER(create_key);
176 DECL_HANDLER(open_key);
177 DECL_HANDLER(delete_key);
178 DECL_HANDLER(enum_key);
179 DECL_HANDLER(set_key_value);
180 DECL_HANDLER(get_key_value);
181 DECL_HANDLER(enum_key_value);
182 DECL_HANDLER(delete_key_value);
183 DECL_HANDLER(load_registry);
184 DECL_HANDLER(save_registry);
185 DECL_HANDLER(save_registry_atexit);
186 DECL_HANDLER(set_registry_levels);
187 DECL_HANDLER(create_timer);
188 DECL_HANDLER(open_timer);
189 DECL_HANDLER(set_timer);
190 DECL_HANDLER(cancel_timer);
191 DECL_HANDLER(get_thread_context);
192 DECL_HANDLER(set_thread_context);
193 DECL_HANDLER(get_selector_entry);
194 DECL_HANDLER(add_atom);
195 DECL_HANDLER(delete_atom);
196 DECL_HANDLER(find_atom);
197 DECL_HANDLER(get_atom_name);
198 DECL_HANDLER(init_atom_table);
199 DECL_HANDLER(get_msg_queue);
200 DECL_HANDLER(wake_queue);
201 DECL_HANDLER(wait_input_idle);
202 DECL_HANDLER(create_serial);
203 DECL_HANDLER(get_serial_info);
204 DECL_HANDLER(set_serial_info);
205 DECL_HANDLER(create_async);
206 DECL_HANDLER(async_result);
208 #ifdef WANT_REQUEST_HANDLERS
210 typedef void (*req_handler)( void *req );
211 static const req_handler req_handlers[REQ_NB_REQUESTS] =
213 (req_handler)req_new_process,
214 (req_handler)req_wait_process,
215 (req_handler)req_new_thread,
216 (req_handler)req_boot_done,
217 (req_handler)req_init_process,
218 (req_handler)req_init_process_done,
219 (req_handler)req_init_thread,
220 (req_handler)req_get_thread_buffer,
221 (req_handler)req_terminate_process,
222 (req_handler)req_terminate_thread,
223 (req_handler)req_get_process_info,
224 (req_handler)req_set_process_info,
225 (req_handler)req_get_thread_info,
226 (req_handler)req_set_thread_info,
227 (req_handler)req_suspend_thread,
228 (req_handler)req_resume_thread,
229 (req_handler)req_load_dll,
230 (req_handler)req_unload_dll,
231 (req_handler)req_queue_apc,
232 (req_handler)req_get_apc,
233 (req_handler)req_close_handle,
234 (req_handler)req_get_handle_info,
235 (req_handler)req_set_handle_info,
236 (req_handler)req_dup_handle,
237 (req_handler)req_open_process,
238 (req_handler)req_select,
239 (req_handler)req_create_event,
240 (req_handler)req_event_op,
241 (req_handler)req_open_event,
242 (req_handler)req_create_mutex,
243 (req_handler)req_release_mutex,
244 (req_handler)req_open_mutex,
245 (req_handler)req_create_semaphore,
246 (req_handler)req_release_semaphore,
247 (req_handler)req_open_semaphore,
248 (req_handler)req_create_file,
249 (req_handler)req_alloc_file_handle,
250 (req_handler)req_get_read_fd,
251 (req_handler)req_get_write_fd,
252 (req_handler)req_set_file_pointer,
253 (req_handler)req_truncate_file,
254 (req_handler)req_set_file_time,
255 (req_handler)req_flush_file,
256 (req_handler)req_get_file_info,
257 (req_handler)req_lock_file,
258 (req_handler)req_unlock_file,
259 (req_handler)req_create_pipe,
260 (req_handler)req_create_socket,
261 (req_handler)req_accept_socket,
262 (req_handler)req_set_socket_event,
263 (req_handler)req_get_socket_event,
264 (req_handler)req_enable_socket_event,
265 (req_handler)req_alloc_console,
266 (req_handler)req_free_console,
267 (req_handler)req_open_console,
268 (req_handler)req_set_console_fd,
269 (req_handler)req_get_console_mode,
270 (req_handler)req_set_console_mode,
271 (req_handler)req_set_console_info,
272 (req_handler)req_get_console_info,
273 (req_handler)req_write_console_input,
274 (req_handler)req_read_console_input,
275 (req_handler)req_create_change_notification,
276 (req_handler)req_create_mapping,
277 (req_handler)req_open_mapping,
278 (req_handler)req_get_mapping_info,
279 (req_handler)req_create_device,
280 (req_handler)req_create_snapshot,
281 (req_handler)req_next_process,
282 (req_handler)req_next_thread,
283 (req_handler)req_next_module,
284 (req_handler)req_wait_debug_event,
285 (req_handler)req_exception_event,
286 (req_handler)req_output_debug_string,
287 (req_handler)req_continue_debug_event,
288 (req_handler)req_debug_process,
289 (req_handler)req_read_process_memory,
290 (req_handler)req_write_process_memory,
291 (req_handler)req_create_key,
292 (req_handler)req_open_key,
293 (req_handler)req_delete_key,
294 (req_handler)req_enum_key,
295 (req_handler)req_set_key_value,
296 (req_handler)req_get_key_value,
297 (req_handler)req_enum_key_value,
298 (req_handler)req_delete_key_value,
299 (req_handler)req_load_registry,
300 (req_handler)req_save_registry,
301 (req_handler)req_save_registry_atexit,
302 (req_handler)req_set_registry_levels,
303 (req_handler)req_create_timer,
304 (req_handler)req_open_timer,
305 (req_handler)req_set_timer,
306 (req_handler)req_cancel_timer,
307 (req_handler)req_get_thread_context,
308 (req_handler)req_set_thread_context,
309 (req_handler)req_get_selector_entry,
310 (req_handler)req_add_atom,
311 (req_handler)req_delete_atom,
312 (req_handler)req_find_atom,
313 (req_handler)req_get_atom_name,
314 (req_handler)req_init_atom_table,
315 (req_handler)req_get_msg_queue,
316 (req_handler)req_wake_queue,
317 (req_handler)req_wait_input_idle,
318 (req_handler)req_create_serial,
319 (req_handler)req_get_serial_info,
320 (req_handler)req_set_serial_info,
321 (req_handler)req_create_async,
322 (req_handler)req_async_result,
324 #endif /* WANT_REQUEST_HANDLERS */
326 /* ### make_requests end ### */
327 /* Everything above this line is generated automatically by tools/make_requests */
329 #endif /* __WINE_SERVER_REQUEST_H */