Added tracking support and fixed loading of resource strings.
[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.h"
16 #include "server/request.h"
17
18 /* kernel objects */
19
20 struct object;
21 struct object_name;
22 struct thread;
23
24 struct object_ops
25 {
26     void (*dump)(struct object *,int);                  /* dump the object (for debugging) */
27     int  (*signaled)(struct object *,struct thread *);  /* is object signaled? */
28     int  (*satisfied)(struct object *,struct thread *); /* wait satisfied; return 1 if abandoned */
29     void (*destroy)(struct object *);                   /* destroy on refcount == 0 */
30 };
31
32 struct object
33 {
34     unsigned int              refcount;
35     const struct object_ops  *ops;
36     struct wait_queue_entry  *head;
37     struct wait_queue_entry  *tail;
38     struct object_name       *name;
39 };
40
41 extern void *mem_alloc( size_t size );  /* malloc wrapper */
42 extern struct object *create_named_object( const char *name, const struct object_ops *ops,
43                                            size_t size );
44 extern int init_object( struct object *obj, const struct object_ops *ops,
45                         const char *name );
46 /* grab/release_object can take any pointer, but you better make sure */
47 /* that the thing pointed to starts with a struct object... */
48 extern struct object *grab_object( void *obj );
49 extern void release_object( void *obj );
50 extern struct object *find_object( const char *name );
51
52 /* request handlers */
53
54 struct iovec;
55 struct thread;
56
57 extern void call_req_handler( struct thread *thread, enum request req,
58                               void *data, int len, int fd );
59 extern void call_timeout_handler( struct thread *thread );
60 extern void call_kill_handler( struct thread *thread, int exit_code );
61
62 extern void trace_request( enum request req, void *data, int len, int fd );
63 extern void trace_timeout(void);
64 extern void trace_kill( int exit_code );
65 extern void trace_reply( struct thread *thread, int type, int pass_fd,
66                          struct iovec *vec, int veclen );
67
68 /* socket functions */
69
70 extern int add_client( int client_fd, struct thread *self );
71 extern void remove_client( int client_fd, int exit_code );
72 extern int get_initial_client_fd(void);
73 extern void set_timeout( int client_fd, struct timeval *when );
74 extern int send_reply_v( int client_fd, int type, int pass_fd,
75                          struct iovec *vec, int veclen );
76
77 /* process functions */
78
79 struct process;
80
81 extern struct process *create_process(void);
82 extern struct process *get_process_from_id( void *id );
83 extern struct process *get_process_from_handle( int handle, unsigned int access );
84 extern void add_process_thread( struct process *process,
85                                 struct thread *thread );
86 extern void remove_process_thread( struct process *process,
87                                    struct thread *thread );
88 extern void kill_process( struct process *process, int exit_code );
89 extern void get_process_info( struct process *process,
90                               struct get_process_info_reply *reply );
91
92 /* handle functions */
93
94 /* alloc_handle takes a void *obj for convenience, but you better make sure */
95 /* that the thing pointed to starts with a struct object... */
96 extern int alloc_handle( struct process *process, void *obj,
97                          unsigned int access, int inherit );
98 extern int close_handle( struct process *process, int handle );
99 extern int set_handle_info( struct process *process, int handle,
100                             int mask, int flags );
101 extern struct object *get_handle_obj( struct process *process, int handle,
102                                       unsigned int access, const struct object_ops *ops );
103 extern int duplicate_handle( struct process *src, int src_handle, struct process *dst,
104                              int dst_handle, unsigned int access, int inherit, int options );
105 extern int open_object( const char *name, const struct object_ops *ops,
106                         unsigned int access, int inherit );
107
108 /* event functions */
109
110 extern struct object *create_event( const char *name, int manual_reset, int initial_state );
111 extern int open_event( unsigned int access, int inherit, const char *name );
112 extern int pulse_event( int handle );
113 extern int set_event( int handle );
114 extern int reset_event( int handle );
115
116
117 /* mutex functions */
118
119 extern struct object *create_mutex( const char *name, int owned );
120 extern int open_mutex( unsigned int access, int inherit, const char *name );
121 extern int release_mutex( int handle );
122 extern void abandon_mutexes( struct thread *thread );
123
124
125 /* semaphore functions */
126
127 extern struct object *create_semaphore( const char *name, unsigned int initial, unsigned int max );
128 extern int open_semaphore( unsigned int access, int inherit, const char *name );
129 extern int release_semaphore( int handle, unsigned int count, unsigned int *prev_count );
130
131 extern int debug_level;
132
133 #endif  /* __WINE_SERVER_OBJECT_H */