Release 980809
[wine] / include / server / object.h
1 /*
2  * Wine server objects
3  *
4  * Copyright (C) 1998 Alexandre Julliard
5  */
6
7 #ifndef __WINE_SERVER_OBJECT_H
8 #define __WINE_SERVER_OBJECT_H
9
10 #ifndef __WINE_SERVER__
11 #error This file can only be used in the Wine server
12 #endif
13
14 #include <sys/time.h>
15 #include "server/request.h"
16
17 /* kernel objects */
18
19 struct object;
20 struct object_name;
21
22 struct object_ops
23 {
24     void (*dump)(struct object *,int);   /* dump the object (for debugging) */
25     void (*destroy)(struct object *);    /* destroy on refcount == 0 */
26 };
27
28 struct object
29 {
30     unsigned int              refcount;
31     const struct object_ops  *ops;
32     struct object_name       *name;
33 };
34
35 extern void init_object( struct object *obj, const struct object_ops *ops,
36                          const char *name );
37 /* grab/release_object can take any pointer, but you better make sure */
38 /* that the thing pointed to starts with a struct object... */
39 extern struct object *grab_object( void *obj );
40 extern void release_object( void *obj );
41
42 /* request handlers */
43
44 struct iovec;
45 struct thread;
46
47 extern void call_req_handler( struct thread *thread, enum request req,
48                               void *data, int len, int fd );
49 extern void call_timeout_handler( struct thread *thread );
50 extern void call_kill_handler( struct thread *thread, int exit_code );
51
52 extern void trace_request( enum request req, void *data, int len, int fd );
53 extern void trace_timeout(void);
54 extern void trace_kill( int exit_code );
55 extern void trace_reply( struct thread *thread, int type, int pass_fd,
56                          struct iovec *vec, int veclen );
57
58 /* socket functions */
59
60 extern int add_client( int client_fd, struct thread *self );
61 extern void remove_client( int client_fd, int exit_code );
62 extern int get_initial_client_fd(void);
63 extern void set_timeout( int client_fd, struct timeval *when );
64 extern int send_reply_v( int client_fd, int type, int pass_fd,
65                          struct iovec *vec, int veclen );
66
67 /* process functions */
68
69 struct process;
70
71 extern struct process *create_process(void);
72 extern struct process *get_process_from_id( void *id );
73 extern struct process *get_process_from_handle( int handle, unsigned int access );
74 extern void add_process_thread( struct process *process,
75                                 struct thread *thread );
76 extern void remove_process_thread( struct process *process,
77                                    struct thread *thread );
78 extern void kill_process( struct process *process, int exit_code );
79 extern void get_process_info( struct process *process,
80                               struct get_process_info_reply *reply );
81
82 /* handle functions */
83
84 /* alloc_handle takes a void *obj for convenience, but you better make sure */
85 /* that the thing pointed to starts with a struct object... */
86 extern int alloc_handle( struct process *process, void *obj,
87                          unsigned int access, int inherit );
88 extern int close_handle( struct process *process, int handle );
89 extern int set_handle_info( struct process *process, int handle,
90                             int mask, int flags );
91 extern struct object *get_handle_obj( struct process *process, int handle,
92                                       unsigned int access, const struct object_ops *ops );
93 extern int duplicate_handle( struct process *src, int src_handle, struct process *dst,
94                              int dst_handle, unsigned int access, int inherit, int options );
95
96 extern int debug_level;
97
98 #endif  /* __WINE_SERVER_OBJECT_H */