2 * Copyright (c) 2004-2008 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
28 #include <sys/types.h>
29 #include <sys/queue.h>
32 #include <asl_private.h>
33 #include <asl_store.h>
34 #include <asl_memory.h>
35 #include <asl_mini_memory.h>
39 #define ADDFD_FLAGS_LOCAL 0x00000001
41 #define ASL_DB_NOTIFICATION "com.apple.system.logger.message"
42 #define SELF_DB_NOTIFICATION "self.logger.message"
44 #define ASL_KEY_READ_UID "ReadUID"
45 #define ASL_KEY_READ_GID "ReadGID"
46 #define ASL_KEY_EXPIRE_TIME "ASLExpireTime"
47 #define ASL_KEY_IGNORE "ASLIgnore"
48 #define ASL_KEY_TIME_NSEC "TimeNanoSec"
49 #define ASL_KEY_REF_PID "RefPID"
50 #define ASL_KEY_REF_PROC "RefProc"
51 #define ASL_KEY_SESSION "Session"
53 #define _PATH_PIDFILE "/var/run/syslog.pid"
54 #define _PATH_ASL_IN "/var/run/asl_input"
55 #define _PATH_SYSLOG_CONF "/etc/syslog.conf"
56 #define _PATH_SYSLOG_IN "/var/run/syslog"
57 #define _PATH_KLOG "/dev/klog"
58 #define _PATH_MODULE_LIB "/usr/lib/asl"
60 #define DB_TYPE_FILE 0x00000001
61 #define DB_TYPE_MEMORY 0x00000002
62 #define DB_TYPE_MINI 0x00000004
64 #define KERN_DISASTER_LEVEL 3
71 int disaster_occurred
;
72 mach_port_t server_port
;
73 launch_data_t launch_dict
;
74 const char *debug_file
;
79 uint32_t db_memory_max
;
82 uint64_t bsd_flush_time
;
83 uint64_t asl_store_ping_time
;
84 uint64_t bsd_max_dup_time
;
88 asl_memory_t
*memory_db
;
89 asl_mini_memory_t
*mini_db
;
90 asl_mini_memory_t
*disaster_db
;
93 extern struct global_s global
;
102 TAILQ_ENTRY(module_list
) entries
;
105 int aslevent_init(void);
106 int aslevent_fdsets(fd_set
*, fd_set
*, fd_set
*);
107 void aslevent_handleevent(fd_set
*, fd_set
*, fd_set
*);
109 void asl_archive(void);
111 char *get_line_from_file(FILE *f
);
113 int asldebug(const char *, ...);
114 int asl_log_string(const char *str
);
116 char *asl_msg_to_string(asl_msg_t
*msg
, uint32_t *len
);
117 asl_msg_t
*asl_msg_from_string(const char *buf
);
118 int asl_msg_cmp(asl_msg_t
*a
, asl_msg_t
*b
);
119 time_t asl_parse_time(const char *str
);
121 typedef asl_msg_t
*(*aslreadfn
)(int);
122 typedef char *(*aslwritefn
)(const char *, int);
123 typedef char *(*aslexceptfn
)(int);
124 typedef int (*aslsendmsgfn
)(asl_msg_t
*msg
, const char *outid
);
126 int aslevent_addfd(int fd
, uint32_t flags
, aslreadfn
, aslwritefn
, aslexceptfn
);
127 int aslevent_removefd(int fd
);
128 int aslevent_addmatch(asl_msg_t
*query
, char *outid
);
130 int aslevent_addoutput(aslsendmsgfn
, const char *outid
);
132 int asl_syslog_faciliy_name_to_num(const char *fac
);
133 const char *asl_syslog_faciliy_num_to_name(int num
);
134 asl_msg_t
*asl_input_parse(const char *in
, int len
, char *rhost
, int flag
);
136 void db_ping_store(time_t now
);
138 /* message refcount utilities */
139 uint32_t asl_msg_type(asl_msg_t
*m
);
140 asl_msg_t
*asl_msg_retain(asl_msg_t
*m
);
141 void asl_msg_release(asl_msg_t
*m
);
144 uint32_t notify_register_plain(const char *name
, int *out_token
);
146 #endif /* __DAEMON_H__ */