]> git.saurik.com Git - apple/syslog.git/blob - syslogd.tproj/daemon.h
syslog-64.tar.gz
[apple/syslog.git] / syslogd.tproj / daemon.h
1 /*
2 * Copyright (c) 2004 Apple Computer, 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 __DAEMON_H__
25 #define __DAEMON_H__
26
27 #include <stdio.h>
28 #include <sys/types.h>
29 #include <sys/queue.h>
30 #include <time.h>
31 #include <asl.h>
32 #include <asl_private.h>
33 #include <notify.h>
34 #include <launch.h>
35
36 #define ADDFD_FLAGS_LOCAL 0x00000001
37
38 #define ASL_DB_NOTIFICATION "com.apple.system.logger.message"
39
40 #define ASL_KEY_READ_UID "ReadUID"
41 #define ASL_KEY_READ_GID "ReadGID"
42 #define ASL_KEY_EXPIRE_TIME "ASLExpireTime"
43 #define ASL_KEY_IGNORE "ASLIgnore"
44 #define ASL_KEY_TIME_NSEC "TimeNanoSec"
45 #define ASL_KEY_REF_PID "RefPID"
46 #define ASL_KEY_REF_PROC "RefProc"
47 #define ASL_KEY_SESSION "Session"
48
49 #define _PATH_PIDFILE "/var/run/syslog.pid"
50 #define _PATH_ASL_IN "/var/run/asl_input"
51 #define _PATH_ASL_DIR "/var/log"
52 #define _PATH_ASL_DB "/var/log/asl.db"
53 #define _PATH_SYSLOG_CONF "/etc/syslog.conf"
54 #define _PATH_SYSLOG_IN "/var/run/syslog"
55 #define _PATH_KLOG "/dev/klog"
56 #define _PATH_MODULE_LIB "/usr/lib/asl"
57
58 #define KERN_DISASTER_LEVEL 3
59
60 extern launch_data_t launch_dict;
61
62 struct module_list
63 {
64 char *name;
65 void *module;
66 int (*init)(void);
67 int (*reset)(void);
68 int (*close)(void);
69 TAILQ_ENTRY(module_list) entries;
70 };
71
72 int aslevent_init(void);
73 int aslevent_fdsets(fd_set *, fd_set *, fd_set *);
74 void aslevent_handleevent(fd_set *, fd_set *, fd_set *);
75 void asl_mark(void);
76 void asl_archive(void);
77
78 char *get_line_from_file(FILE *f);
79
80 int asldebug(const char *, ...);
81 int asl_log_string(const char *str);
82
83 char *asl_msg_to_string(asl_msg_t *msg, uint32_t *len);
84 asl_msg_t *asl_msg_from_string(const char *buf);
85 int asl_msg_cmp(asl_msg_t *a, asl_msg_t *b);
86 time_t asl_parse_time(const char *str);
87
88 typedef asl_msg_t *(*aslreadfn)(int);
89 typedef char *(*aslwritefn)(const char *, int);
90 typedef char *(*aslexceptfn)(int);
91 typedef int (*aslsendmsgfn)(asl_msg_t *msg, const char *outid);
92
93 int aslevent_addfd(int fd, uint32_t flags, aslreadfn, aslwritefn, aslexceptfn);
94 int aslevent_removefd(int fd);
95 int aslevent_addmatch(asl_msg_t *query, char *outid);
96
97 int aslevent_addoutput(aslsendmsgfn, const char *outid);
98
99 int asl_syslog_faciliy_name_to_num(const char *fac);
100 const char *asl_syslog_faciliy_num_to_name(int num);
101 asl_msg_t *asl_input_parse(const char *in, int len, char *rhost, int flag);
102
103 uint32_t db_prune(aslresponse query);
104 uint32_t db_archive(time_t cut, uint64_t max);
105 uint32_t db_compact(void);
106
107 /* message refcount utilities */
108 uint32_t asl_msg_type(asl_msg_t *m);
109 asl_msg_t *asl_msg_retain(asl_msg_t *m);
110 void asl_msg_release(asl_msg_t *m);
111
112 /* notify SPI */
113 uint32_t notify_register_plain(const char *name, int *out_token);
114
115 #endif /* __DAEMON_H__ */