]>
Commit | Line | Data |
---|---|---|
81582353 A |
1 | /* |
2 | * Copyright (c) 2012 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 __ASL_COMMON_H__ | |
25 | #define __ASL_COMMON_H__ | |
26 | ||
27 | #include <stdio.h> | |
28 | #include <xpc/xpc.h> | |
29 | ||
30 | #define ASL_MODULE_NAME "com.apple.asl" | |
31 | #define _PATH_CRASHREPORTER "/Library/Logs/CrashReporter" | |
32 | ||
33 | #define ASL_SERVICE_NAME "com.apple.system.logger" | |
34 | ||
35 | #define CRASH_MOVER_WILL_START_NOTIFICATION "CrashMoverWillStart" | |
36 | ||
37 | #define DEFAULT_TTL 7 /* days */ | |
38 | #define SECONDS_PER_DAY 86400 | |
39 | ||
40 | #define ACTION_NONE 0 | |
41 | #define ACTION_SET_PARAM 1 | |
42 | #define ACTION_OUT_DEST 2 | |
43 | #define ACTION_IGNORE 3 | |
44 | #define ACTION_SKIP 4 | |
45 | #define ACTION_CLAIM 5 | |
46 | #define ACTION_NOTIFY 6 | |
47 | #define ACTION_BROADCAST 7 | |
48 | #define ACTION_ACCESS 8 | |
49 | #define ACTION_ASL_STORE 9 /* Save in main ASL Database */ | |
50 | #define ACTION_ASL_FILE 10 /* Save in an ASL format data file */ | |
51 | #define ACTION_ASL_DIR 11 /* Save in an ASL directory */ | |
52 | #define ACTION_FILE 12 /* Save in a text file */ | |
53 | #define ACTION_FORWARD 13 | |
54 | #define ACTION_CONTROL 14 | |
55 | #define ACTION_SET_FILE 15 /* = foo [File /a/b/c] */ | |
56 | #define ACTION_SET_PLIST 16 /* = foo [Plist /a/b/c] ... */ | |
57 | #define ACTION_SET_PROF 17 /* = foo [Profile abc] ... */ | |
58 | ||
59 | #define STYLE_SEC_PREFIX_CHAR 'T' | |
60 | ||
61 | #define MODULE_FLAG_HAS_LOGGED 0x80000000 | |
62 | #define MODULE_FLAG_CLEAR_LOGGED 0x7fffffff | |
63 | #define MODULE_FLAG_ENABLED 0x00000001 | |
64 | #define MODULE_FLAG_LOCAL 0x00000002 | |
65 | #define MODULE_FLAG_ROTATE 0x00000004 | |
66 | #define MODULE_FLAG_COALESCE 0x00000008 | |
67 | #define MODULE_FLAG_COMPRESS 0x00000010 | |
68 | #define MODULE_FLAG_EXTERNAL 0x00000020 | |
69 | #define MODULE_FLAG_STYLE_SEC 0x00000100 /* foo.T1332799722 (note STYLE_SEC_PREFIX_CHAR) */ | |
70 | #define MODULE_FLAG_STYLE_SEQ 0x00000200 /* foo.0 */ | |
71 | #define MODULE_FLAG_STYLE_UTC 0x00000400 /* foo.2012-04-06T13:45:00Z */ | |
72 | #define MODULE_FLAG_STYLE_UTC_B 0x00000800 /* ("basic utc") foo.20120406T134500Z */ | |
73 | #define MODULE_FLAG_STYLE_LCL 0x00001000 /* foo.2012-04-06T13:45:00-7 */ | |
74 | #define MODULE_FLAG_STYLE_LCL_B 0x00002000 /* ("basic local") foo.20120406T134500-7 */ | |
75 | #define MODULE_FLAG_BASESTAMP 0x00004000 /* base file has timestamp */ | |
76 | #define MODULE_FLAG_CRASHLOG 0x00008000 /* checkpoint on CrashMoverWillStart notification */ | |
77 | #define MODULE_FLAG_SOFT_WRITE 0x00010000 /* ignore write failures */ | |
78 | #define MODULE_FLAG_TYPE_ASL 0x00020000 /* asl format file */ | |
79 | #define MODULE_FLAG_TYPE_ASL_DIR 0x00040000 /* asl format directory */ | |
80 | #define MODULE_FLAG_STD_BSD_MSG 0x00080000 /* print format is std, bsd, or msg */ | |
81 | ||
82 | #define CHECKPOINT_TEST 0x00000000 | |
83 | #define CHECKPOINT_FORCE 0xffffffff | |
84 | #define CHECKPOINT_SIZE 0x00000001 | |
85 | #define CHECKPOINT_TIME 0x00000002 | |
86 | #define CHECKPOINT_CRASH 0x00000004 | |
87 | ||
88 | typedef struct | |
89 | { | |
90 | char *path; | |
91 | char *fname; | |
92 | char *fmt; | |
93 | const char *tfmt; | |
94 | char *rotate_dir; | |
95 | uint32_t flags; | |
96 | uint32_t fails; | |
97 | uint32_t ttl; | |
98 | mode_t mode; | |
99 | #if !TARGET_IPHONE_SIMULATOR | |
100 | uid_t *uid; | |
101 | uint32_t nuid; | |
102 | gid_t *gid; | |
103 | uint32_t ngid; | |
104 | #endif | |
105 | size_t file_max; | |
106 | size_t all_max; | |
107 | uint32_t refcount; | |
108 | time_t stamp; | |
109 | size_t size; | |
110 | void *private; | |
111 | } asl_out_dst_data_t; | |
112 | ||
113 | typedef struct asl_out_rule_s | |
114 | { | |
115 | asl_msg_t *query; | |
116 | uint32_t action; | |
117 | char *options; | |
118 | asl_out_dst_data_t *dst; | |
119 | void *private; | |
120 | struct asl_out_rule_s *next; | |
121 | } asl_out_rule_t; | |
122 | ||
123 | typedef struct asl_out_module_s | |
124 | { | |
125 | char *name; | |
126 | uint32_t flags; | |
127 | asl_out_rule_t *ruleset; | |
128 | struct asl_out_module_s *next; | |
129 | } asl_out_module_t; | |
130 | ||
131 | typedef struct asl_out_file_list_s | |
132 | { | |
133 | char *name; | |
134 | time_t ftime; | |
135 | uint32_t seq; | |
136 | size_t size; | |
137 | struct asl_out_file_list_s *next; | |
138 | struct asl_out_file_list_s *prev; | |
139 | } asl_out_file_list_t; | |
140 | ||
141 | char **explode(const char *s, const char *delim); | |
142 | void free_string_list(char **l); | |
143 | char *get_line_from_file(FILE *f); | |
144 | char *next_word_from_string(char **s); | |
145 | size_t asl_str_to_size(char *s); | |
146 | asl_msg_t *xpc_object_to_asl_msg(xpc_object_t xobj); | |
147 | ||
148 | int asl_check_option(aslmsg msg, const char *opt); | |
149 | ||
150 | /* ASL OUT MODULES */ | |
151 | asl_out_module_t *asl_out_module_new(const char *name); | |
152 | void asl_out_module_free(asl_out_module_t *m); | |
153 | asl_out_module_t *asl_out_module_init(void); | |
154 | asl_out_module_t *asl_out_module_init_from_file(const char *name, FILE *f); | |
155 | asl_out_rule_t *asl_out_module_parse_line(asl_out_module_t *m, char *s); | |
156 | ||
157 | void asl_out_module_print(FILE *f, asl_out_module_t *m); | |
158 | char *asl_out_module_rule_to_string(asl_out_rule_t *r); | |
159 | ||
160 | int asl_out_mkpath(asl_out_rule_t *r); | |
161 | int asl_out_dst_checkpoint(asl_out_dst_data_t *dst, uint32_t force); | |
162 | int asl_out_dst_file_create_open(asl_out_dst_data_t *dst); | |
163 | int asl_out_dst_set_access(int fd, asl_out_dst_data_t *dst); | |
164 | void asl_make_timestamp(time_t stamp, uint32_t flags, char *buf, size_t len); | |
165 | void asl_make_dst_filename(asl_out_dst_data_t *dst, char *buf, size_t len); | |
166 | ||
167 | asl_out_dst_data_t *asl_out_dst_data_retain(asl_out_dst_data_t *dst); | |
168 | void asl_out_dst_data_release(asl_out_dst_data_t *dst); | |
169 | ||
170 | /* rotated log files */ | |
171 | asl_out_file_list_t *asl_list_log_files(const char *dir, const char *base, bool src, uint32_t flags); | |
172 | asl_out_file_list_t * asl_list_src_files(asl_out_dst_data_t *dst); | |
173 | asl_out_file_list_t * asl_list_dst_files(asl_out_dst_data_t *dst); | |
174 | void asl_out_file_list_free(asl_out_file_list_t *l); | |
175 | ||
176 | asl_msg_t *configuration_profile_to_asl_msg(const char *ident); | |
177 | ||
178 | #endif /* __ASL_COMMON_H__ */ |