- factorize Clear method between Viewport and Device
[wine] / server / request.h
1 /*
2  * Wine server requests
3  *
4  * Copyright (C) 1999 Alexandre Julliard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #ifndef __WINE_SERVER_REQUEST_H
22 #define __WINE_SERVER_REQUEST_H
23
24 #include <assert.h>
25
26 #include "thread.h"
27 #include "wine/server_protocol.h"
28
29 /* max request length */
30 #define MAX_REQUEST_LENGTH  8192
31
32 /* request handler definition */
33 #define DECL_HANDLER(name) \
34     void req_##name( const struct name##_request *req, struct name##_reply *reply )
35
36 /* request functions */
37
38 #ifdef __GNUC__
39 extern void fatal_protocol_error( struct thread *thread,
40                                   const char *err, ... ) __attribute__((format (printf,2,3)));
41 extern void fatal_protocol_perror( struct thread *thread,
42                                    const char *err, ... ) __attribute__((format (printf,2,3)));
43 extern void fatal_error( const char *err, ... )  __attribute__((noreturn,format(printf,1,2)));
44 extern void fatal_perror( const char *err, ... )  __attribute__((noreturn,format(printf,1,2)));
45 #else
46 extern void fatal_protocol_error( struct thread *thread, const char *err, ... );
47 extern void fatal_protocol_perror( struct thread *thread, const char *err, ... );
48 extern void fatal_error( const char *err, ... );
49 extern void fatal_perror( const char *err, ... );
50 #endif
51
52 extern const char *get_config_dir(void);
53 extern void *set_reply_data_size( size_t size );
54 extern int receive_fd( struct process *process );
55 extern int send_client_fd( struct process *process, int fd, obj_handle_t handle );
56 extern void read_request( struct thread *thread );
57 extern void write_reply( struct thread *thread );
58 extern unsigned int get_tick_count(void);
59 extern void open_master_socket(void);
60 extern void close_master_socket(void);
61 extern void lock_master_socket( int locked );
62 extern int wait_for_lock(void);
63 extern int kill_lock_owner( int sig );
64
65 extern void trace_request(void);
66 extern void trace_reply( enum request req, const union generic_reply *reply );
67
68 /* get the request vararg data */
69 inline static const void *get_req_data(void)
70 {
71     return current->req_data;
72 }
73
74 /* get the request vararg size */
75 inline static size_t get_req_data_size(void)
76 {
77     return current->req.request_header.request_size;
78 }
79
80 /* get the reply maximum vararg size */
81 inline static size_t get_reply_max_size(void)
82 {
83     return current->req.request_header.reply_size;
84 }
85
86 /* allocate and fill the reply data */
87 inline static void *set_reply_data( const void *data, size_t size )
88 {
89     void *ret = set_reply_data_size( size );
90     if (ret) memcpy( ret, data, size );
91     return ret;
92 }
93
94 /* set the reply data pointer directly (will be freed by request code) */
95 inline static void set_reply_data_ptr( void *data, size_t size )
96 {
97     assert( size <= get_reply_max_size() );
98     current->reply_size = size;
99     current->reply_data = data;
100 }
101
102
103 /* Everything below this line is generated automatically by tools/make_requests */
104 /* ### make_requests begin ### */
105
106 DECL_HANDLER(new_process);
107 DECL_HANDLER(get_new_process_info);
108 DECL_HANDLER(new_thread);
109 DECL_HANDLER(boot_done);
110 DECL_HANDLER(init_process);
111 DECL_HANDLER(get_startup_info);
112 DECL_HANDLER(init_process_done);
113 DECL_HANDLER(init_thread);
114 DECL_HANDLER(terminate_process);
115 DECL_HANDLER(terminate_thread);
116 DECL_HANDLER(get_process_info);
117 DECL_HANDLER(set_process_info);
118 DECL_HANDLER(get_thread_info);
119 DECL_HANDLER(set_thread_info);
120 DECL_HANDLER(suspend_thread);
121 DECL_HANDLER(resume_thread);
122 DECL_HANDLER(load_dll);
123 DECL_HANDLER(unload_dll);
124 DECL_HANDLER(queue_apc);
125 DECL_HANDLER(get_apc);
126 DECL_HANDLER(close_handle);
127 DECL_HANDLER(set_handle_info);
128 DECL_HANDLER(dup_handle);
129 DECL_HANDLER(open_process);
130 DECL_HANDLER(open_thread);
131 DECL_HANDLER(select);
132 DECL_HANDLER(create_event);
133 DECL_HANDLER(event_op);
134 DECL_HANDLER(open_event);
135 DECL_HANDLER(create_mutex);
136 DECL_HANDLER(release_mutex);
137 DECL_HANDLER(open_mutex);
138 DECL_HANDLER(create_semaphore);
139 DECL_HANDLER(release_semaphore);
140 DECL_HANDLER(open_semaphore);
141 DECL_HANDLER(create_file);
142 DECL_HANDLER(alloc_file_handle);
143 DECL_HANDLER(get_handle_fd);
144 DECL_HANDLER(set_file_pointer);
145 DECL_HANDLER(truncate_file);
146 DECL_HANDLER(set_file_time);
147 DECL_HANDLER(flush_file);
148 DECL_HANDLER(get_file_info);
149 DECL_HANDLER(lock_file);
150 DECL_HANDLER(unlock_file);
151 DECL_HANDLER(create_pipe);
152 DECL_HANDLER(create_socket);
153 DECL_HANDLER(accept_socket);
154 DECL_HANDLER(set_socket_event);
155 DECL_HANDLER(get_socket_event);
156 DECL_HANDLER(enable_socket_event);
157 DECL_HANDLER(set_socket_deferred);
158 DECL_HANDLER(alloc_console);
159 DECL_HANDLER(free_console);
160 DECL_HANDLER(get_console_renderer_events);
161 DECL_HANDLER(open_console);
162 DECL_HANDLER(get_console_mode);
163 DECL_HANDLER(set_console_mode);
164 DECL_HANDLER(set_console_input_info);
165 DECL_HANDLER(get_console_input_info);
166 DECL_HANDLER(append_console_input_history);
167 DECL_HANDLER(get_console_input_history);
168 DECL_HANDLER(create_console_output);
169 DECL_HANDLER(set_console_output_info);
170 DECL_HANDLER(get_console_output_info);
171 DECL_HANDLER(write_console_input);
172 DECL_HANDLER(read_console_input);
173 DECL_HANDLER(write_console_output);
174 DECL_HANDLER(fill_console_output);
175 DECL_HANDLER(read_console_output);
176 DECL_HANDLER(move_console_output);
177 DECL_HANDLER(send_console_signal);
178 DECL_HANDLER(create_change_notification);
179 DECL_HANDLER(create_mapping);
180 DECL_HANDLER(open_mapping);
181 DECL_HANDLER(get_mapping_info);
182 DECL_HANDLER(create_device);
183 DECL_HANDLER(create_snapshot);
184 DECL_HANDLER(next_process);
185 DECL_HANDLER(next_thread);
186 DECL_HANDLER(next_module);
187 DECL_HANDLER(wait_debug_event);
188 DECL_HANDLER(queue_exception_event);
189 DECL_HANDLER(get_exception_status);
190 DECL_HANDLER(output_debug_string);
191 DECL_HANDLER(continue_debug_event);
192 DECL_HANDLER(debug_process);
193 DECL_HANDLER(debug_break);
194 DECL_HANDLER(set_debugger_kill_on_exit);
195 DECL_HANDLER(read_process_memory);
196 DECL_HANDLER(write_process_memory);
197 DECL_HANDLER(create_key);
198 DECL_HANDLER(open_key);
199 DECL_HANDLER(delete_key);
200 DECL_HANDLER(enum_key);
201 DECL_HANDLER(set_key_value);
202 DECL_HANDLER(get_key_value);
203 DECL_HANDLER(enum_key_value);
204 DECL_HANDLER(delete_key_value);
205 DECL_HANDLER(load_registry);
206 DECL_HANDLER(save_registry);
207 DECL_HANDLER(save_registry_atexit);
208 DECL_HANDLER(set_registry_levels);
209 DECL_HANDLER(set_registry_notification);
210 DECL_HANDLER(create_timer);
211 DECL_HANDLER(open_timer);
212 DECL_HANDLER(set_timer);
213 DECL_HANDLER(cancel_timer);
214 DECL_HANDLER(get_thread_context);
215 DECL_HANDLER(set_thread_context);
216 DECL_HANDLER(get_selector_entry);
217 DECL_HANDLER(add_atom);
218 DECL_HANDLER(delete_atom);
219 DECL_HANDLER(find_atom);
220 DECL_HANDLER(get_atom_name);
221 DECL_HANDLER(init_atom_table);
222 DECL_HANDLER(get_msg_queue);
223 DECL_HANDLER(set_queue_mask);
224 DECL_HANDLER(get_queue_status);
225 DECL_HANDLER(wait_input_idle);
226 DECL_HANDLER(send_message);
227 DECL_HANDLER(get_message);
228 DECL_HANDLER(reply_message);
229 DECL_HANDLER(get_message_reply);
230 DECL_HANDLER(set_win_timer);
231 DECL_HANDLER(kill_win_timer);
232 DECL_HANDLER(create_serial);
233 DECL_HANDLER(get_serial_info);
234 DECL_HANDLER(set_serial_info);
235 DECL_HANDLER(register_async);
236 DECL_HANDLER(create_named_pipe);
237 DECL_HANDLER(open_named_pipe);
238 DECL_HANDLER(connect_named_pipe);
239 DECL_HANDLER(wait_named_pipe);
240 DECL_HANDLER(disconnect_named_pipe);
241 DECL_HANDLER(get_named_pipe_info);
242 DECL_HANDLER(create_smb);
243 DECL_HANDLER(get_smb_info);
244 DECL_HANDLER(create_window);
245 DECL_HANDLER(link_window);
246 DECL_HANDLER(destroy_window);
247 DECL_HANDLER(set_window_owner);
248 DECL_HANDLER(get_window_info);
249 DECL_HANDLER(set_window_info);
250 DECL_HANDLER(get_window_parents);
251 DECL_HANDLER(get_window_children);
252 DECL_HANDLER(get_window_tree);
253 DECL_HANDLER(set_window_rectangles);
254 DECL_HANDLER(get_window_rectangles);
255 DECL_HANDLER(get_window_text);
256 DECL_HANDLER(set_window_text);
257 DECL_HANDLER(inc_window_paint_count);
258 DECL_HANDLER(get_windows_offset);
259 DECL_HANDLER(set_window_property);
260 DECL_HANDLER(remove_window_property);
261 DECL_HANDLER(get_window_property);
262 DECL_HANDLER(get_window_properties);
263 DECL_HANDLER(attach_thread_input);
264 DECL_HANDLER(get_thread_input);
265 DECL_HANDLER(set_foreground_window);
266 DECL_HANDLER(set_focus_window);
267 DECL_HANDLER(set_active_window);
268 DECL_HANDLER(set_capture_window);
269 DECL_HANDLER(set_caret_window);
270 DECL_HANDLER(set_caret_info);
271 DECL_HANDLER(set_hook);
272 DECL_HANDLER(remove_hook);
273 DECL_HANDLER(start_hook_chain);
274 DECL_HANDLER(finish_hook_chain);
275 DECL_HANDLER(get_next_hook);
276
277 #ifdef WANT_REQUEST_HANDLERS
278
279 typedef void (*req_handler)( const void *req, void *reply );
280 static const req_handler req_handlers[REQ_NB_REQUESTS] =
281 {
282     (req_handler)req_new_process,
283     (req_handler)req_get_new_process_info,
284     (req_handler)req_new_thread,
285     (req_handler)req_boot_done,
286     (req_handler)req_init_process,
287     (req_handler)req_get_startup_info,
288     (req_handler)req_init_process_done,
289     (req_handler)req_init_thread,
290     (req_handler)req_terminate_process,
291     (req_handler)req_terminate_thread,
292     (req_handler)req_get_process_info,
293     (req_handler)req_set_process_info,
294     (req_handler)req_get_thread_info,
295     (req_handler)req_set_thread_info,
296     (req_handler)req_suspend_thread,
297     (req_handler)req_resume_thread,
298     (req_handler)req_load_dll,
299     (req_handler)req_unload_dll,
300     (req_handler)req_queue_apc,
301     (req_handler)req_get_apc,
302     (req_handler)req_close_handle,
303     (req_handler)req_set_handle_info,
304     (req_handler)req_dup_handle,
305     (req_handler)req_open_process,
306     (req_handler)req_open_thread,
307     (req_handler)req_select,
308     (req_handler)req_create_event,
309     (req_handler)req_event_op,
310     (req_handler)req_open_event,
311     (req_handler)req_create_mutex,
312     (req_handler)req_release_mutex,
313     (req_handler)req_open_mutex,
314     (req_handler)req_create_semaphore,
315     (req_handler)req_release_semaphore,
316     (req_handler)req_open_semaphore,
317     (req_handler)req_create_file,
318     (req_handler)req_alloc_file_handle,
319     (req_handler)req_get_handle_fd,
320     (req_handler)req_set_file_pointer,
321     (req_handler)req_truncate_file,
322     (req_handler)req_set_file_time,
323     (req_handler)req_flush_file,
324     (req_handler)req_get_file_info,
325     (req_handler)req_lock_file,
326     (req_handler)req_unlock_file,
327     (req_handler)req_create_pipe,
328     (req_handler)req_create_socket,
329     (req_handler)req_accept_socket,
330     (req_handler)req_set_socket_event,
331     (req_handler)req_get_socket_event,
332     (req_handler)req_enable_socket_event,
333     (req_handler)req_set_socket_deferred,
334     (req_handler)req_alloc_console,
335     (req_handler)req_free_console,
336     (req_handler)req_get_console_renderer_events,
337     (req_handler)req_open_console,
338     (req_handler)req_get_console_mode,
339     (req_handler)req_set_console_mode,
340     (req_handler)req_set_console_input_info,
341     (req_handler)req_get_console_input_info,
342     (req_handler)req_append_console_input_history,
343     (req_handler)req_get_console_input_history,
344     (req_handler)req_create_console_output,
345     (req_handler)req_set_console_output_info,
346     (req_handler)req_get_console_output_info,
347     (req_handler)req_write_console_input,
348     (req_handler)req_read_console_input,
349     (req_handler)req_write_console_output,
350     (req_handler)req_fill_console_output,
351     (req_handler)req_read_console_output,
352     (req_handler)req_move_console_output,
353     (req_handler)req_send_console_signal,
354     (req_handler)req_create_change_notification,
355     (req_handler)req_create_mapping,
356     (req_handler)req_open_mapping,
357     (req_handler)req_get_mapping_info,
358     (req_handler)req_create_device,
359     (req_handler)req_create_snapshot,
360     (req_handler)req_next_process,
361     (req_handler)req_next_thread,
362     (req_handler)req_next_module,
363     (req_handler)req_wait_debug_event,
364     (req_handler)req_queue_exception_event,
365     (req_handler)req_get_exception_status,
366     (req_handler)req_output_debug_string,
367     (req_handler)req_continue_debug_event,
368     (req_handler)req_debug_process,
369     (req_handler)req_debug_break,
370     (req_handler)req_set_debugger_kill_on_exit,
371     (req_handler)req_read_process_memory,
372     (req_handler)req_write_process_memory,
373     (req_handler)req_create_key,
374     (req_handler)req_open_key,
375     (req_handler)req_delete_key,
376     (req_handler)req_enum_key,
377     (req_handler)req_set_key_value,
378     (req_handler)req_get_key_value,
379     (req_handler)req_enum_key_value,
380     (req_handler)req_delete_key_value,
381     (req_handler)req_load_registry,
382     (req_handler)req_save_registry,
383     (req_handler)req_save_registry_atexit,
384     (req_handler)req_set_registry_levels,
385     (req_handler)req_set_registry_notification,
386     (req_handler)req_create_timer,
387     (req_handler)req_open_timer,
388     (req_handler)req_set_timer,
389     (req_handler)req_cancel_timer,
390     (req_handler)req_get_thread_context,
391     (req_handler)req_set_thread_context,
392     (req_handler)req_get_selector_entry,
393     (req_handler)req_add_atom,
394     (req_handler)req_delete_atom,
395     (req_handler)req_find_atom,
396     (req_handler)req_get_atom_name,
397     (req_handler)req_init_atom_table,
398     (req_handler)req_get_msg_queue,
399     (req_handler)req_set_queue_mask,
400     (req_handler)req_get_queue_status,
401     (req_handler)req_wait_input_idle,
402     (req_handler)req_send_message,
403     (req_handler)req_get_message,
404     (req_handler)req_reply_message,
405     (req_handler)req_get_message_reply,
406     (req_handler)req_set_win_timer,
407     (req_handler)req_kill_win_timer,
408     (req_handler)req_create_serial,
409     (req_handler)req_get_serial_info,
410     (req_handler)req_set_serial_info,
411     (req_handler)req_register_async,
412     (req_handler)req_create_named_pipe,
413     (req_handler)req_open_named_pipe,
414     (req_handler)req_connect_named_pipe,
415     (req_handler)req_wait_named_pipe,
416     (req_handler)req_disconnect_named_pipe,
417     (req_handler)req_get_named_pipe_info,
418     (req_handler)req_create_smb,
419     (req_handler)req_get_smb_info,
420     (req_handler)req_create_window,
421     (req_handler)req_link_window,
422     (req_handler)req_destroy_window,
423     (req_handler)req_set_window_owner,
424     (req_handler)req_get_window_info,
425     (req_handler)req_set_window_info,
426     (req_handler)req_get_window_parents,
427     (req_handler)req_get_window_children,
428     (req_handler)req_get_window_tree,
429     (req_handler)req_set_window_rectangles,
430     (req_handler)req_get_window_rectangles,
431     (req_handler)req_get_window_text,
432     (req_handler)req_set_window_text,
433     (req_handler)req_inc_window_paint_count,
434     (req_handler)req_get_windows_offset,
435     (req_handler)req_set_window_property,
436     (req_handler)req_remove_window_property,
437     (req_handler)req_get_window_property,
438     (req_handler)req_get_window_properties,
439     (req_handler)req_attach_thread_input,
440     (req_handler)req_get_thread_input,
441     (req_handler)req_set_foreground_window,
442     (req_handler)req_set_focus_window,
443     (req_handler)req_set_active_window,
444     (req_handler)req_set_capture_window,
445     (req_handler)req_set_caret_window,
446     (req_handler)req_set_caret_info,
447     (req_handler)req_set_hook,
448     (req_handler)req_remove_hook,
449     (req_handler)req_start_hook_chain,
450     (req_handler)req_finish_hook_chain,
451     (req_handler)req_get_next_hook,
452 };
453 #endif  /* WANT_REQUEST_HANDLERS */
454
455 /* ### make_requests end ### */
456 /* Everything above this line is generated automatically by tools/make_requests */
457
458 #endif  /* __WINE_SERVER_REQUEST_H */