]>
Commit | Line | Data |
---|---|---|
81582353 A |
1 | /* |
2 | * Copyright (c) 2007-2011 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_FILE_H__ | |
25 | #define __ASL_FILE_H__ | |
26 | ||
27 | #include <stdio.h> | |
28 | #include <stdint.h> | |
29 | #include <sys/types.h> | |
30 | #include <asl.h> | |
f3df4c03 A |
31 | #include <asl_msg.h> |
32 | #include <asl_msg_list.h> | |
81582353 | 33 | #include <Availability.h> |
f3df4c03 A |
34 | #include <os/object.h> |
35 | #include <os/object_private.h> | |
81582353 A |
36 | |
37 | #define DB_HEADER_LEN 80 | |
38 | #define DB_HEADER_COOKIE_OFFSET 0 | |
39 | #define DB_HEADER_VERS_OFFSET 12 | |
40 | #define DB_HEADER_FIRST_OFFSET 16 | |
41 | #define DB_HEADER_TIME_OFFSET 24 | |
42 | #define DB_HEADER_CSIZE_OFFSET 32 | |
f3df4c03 A |
43 | #define DB_HEADER_FILTER_MASK_OFFSET 36 |
44 | #define DB_HEADER_LAST_OFFSET 37 | |
81582353 A |
45 | |
46 | /* | |
47 | * Magic Cookie for database files. | |
48 | * MAXIMUM 12 CHARS! (DB_HEADER_VERS_OFFSET) | |
49 | */ | |
50 | #define ASL_DB_COOKIE "ASL DB" | |
51 | #define ASL_DB_COOKIE_LEN 6 | |
52 | #define DB_VERSION 2 | |
53 | #define DB_VERSION_LEGACY_1 1 | |
54 | ||
f3df4c03 A |
55 | #define ASL_FILE_FLAG_READ 0x00000001 |
56 | #define ASL_FILE_FLAG_WRITE 0x00000002 | |
57 | #define ASL_FILE_FLAG_UNLIMITED_CACHE 0x00000004 | |
58 | #define ASL_FILE_FLAG_PRESERVE_MSG_ID 0x00000008 | |
59 | #define ASL_FILE_FLAG_LEGACY_STORE 0x00000010 | |
81582353 A |
60 | |
61 | #define ASL_FILE_TYPE_MSG 0 | |
62 | #define ASL_FILE_TYPE_STR 1 | |
63 | ||
64 | #define ASL_FILE_POSITION_FIRST 0 | |
65 | #define ASL_FILE_POSITION_PREVIOUS 1 | |
66 | #define ASL_FILE_POSITION_NEXT 2 | |
67 | #define ASL_FILE_POSITION_LAST 3 | |
68 | ||
f3df4c03 A |
69 | /* flags for asl_file_filter */ |
70 | #define ASL_FILE_FILTER_FLAG_KEEP_MATCHES 0x00000001 | |
71 | ||
81582353 | 72 | /* NB CACHE_SIZE must be > 1 */ |
5222c21d A |
73 | #define CACHE_SIZE 128 |
74 | ||
75 | /* This makes the maximum size of a file_string_t 128 bytes */ | |
76 | #define CACHE_MAX_STRING_LEN 108 | |
81582353 A |
77 | |
78 | /* Size of the fixed-length part of a MSG record */ | |
79 | #define MSG_RECORD_FIXED_LENGTH 122 | |
80 | ||
81 | /* | |
82 | * The first record (header) in the database has the format: | |
83 | * | |
f3df4c03 A |
84 | * | 12 | 4 | 8 | 8 | 4 | 8 | 1 | 35 | (80 bytes) |
85 | * | Cookie | Vers | First | Time | String cache size | Last | Mask | Zero | | |
81582353 A |
86 | * |
87 | * MSG records have the format: | |
88 | * | |
89 | * | 2 | 4 | 8 | 8 | 8 | 4 | 2 | 2 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | |
90 | * | 00 | Len | Next | ID | Time | Nano | Level | Flags | PID | UID | GID | RUID | RGID | RefPID | KV count ... | |
91 | * | |
92 | * | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | | 8 | |
93 | * | Host | Sender | Facility | Message | RefProc | Session | Key0 | Val0 | ... | Previous | | |
94 | * | |
95 | * STR records have the format: | |
96 | * | |
97 | * | 2 | 4 | Len | (Len + 6 bytes) | |
98 | * | 01 | Len | Data+NUL | | |
99 | * | |
100 | */ | |
101 | ||
102 | typedef struct file_string_s | |
103 | { | |
104 | uint64_t where; | |
105 | uint32_t hash; | |
106 | struct file_string_s *next; | |
5222c21d | 107 | char str[CACHE_MAX_STRING_LEN]; |
81582353 A |
108 | } file_string_t; |
109 | ||
f3df4c03 | 110 | typedef struct asl_file_s |
81582353 | 111 | { |
f3df4c03 A |
112 | uint32_t asl_type; //ASL OBJECT HEADER |
113 | int32_t refcount; //ASL OBJECT HEADER | |
81582353 A |
114 | uint32_t flags; |
115 | uint32_t version; | |
f3df4c03 A |
116 | uint32_t string_cache_count; |
117 | uint32_t msg_count; | |
81582353 | 118 | file_string_t *string_list; |
5222c21d | 119 | file_string_t *string_spare; |
81582353 A |
120 | uint64_t first; |
121 | uint64_t last; | |
5222c21d | 122 | uint64_t last_mid; |
81582353 A |
123 | uint64_t prev; |
124 | uint64_t cursor; | |
125 | uint64_t cursor_xid; | |
126 | uint64_t dob; | |
127 | size_t file_size; | |
128 | FILE *store; | |
129 | void *legacy; | |
130 | char *scratch; | |
131 | } asl_file_t; | |
132 | ||
133 | typedef struct asl_file_list_s | |
134 | { | |
135 | asl_file_t *file; | |
136 | struct asl_file_list_s *next; | |
137 | } asl_file_list_t; | |
138 | ||
f3df4c03 A |
139 | __BEGIN_DECLS |
140 | ||
141 | const asl_jump_table_t *asl_file_jump_table(void); | |
142 | ||
af7d442c A |
143 | asl_file_list_t *asl_file_list_add(asl_file_list_t *list, asl_file_t *f) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.5,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0)); |
144 | void asl_file_list_close(asl_file_list_t *list) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.5,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0)); | |
81582353 | 145 | |
af7d442c A |
146 | asl_file_t *asl_file_retain(asl_file_t *s) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.10,10.12), ios(7.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0)); |
147 | void asl_file_release(asl_file_t *s) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.10,10.12), ios(7.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0)); | |
f3df4c03 | 148 | |
af7d442c A |
149 | uint32_t asl_file_open_write(const char *path, mode_t mode, uid_t uid, gid_t gid, asl_file_t **s) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.5,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0)); |
150 | uint32_t asl_file_close(asl_file_t *s) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.5,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0)); | |
81582353 | 151 | |
af7d442c | 152 | uint32_t asl_file_save(asl_file_t *s, asl_msg_t *msg, uint64_t *mid) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.5,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0)); |
81582353 | 153 | |
af7d442c A |
154 | uint32_t asl_file_open_read(const char *path, asl_file_t **s) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.5,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0)); |
155 | uint32_t asl_file_fetch(asl_file_t *s, uint64_t mid, asl_msg_t **msg) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.5,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0)); | |
81582353 | 156 | |
af7d442c A |
157 | uint32_t asl_file_read_set_position(asl_file_t *s, uint32_t pos) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.5,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0)); |
158 | uint32_t asl_file_fetch_next(asl_file_t *s, asl_msg_t **msg) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.5,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0)); | |
159 | uint32_t asl_file_fetch_previous(asl_file_t *s, asl_msg_t **msg) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.5,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0)); | |
81582353 | 160 | |
af7d442c A |
161 | asl_msg_list_t *asl_file_match(asl_file_t *s, asl_msg_list_t *query, uint64_t *last, uint64_t start, uint32_t count, uint32_t duration, int32_t direction) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.5,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0)); |
162 | asl_msg_list_t *asl_file_list_match(asl_file_list_t *list, asl_msg_list_t *query, uint64_t *last, uint64_t start, uint32_t count, uint32_t duration, int32_t direction) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.5,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0)); | |
81582353 | 163 | |
af7d442c A |
164 | void *asl_file_list_match_start(asl_file_list_t *list, uint64_t start_id, int32_t direction) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.5,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0)); |
165 | uint32_t asl_file_list_match_next(void *token, asl_msg_list_t *query, asl_msg_list_t **res, uint32_t count) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.5,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0)); | |
166 | void asl_file_list_match_end(void *token) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.5,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0)); | |
81582353 | 167 | |
af7d442c A |
168 | size_t asl_file_size(asl_file_t *s) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.5,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0)); |
169 | uint64_t asl_file_ctime(asl_file_t *s) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.5,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0)); | |
81582353 | 170 | |
af7d442c A |
171 | uint32_t asl_file_compact(asl_file_t *s, const char *path, mode_t mode, uid_t uid, gid_t gid) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.5,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0)); |
172 | uint32_t asl_file_filter(asl_file_t *s, const char *path, asl_msg_list_t *filter, uint32_t flags, mode_t mode, uid_t uid, gid_t gid, uint32_t *dstcount, void (*aux_callback)(const char *auxfile)) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.10,10.12), ios(7.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0)); | |
173 | uint32_t asl_file_filter_level(asl_file_t *s, const char *path, uint32_t keep_mask, mode_t mode, uid_t uid, gid_t gid, uint32_t *dstcount, void (*aux_callback)(const char *auxfile)) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.10,10.12), ios(7.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0)); | |
f3df4c03 A |
174 | |
175 | __END_DECLS | |
81582353 A |
176 | |
177 | #endif /* __ASL_FILE_H__ */ |