xref: /NextBSD/usr.sbin/notifyd/notifyd.h (revision 33da5adc555b3bc29986eeadca03829e4ad06b1e)
1 /*
2  * Copyright (c) 2003-2010 Apple Inc. All rights reserved.
3  *
4  * @APPLE_LICENSE_HEADER_START@
5  *
6  * This file contains Original Code and/or Modifications of Original Code
7  * as defined in and that are subject to the Apple Public Source License
8  * Version 2.0 (the 'License'). You may not use this file except in
9  * compliance with the License. Please obtain a copy of the License at
10  * http://www.opensource.apple.com/apsl/ and read it before using this
11  * file.
12  *
13  * The Original Code and all software distributed under the License are
14  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18  * Please see the License for the specific language governing rights and
19  * limitations under the License.
20  *
21  * @APPLE_LICENSE_HEADER_END@
22  */
23 
24 #ifndef _NOTIFY_DAEMON_H_
25 #define _NOTIFY_DAEMON_H_
26 
27 #include <libnotify.h>
28 #include <mach/mach.h>
29 #include <launch.h>
30 #include <dispatch/dispatch.h>
31 
32 #define NOTIFY_IPC_VERSION 2
33 
34 extern struct global_s global;
35 extern struct call_statistics_s call_statistics;
36 
37 struct global_s
38 {
39 	mach_port_t server_port;
40 	launch_data_t launch_dict;
41 	notify_state_t *notify_state;
42 	dispatch_queue_t work_q;
43 	dispatch_source_t mach_src;
44 	dispatch_source_t sig_usr1_src;
45 	dispatch_source_t sig_usr2_src;
46 	dispatch_source_t sig_winch_src;
47 	uint32_t request_size;
48 	uint32_t reply_size;
49 	uint32_t nslots;
50 	uint32_t slot_id;
51 	uint32_t *shared_memory_base;
52 	uint32_t *shared_memory_refcount;
53 	uint32_t *last_shm_base;
54 	uint32_t log_cutoff;
55 	uint32_t log_default;
56 	char *log_path;
57 } global;
58 
59 struct call_statistics_s
60 {
61 	uint64_t post;
62 	uint64_t post_no_op;
63 	uint64_t post_by_id;
64 	uint64_t post_by_name;
65 	uint64_t post_by_name_and_fetch_id;
66 	uint64_t reg;
67 	uint64_t reg_plain;
68 	uint64_t reg_check;
69 	uint64_t reg_signal;
70 	uint64_t reg_file;
71 	uint64_t reg_port;
72 	uint64_t cancel;
73 	uint64_t suspend;
74 	uint64_t resume;
75 	uint64_t suspend_pid;
76 	uint64_t resume_pid;
77 	uint64_t check;
78 	uint64_t get_state;
79 	uint64_t get_state_by_client;
80 	uint64_t get_state_by_id;
81 	uint64_t get_state_by_client_and_fetch_id;
82 	uint64_t set_state;
83 	uint64_t set_state_by_client;
84 	uint64_t set_state_by_id;
85 	uint64_t set_state_by_client_and_fetch_id;
86 	uint64_t get_owner;
87 	uint64_t set_owner;
88 	uint64_t get_access;
89 	uint64_t set_access;
90 	uint64_t monitor_file;
91 	uint64_t service_timer;
92 	uint64_t service_path;
93 	uint64_t cleanup;
94 	uint64_t regenerate;
95 } call_statistics;
96 
97 extern void log_message(int priority, const char *str, ...);
98 extern uint32_t daemon_post(const char *name, uint32_t u, uint32_t g);
99 extern uint32_t daemon_post_nid(uint64_t nid, uint32_t u, uint32_t g);
100 extern void daemon_post_client(uint64_t cid);
101 extern void daemon_set_state(const char *name, uint64_t val);
102 extern void dump_status(uint32_t level);
103 
104 #endif /* _NOTIFY_DAEMON_H_ */
105