]>
git.saurik.com Git - apple/syslog.git/blob - aslcommon/asl_common.h
2 * Copyright (c) 2012 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@
24 #ifndef __ASL_COMMON_H__
25 #define __ASL_COMMON_H__
31 #define ASL_MODULE_NAME "com.apple.asl"
32 #define _PATH_CRASHREPORTER "/Library/Logs/CrashReporter"
33 #define _PATH_CRASHREPORTER_MOBILE_1 "/var/mobile/Library/Logs/CrashReporter"
34 #define _PATH_CRASHREPORTER_MOBILE_2 "/private/var/mobile/Library/Logs/CrashReporter"
35 #define ASL_INTERNAL_LOGS_DIR "Logs"
37 #define ASL_SERVICE_NAME "com.apple.system.logger"
39 #define CRASH_MOVER_WILL_START_NOTIFICATION "CrashMoverWillStart"
41 #define SECONDS_PER_DAY 86400
42 #define DEFAULT_TTL (7 * SECONDS_PER_DAY)
45 #define ACTION_SET_PARAM 1
46 #define ACTION_OUT_DEST 2
47 #define ACTION_IGNORE 3
49 #define ACTION_CLAIM 5
50 #define ACTION_NOTIFY 6
51 #define ACTION_BROADCAST 7
52 #define ACTION_ACCESS 8
53 #define ACTION_SET_KEY 9
54 #define ACTION_UNSET_KEY 10
55 #define ACTION_ASL_STORE 11 /* Save in main ASL Database */
56 #define ACTION_ASL_FILE 12 /* Save in an ASL format data file */
57 #define ACTION_ASL_DIR 13 /* Save in an ASL directory */
58 #define ACTION_FILE 14 /* Save in a text file */
59 #define ACTION_FORWARD 15
60 #define ACTION_CONTROL 16
61 #define ACTION_SET_FILE 17 /* = foo [File /a/b/c] */
62 #define ACTION_SET_PLIST 18 /* = foo [Plist /a/b/c] ... */
63 #define ACTION_SET_PROF 19 /* = foo [Profile abc] ... */
65 #define STYLE_SEC_PREFIX_CHAR 'T'
67 #define MODULE_FLAG_HAS_LOGGED 0x80000000
68 #define MODULE_FLAG_CLEAR_LOGGED 0x7fffffff
69 #define MODULE_FLAG_ENABLED 0x00000001
70 #define MODULE_FLAG_LOCAL 0x00000002
71 #define MODULE_FLAG_ROTATE 0x00000004
72 #define MODULE_FLAG_COALESCE 0x00000008
73 #define MODULE_FLAG_COMPRESS 0x00000010
74 #define MODULE_FLAG_NONSTD_DIR 0x00000020
75 #define MODULE_FLAG_EXTERNAL 0x00000040
76 #define MODULE_FLAG_TRUNCATE 0x00000080
77 #define MODULE_FLAG_BASESTAMP 0x00000100 /* base file has timestamp */
78 #define MODULE_FLAG_SYMLINK 0x00000200 /* link to basestamp name */
79 #define MODULE_FLAG_CRASHLOG 0x00000400 /* checkpoint on CrashMoverWillStart notification */
80 #define MODULE_FLAG_SOFT_WRITE 0x00000800 /* ignore write failures */
81 #define MODULE_FLAG_TYPE_ASL 0x00001000 /* asl format file */
82 #define MODULE_FLAG_TYPE_ASL_DIR 0x00002000 /* asl format directory */
83 #define MODULE_FLAG_STD_BSD_MSG 0x00004000 /* print format is std, bsd, or msg */
84 #define MODULE_FLAG_SIZE_ONLY 0x00008000 /* checkpoint on file size only */
86 #define MODULE_NAME_STYLE_FORMAT_MASK 0xf0000000
87 #define MODULE_NAME_STYLE_FORMAT_BS 0x10000000 /* base.stamp */
88 #define MODULE_NAME_STYLE_FORMAT_BES 0x20000000 /* base.ext.stamp */
89 #define MODULE_NAME_STYLE_FORMAT_BSE 0x40000000 /* base.stamp.ext */
90 #define MODULE_NAME_STYLE_STAMP_MASK 0x000000ff
91 #define MODULE_NAME_STYLE_STAMP_SEC 0x00000001 /* foo.T1332799722 (note STYLE_SEC_PREFIX_CHAR) */
92 #define MODULE_NAME_STYLE_STAMP_SEQ 0x00000002 /* foo.0 */
93 #define MODULE_NAME_STYLE_STAMP_UTC 0x00000004 /* foo.2012-04-06T13:45:00Z */
94 #define MODULE_NAME_STYLE_STAMP_UTC_B 0x00000008 /* ("basic utc") foo.20120406T134500Z */
95 #define MODULE_NAME_STYLE_STAMP_LCL 0x00000010 /* foo.2012-04-06T13:45:00-7 */
96 #define MODULE_NAME_STYLE_STAMP_LCL_B 0x00000020 /* ("basic local") foo.20120406T134500-7 */
98 #define STAMP_STYLE_INVALID -1
99 #define STAMP_STYLE_NULL 0
100 #define STAMP_STYLE_SEC 1
101 #define STAMP_STYLE_SEQ 2
102 #define STAMP_STYLE_ISO8601 3
104 #define CHECKPOINT_TEST 0x00000000
105 #define CHECKPOINT_FORCE 0x00000001
119 uint32_t style_flags
;
125 #if !TARGET_OS_SIMULATOR
137 } asl_out_dst_data_t
;
139 typedef struct asl_out_rule_s
144 asl_out_dst_data_t
*dst
;
146 struct asl_out_rule_s
*next
;
149 typedef struct asl_out_module_s
153 asl_out_rule_t
*ruleset
;
154 struct asl_out_module_s
*next
;
157 typedef struct asl_out_file_list_s
164 struct asl_out_file_list_s
*next
;
165 struct asl_out_file_list_s
*prev
;
166 } asl_out_file_list_t
;
168 char **explode(const char *s
, const char *delim
);
169 void free_string_list(char **l
);
170 char *get_line_from_file(FILE *f
);
171 char *next_word_from_string(char **s
);
172 size_t asl_str_to_size(char *s
);
173 asl_msg_t
*xpc_object_to_asl_msg(xpc_object_t xobj
);
175 int asl_check_option(asl_msg_t
*msg
, const char *opt
);
177 /* ASL OUT MODULES */
178 asl_out_module_t
*asl_out_module_new(const char *name
);
179 void asl_out_module_free(asl_out_module_t
*m
);
180 asl_out_module_t
*asl_out_module_init(void);
181 asl_out_module_t
*asl_out_module_init_from_file(const char *name
, FILE *f
);
182 asl_out_rule_t
*asl_out_module_parse_line(asl_out_module_t
*m
, char *s
);
184 void asl_out_module_print(FILE *f
, asl_out_module_t
*m
);
185 char *asl_out_module_rule_to_string(asl_out_rule_t
*r
);
187 int asl_out_mkpath(asl_out_module_t
*mlist
, asl_out_rule_t
*r
);
188 int asl_make_database_dir(const char *dir
, char **out
);
189 int asl_out_dst_checkpoint(asl_out_dst_data_t
*dst
, uint32_t force
);
190 int asl_out_dst_file_create_open(asl_out_dst_data_t
*dst
, char **pathp
);
191 int asl_out_dst_set_access(int fd
, asl_out_dst_data_t
*dst
);
192 void asl_make_timestamp(time_t stamp
, uint32_t flags
, char *buf
, size_t len
);
193 void asl_dst_make_current_name(asl_out_dst_data_t
*dst
, uint32_t xflags
, char *buf
, size_t len
);
195 asl_out_dst_data_t
*asl_out_dst_data_retain(asl_out_dst_data_t
*dst
);
196 void asl_out_dst_data_release(asl_out_dst_data_t
*dst
);
198 /* rotated log files */
199 asl_out_file_list_t
*asl_list_log_files(const char *dir
, const char *base
, const char *ext
, uint32_t flags
, bool src
);
200 asl_out_file_list_t
* asl_list_src_files(asl_out_dst_data_t
*dst
);
201 asl_out_file_list_t
* asl_list_dst_files(asl_out_dst_data_t
*dst
);
202 void asl_out_file_list_free(asl_out_file_list_t
*l
);
203 asl_out_dst_data_t
*asl_out_dest_for_path(asl_out_module_t
*m
, const char *path
);
205 asl_msg_t
*configuration_profile_to_asl_msg(const char *ident
);
207 int asl_secure_chown_chmod_dir(const char *path
, uid_t uid
, gid_t gid
, mode_t mode
);
209 #endif /* __ASL_COMMON_H__ */