]>
git.saurik.com Git - apple/syslog.git/blob - libsystem_asl.tproj/include/asl_file.h
e3d38ab209adba202e0d22d8be71336f56bfdbe7
2 * Copyright (c) 2007-2011 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_FILE_H__
25 #define __ASL_FILE_H__
29 #include <sys/types.h>
32 #include <asl_msg_list.h>
33 #include <Availability.h>
34 #include <os/object.h>
35 #include <os/object_private.h>
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
43 #define DB_HEADER_FILTER_MASK_OFFSET 36
44 #define DB_HEADER_LAST_OFFSET 37
47 * Magic Cookie for database files.
48 * MAXIMUM 12 CHARS! (DB_HEADER_VERS_OFFSET)
50 #define ASL_DB_COOKIE "ASL DB"
51 #define ASL_DB_COOKIE_LEN 6
53 #define DB_VERSION_LEGACY_1 1
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
61 #define ASL_FILE_TYPE_MSG 0
62 #define ASL_FILE_TYPE_STR 1
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
69 /* flags for asl_file_filter */
70 #define ASL_FILE_FILTER_FLAG_KEEP_MATCHES 0x00000001
72 /* NB CACHE_SIZE must be > 1 */
73 #define CACHE_SIZE 256
75 /* Size of the fixed-length part of a MSG record */
76 #define MSG_RECORD_FIXED_LENGTH 122
79 * The first record (header) in the database has the format:
81 * | 12 | 4 | 8 | 8 | 4 | 8 | 1 | 35 | (80 bytes)
82 * | Cookie | Vers | First | Time | String cache size | Last | Mask | Zero |
84 * MSG records have the format:
86 * | 2 | 4 | 8 | 8 | 8 | 4 | 2 | 2 | 4 | 4 | 4 | 4 | 4 | 4 | 4
87 * | 00 | Len | Next | ID | Time | Nano | Level | Flags | PID | UID | GID | RUID | RGID | RefPID | KV count ...
89 * | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | | 8
90 * | Host | Sender | Facility | Message | RefProc | Session | Key0 | Val0 | ... | Previous |
92 * STR records have the format:
94 * | 2 | 4 | Len | (Len + 6 bytes)
95 * | 01 | Len | Data+NUL |
99 typedef struct file_string_s
103 struct file_string_s
*next
;
107 typedef struct asl_file_s
109 uint32_t asl_type
; //ASL OBJECT HEADER
110 int32_t refcount
; //ASL OBJECT HEADER
113 uint32_t string_cache_count
;
115 file_string_t
*string_list
;
128 typedef struct asl_file_list_s
131 struct asl_file_list_s
*next
;
136 const asl_jump_table_t
*asl_file_jump_table(void);
138 asl_file_list_t
*asl_file_list_add(asl_file_list_t
*list
, asl_file_t
*f
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
139 void asl_file_list_close(asl_file_list_t
*list
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
141 asl_file_t
*asl_file_retain(asl_file_t
*s
) __OSX_AVAILABLE_STARTING(__MAC_10_10
, __IPHONE_7_0
);
142 void asl_file_release(asl_file_t
*s
) __OSX_AVAILABLE_STARTING(__MAC_10_10
, __IPHONE_7_0
);
144 uint32_t asl_file_open_write(const char *path
, mode_t mode
, uid_t uid
, gid_t gid
, asl_file_t
**s
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
145 uint32_t asl_file_close(asl_file_t
*s
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
147 uint32_t asl_file_save(asl_file_t
*s
, asl_msg_t
*msg
, uint64_t *mid
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
149 uint32_t asl_file_open_read(const char *path
, asl_file_t
**s
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
150 uint32_t asl_file_fetch(asl_file_t
*s
, uint64_t mid
, asl_msg_t
**msg
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
152 uint32_t asl_file_read_set_position(asl_file_t
*s
, uint32_t pos
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
153 uint32_t asl_file_fetch_next(asl_file_t
*s
, asl_msg_t
**msg
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
154 uint32_t asl_file_fetch_previous(asl_file_t
*s
, asl_msg_t
**msg
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
156 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
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
157 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
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
159 void *asl_file_list_match_start(asl_file_list_t
*list
, uint64_t start_id
, int32_t direction
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
160 uint32_t asl_file_list_match_next(void *token
, asl_msg_list_t
*query
, asl_msg_list_t
**res
, uint32_t count
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
161 void asl_file_list_match_end(void *token
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
163 size_t asl_file_size(asl_file_t
*s
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
164 uint64_t asl_file_ctime(asl_file_t
*s
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
166 uint32_t asl_file_compact(asl_file_t
*s
, const char *path
, mode_t mode
, uid_t uid
, gid_t gid
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
167 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
)) __OSX_AVAILABLE_STARTING(__MAC_10_10
, __IPHONE_7_0
);
168 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
)) __OSX_AVAILABLE_STARTING(__MAC_10_10
, __IPHONE_7_0
);
172 #endif /* __ASL_FILE_H__ */