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
34struct global_s
35{
36	mach_port_t server_port;
37	launch_data_t launch_dict;
38	notify_state_t *notify_state;
39	dispatch_queue_t work_q;
40	dispatch_source_t mach_src;
41	dispatch_source_t sig_usr1_src;
42	dispatch_source_t sig_usr2_src;
43	dispatch_source_t sig_winch_src;
44	uint32_t request_size;
45	uint32_t reply_size;
46	uint32_t nslots;
47	uint32_t slot_id;
48	uint32_t *shared_memory_base;
49	uint32_t *shared_memory_refcount;
50	uint32_t *last_shm_base;
51	uint32_t log_cutoff;
52	uint32_t log_default;
53	FILE *log_file;
54} global;
55
56struct call_statistics_s
57{
58	uint64_t post;
59	uint64_t post_no_op;
60	uint64_t post_by_id;
61	uint64_t post_by_name;
62	uint64_t post_by_name_and_fetch_id;
63	uint64_t reg;
64	uint64_t reg_plain;
65	uint64_t reg_check;
66	uint64_t reg_signal;
67	uint64_t reg_file;
68	uint64_t reg_port;
69	uint64_t cancel;
70	uint64_t suspend;
71	uint64_t resume;
72	uint64_t suspend_pid;
73	uint64_t resume_pid;
74	uint64_t check;
75	uint64_t get_state;
76	uint64_t get_state_by_client;
77	uint64_t get_state_by_id;
78	uint64_t get_state_by_client_and_fetch_id;
79	uint64_t set_state;
80	uint64_t set_state_by_client;
81	uint64_t set_state_by_id;
82	uint64_t set_state_by_client_and_fetch_id;
83	uint64_t get_owner;
84	uint64_t set_owner;
85	uint64_t get_access;
86	uint64_t set_access;
87	uint64_t monitor_file;
88	uint64_t service_timer;
89	uint64_t service_path;
90	uint64_t cleanup;
91	uint64_t regenerate;
92} call_statistics;
93
94extern void log_message(int priority, const char *str, ...);
95extern uint32_t daemon_post(const char *name, uint32_t u, uint32_t g);
96extern uint32_t daemon_post_nid(uint64_t nid, uint32_t u, uint32_t g);
97extern void daemon_post_client(uint64_t cid);
98extern void daemon_set_state(const char *name, uint64_t val);
99extern void dump_status(uint32_t level);
100
101#endif /* _NOTIFY_DAEMON_H_ */
102