Use service thread for "true" multimedia timers.
[wine/wine-kai.git] / include / server.h
blobeca3e934ee02f390a15b7b12a938bd6b329b7123
1 /*
2 * Wine server definitions
4 * Copyright (C) 1998 Alexandre Julliard
5 */
7 #ifndef __WINE_SERVER_H
8 #define __WINE_SERVER_H
10 #include <stdlib.h>
11 #include <time.h>
13 /* message header as sent on the wire */
14 struct header
16 unsigned int len; /* total msg length (including this header) */
17 unsigned int type; /* msg type */
18 unsigned int seq; /* sequence number */
21 /* max msg length (not including the header) */
22 #define MAX_MSG_LENGTH (16384 - sizeof(struct header))
24 /* data structure used to pass an fd with sendmsg/recvmsg */
25 struct cmsg_fd
27 int len; /* sizeof structure */
28 int level; /* SOL_SOCKET */
29 int type; /* SCM_RIGHTS */
30 int fd; /* fd to pass */
33 /* request handler definition */
34 #define DECL_HANDLER(name) \
35 void req_##name( struct name##_request *req, void *data, int len, int fd )
37 /* Request structures */
39 /* following are the definitions of all the client<->server */
40 /* communication format; requests are from client to server, */
41 /* replies are from server to client. All requests must have */
42 /* a corresponding structure; the replies can be empty in */
43 /* which case it isn't necessary to define a structure. */
46 /* Create a new process from the context of the parent */
47 struct new_process_request
49 int inherit; /* inherit flag */
50 int inherit_all; /* inherit all handles from parent */
51 int start_flags; /* flags from startup info */
52 int hstdin; /* handle for stdin */
53 int hstdout; /* handle for stdout */
54 int hstderr; /* handle for stderr */
55 void* env_ptr; /* pointer to environment (FIXME: hack) */
56 char cmd_line[0]; /* command line */
58 struct new_process_reply
60 void* pid; /* process id */
61 int handle; /* process handle (in the current process) */
65 /* Create a new thread from the context of the parent */
66 struct new_thread_request
68 void* pid; /* process id for the new thread */
69 int suspend; /* new thread should be suspended on creation */
70 int inherit; /* inherit flag */
72 struct new_thread_reply
74 void* tid; /* thread id */
75 int handle; /* thread handle (in the current process) */
79 /* Set the server debug level */
80 struct set_debug_request
82 int level; /* New debug level */
86 /* Initialize a process; called from the new process context */
87 struct init_process_request
89 int dummy;
91 struct init_process_reply
93 int start_flags; /* flags from startup info */
94 int hstdin; /* handle for stdin */
95 int hstdout; /* handle for stdout */
96 int hstderr; /* handle for stderr */
97 void* env_ptr; /* pointer to environment (FIXME: hack) */
101 /* Initialize a thread; called from the child after fork()/clone() */
102 struct init_thread_request
104 int unix_pid; /* Unix pid of new thread */
105 void* teb; /* TEB of new thread (in thread address space) */
107 struct init_thread_reply
109 void* pid; /* process id of the new thread's process */
110 void* tid; /* thread id of the new thread */
114 /* Terminate a process */
115 struct terminate_process_request
117 int handle; /* process handle to terminate */
118 int exit_code; /* process exit code */
122 /* Terminate a thread */
123 struct terminate_thread_request
125 int handle; /* thread handle to terminate */
126 int exit_code; /* thread exit code */
130 /* Retrieve information about a process */
131 struct get_process_info_request
133 int handle; /* process handle */
135 struct get_process_info_reply
137 void* pid; /* server process id */
138 int exit_code; /* process exit code */
139 int priority; /* priority class */
140 int process_affinity; /* process affinity mask */
141 int system_affinity; /* system affinity mask */
145 /* Set a process informations */
146 struct set_process_info_request
148 int handle; /* process handle */
149 int mask; /* setting mask (see below) */
150 int priority; /* priority class */
151 int affinity; /* affinity mask */
153 #define SET_PROCESS_INFO_PRIORITY 0x01
154 #define SET_PROCESS_INFO_AFFINITY 0x02
157 /* Retrieve information about a thread */
158 struct get_thread_info_request
160 int handle; /* thread handle */
162 struct get_thread_info_reply
164 void* tid; /* server thread id */
165 int exit_code; /* thread exit code */
166 int priority; /* thread priority level */
170 /* Set a thread informations */
171 struct set_thread_info_request
173 int handle; /* thread handle */
174 int mask; /* setting mask (see below) */
175 int priority; /* priority class */
176 int affinity; /* affinity mask */
178 #define SET_THREAD_INFO_PRIORITY 0x01
179 #define SET_THREAD_INFO_AFFINITY 0x02
182 /* Suspend a thread */
183 struct suspend_thread_request
185 int handle; /* thread handle */
187 struct suspend_thread_reply
189 int count; /* new suspend count */
193 /* Resume a thread */
194 struct resume_thread_request
196 int handle; /* thread handle */
198 struct resume_thread_reply
200 int count; /* new suspend count */
204 /* Debugger support: freeze / unfreeze */
205 struct debugger_request
207 int op; /* operation type */
210 enum debugger_op { DEBUGGER_FREEZE_ALL, DEBUGGER_UNFREEZE_ALL };
213 /* Queue an APC for a thread */
214 struct queue_apc_request
216 int handle; /* thread handle */
217 void* func; /* function to call */
218 void* param; /* param for function to call */
222 /* Close a handle for the current process */
223 struct close_handle_request
225 int handle; /* handle to close */
229 /* Get information about a handle */
230 struct get_handle_info_request
232 int handle; /* handle we are interested in */
234 struct get_handle_info_reply
236 int flags; /* handle flags */
240 /* Set a handle information */
241 struct set_handle_info_request
243 int handle; /* handle we are interested in */
244 int flags; /* new handle flags */
245 int mask; /* mask for flags to set */
249 /* Duplicate a handle */
250 struct dup_handle_request
252 int src_process; /* src process handle */
253 int src_handle; /* src handle to duplicate */
254 int dst_process; /* dst process handle */
255 unsigned int access; /* wanted access rights */
256 int inherit; /* inherit flag */
257 int options; /* duplicate options (see below) */
259 #define DUP_HANDLE_CLOSE_SOURCE DUPLICATE_CLOSE_SOURCE
260 #define DUP_HANDLE_SAME_ACCESS DUPLICATE_SAME_ACCESS
261 #define DUP_HANDLE_MAKE_GLOBAL 0x80000000 /* Not a Windows flag */
262 struct dup_handle_reply
264 int handle; /* duplicated handle in dst process */
268 /* Open a handle to a process */
269 struct open_process_request
271 void* pid; /* process id to open */
272 unsigned int access; /* wanted access rights */
273 int inherit; /* inherit flag */
275 struct open_process_reply
277 int handle; /* handle to the process */
281 /* Wait for handles */
282 struct select_request
284 int count; /* handles count */
285 int flags; /* wait flags (see below) */
286 int timeout; /* timeout in ms */
287 /* int handles[] */
289 struct select_reply
291 int signaled; /* signaled handle */
292 /* void* apcs[]; */ /* async procedures to call */
294 #define SELECT_ALL 1
295 #define SELECT_ALERTABLE 2
296 #define SELECT_TIMEOUT 4
299 /* Create an event */
300 struct create_event_request
302 int manual_reset; /* manual reset event */
303 int initial_state; /* initial state of the event */
304 int inherit; /* inherit flag */
305 char name[0]; /* event name */
307 struct create_event_reply
309 int handle; /* handle to the event */
312 /* Event operation */
313 struct event_op_request
315 int handle; /* handle to event */
316 int op; /* event operation (see below) */
318 enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
321 /* Open an event */
322 struct open_event_request
324 unsigned int access; /* wanted access rights */
325 int inherit; /* inherit flag */
326 char name[0]; /* object name */
328 struct open_event_reply
330 int handle; /* handle to the event */
334 /* Create a mutex */
335 struct create_mutex_request
337 int owned; /* initially owned? */
338 int inherit; /* inherit flag */
339 char name[0]; /* mutex name */
341 struct create_mutex_reply
343 int handle; /* handle to the mutex */
347 /* Release a mutex */
348 struct release_mutex_request
350 int handle; /* handle to the mutex */
354 /* Open a mutex */
355 struct open_mutex_request
357 unsigned int access; /* wanted access rights */
358 int inherit; /* inherit flag */
359 char name[0]; /* object name */
361 struct open_mutex_reply
363 int handle; /* handle to the mutex */
367 /* Create a semaphore */
368 struct create_semaphore_request
370 unsigned int initial; /* initial count */
371 unsigned int max; /* maximum count */
372 int inherit; /* inherit flag */
373 char name[0]; /* semaphore name */
375 struct create_semaphore_reply
377 int handle; /* handle to the semaphore */
381 /* Release a semaphore */
382 struct release_semaphore_request
384 int handle; /* handle to the semaphore */
385 unsigned int count; /* count to add to semaphore */
387 struct release_semaphore_reply
389 unsigned int prev_count; /* previous semaphore count */
393 /* Open a semaphore */
394 struct open_semaphore_request
396 unsigned int access; /* wanted access rights */
397 int inherit; /* inherit flag */
398 char name[0]; /* object name */
400 struct open_semaphore_reply
402 int handle; /* handle to the semaphore */
406 /* Create a file */
407 struct create_file_request
409 unsigned int access; /* wanted access rights */
410 int inherit; /* inherit flag */
411 unsigned int sharing; /* sharing flags */
412 int create; /* file create action */
413 unsigned int attrs; /* file attributes for creation */
414 char name[0]; /* file name */
416 struct create_file_reply
418 int handle; /* handle to the file */
422 /* Get a Unix fd to read from a file */
423 struct get_read_fd_request
425 int handle; /* handle to the file */
429 /* Get a Unix fd to write to a file */
430 struct get_write_fd_request
432 int handle; /* handle to the file */
436 /* Set a file current position */
437 struct set_file_pointer_request
439 int handle; /* handle to the file */
440 int low; /* position low word */
441 int high; /* position high word */
442 int whence; /* whence to seek */
444 struct set_file_pointer_reply
446 int low; /* new position low word */
447 int high; /* new position high word */
451 /* Truncate (or extend) a file */
452 struct truncate_file_request
454 int handle; /* handle to the file */
458 /* Set a file access and modification times */
459 struct set_file_time_request
461 int handle; /* handle to the file */
462 time_t access_time; /* last access time */
463 time_t write_time; /* last write time */
467 /* Flush a file buffers */
468 struct flush_file_request
470 int handle; /* handle to the file */
474 /* Get information about a file */
475 struct get_file_info_request
477 int handle; /* handle to the file */
479 struct get_file_info_reply
481 int type; /* file type */
482 int attr; /* file attributes */
483 time_t access_time; /* last access time */
484 time_t write_time; /* last write time */
485 int size_high; /* file size */
486 int size_low; /* file size */
487 int links; /* number of links */
488 int index_high; /* unique index */
489 int index_low; /* unique index */
490 unsigned int serial; /* volume serial number */
494 /* Lock a region of a file */
495 struct lock_file_request
497 int handle; /* handle to the file */
498 unsigned int offset_low; /* offset of start of lock */
499 unsigned int offset_high; /* offset of start of lock */
500 unsigned int count_low; /* count of bytes to lock */
501 unsigned int count_high; /* count of bytes to lock */
505 /* Unlock a region of a file */
506 struct unlock_file_request
508 int handle; /* handle to the file */
509 unsigned int offset_low; /* offset of start of unlock */
510 unsigned int offset_high; /* offset of start of unlock */
511 unsigned int count_low; /* count of bytes to unlock */
512 unsigned int count_high; /* count of bytes to unlock */
516 /* Create an anonymous pipe */
517 struct create_pipe_request
519 int inherit; /* inherit flag */
521 struct create_pipe_reply
523 int handle_read; /* handle to the read-side of the pipe */
524 int handle_write; /* handle to the write-side of the pipe */
528 /* Allocate a console for the current process */
529 struct alloc_console_request
531 int dummy;
535 /* Free the console of the current process */
536 struct free_console_request
538 int dummy;
542 /* Open a handle to the process console */
543 struct open_console_request
545 int output; /* input or output? */
546 unsigned int access; /* wanted access rights */
547 int inherit; /* inherit flag */
549 struct open_console_reply
551 int handle; /* handle to the console */
555 /* Set a console file descriptor */
556 struct set_console_fd_request
558 int handle; /* handle to the console */
559 int pid; /* pid of xterm (hack) */
563 /* Get a console mode (input or output) */
564 struct get_console_mode_request
566 int handle; /* handle to the console */
568 struct get_console_mode_reply
570 int mode; /* console mode */
574 /* Set a console mode (input or output) */
575 struct set_console_mode_request
577 int handle; /* handle to the console */
578 int mode; /* console mode */
582 /* Set info about a console (output only) */
583 struct set_console_info_request
585 int handle; /* handle to the console */
586 int mask; /* setting mask (see below) */
587 int cursor_size; /* size of cursor (percentage filled) */
588 int cursor_visible;/* cursor visibility flag */
589 char title[0]; /* console title */
591 #define SET_CONSOLE_INFO_CURSOR 0x01
592 #define SET_CONSOLE_INFO_TITLE 0x02
594 /* Get info about a console (output only) */
595 struct get_console_info_request
597 int handle; /* handle to the console */
599 struct get_console_info_reply
601 int cursor_size; /* size of cursor (percentage filled) */
602 int cursor_visible;/* cursor visibility flag */
603 int pid; /* pid of xterm (hack) */
604 /* char title[0]; */ /* console title */
608 /* Add input records to a console input queue */
609 struct write_console_input_request
611 int handle; /* handle to the console input */
612 int count; /* number of input records */
613 /* INPUT_RECORD records[0]; */ /* input records */
615 struct write_console_input_reply
617 int written; /* number of records written */
620 /* Fetch input records from a console input queue */
621 struct read_console_input_request
623 int handle; /* handle to the console input */
624 int count; /* max number of records to retrieve */
625 int flush; /* flush the retrieved records from the queue? */
627 struct read_console_input_reply
629 int dummy;
630 /* INPUT_RECORD records[0]; */ /* input records */
634 /* Create a change notification */
635 struct create_change_notification_request
637 int subtree; /* watch all the subtree */
638 int filter; /* notification filter */
640 struct create_change_notification_reply
642 int handle; /* handle to the change notification */
646 /* Create a file mapping */
647 struct create_mapping_request
649 int size_high; /* mapping size */
650 int size_low; /* mapping size */
651 int protect; /* protection flags (see below) */
652 int inherit; /* inherit flag */
653 int handle; /* file handle */
654 char name[0]; /* object name */
656 struct create_mapping_reply
658 int handle; /* handle to the mapping */
660 /* protection flags */
661 #define VPROT_READ 0x01
662 #define VPROT_WRITE 0x02
663 #define VPROT_EXEC 0x04
664 #define VPROT_WRITECOPY 0x08
665 #define VPROT_GUARD 0x10
666 #define VPROT_NOCACHE 0x20
667 #define VPROT_COMMITTED 0x40
670 /* Open a mapping */
671 struct open_mapping_request
673 unsigned int access; /* wanted access rights */
674 int inherit; /* inherit flag */
675 char name[0]; /* object name */
677 struct open_mapping_reply
679 int handle; /* handle to the mapping */
683 /* Get information about a file mapping */
684 struct get_mapping_info_request
686 int handle; /* handle to the mapping */
688 struct get_mapping_info_reply
690 int size_high; /* mapping size */
691 int size_low; /* mapping size */
692 int protect; /* protection flags */
696 /* Create a device */
697 struct create_device_request
699 unsigned int access; /* wanted access rights */
700 int inherit; /* inherit flag */
701 int id; /* client private id */
703 struct create_device_reply
705 int handle; /* handle to the device */
709 /* Create a snapshot */
710 struct create_snapshot_request
712 int inherit; /* inherit flag */
713 int flags; /* snapshot flags (TH32CS_*) */
715 struct create_snapshot_reply
717 int handle; /* handle to the snapshot */
721 /* Get the next process from a snapshot */
722 struct next_process_request
724 int handle; /* handle to the snapshot */
725 int reset; /* reset snapshot position? */
727 struct next_process_reply
729 void* pid; /* process id */
730 int threads; /* number of threads */
731 int priority; /* process priority */
735 /* requests definitions */
736 #include "server/request.h"
738 /* client-side functions */
740 #ifndef __WINE_SERVER__
742 /* client communication functions */
743 extern void CLIENT_SendRequest( enum request req, int pass_fd,
744 int n, ... /* arg_1, len_1, etc. */ );
745 extern unsigned int CLIENT_WaitReply( int *len, int *passed_fd,
746 int n, ... /* arg_1, len_1, etc. */ );
747 extern unsigned int CLIENT_WaitSimpleReply( void *reply, int len, int *passed_fd );
748 extern int CLIENT_InitServer(void);
750 struct _THDB;
751 extern int CLIENT_SetDebug( int level );
752 extern int CLIENT_DebuggerRequest( int op );
753 extern int CLIENT_InitThread(void);
754 #endif /* __WINE_SERVER__ */
756 #endif /* __WINE_SERVER_H */