]>
git.saurik.com Git - apple/libc.git/blob - gen/asl_file.h
d550d8d961dd9beaaa7d82b17cbf62a7180cecf3
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>
31 #include <Availability.h>
33 #define DB_HEADER_LEN 80
34 #define DB_HEADER_COOKIE_OFFSET 0
35 #define DB_HEADER_VERS_OFFSET 12
36 #define DB_HEADER_FIRST_OFFSET 16
37 #define DB_HEADER_TIME_OFFSET 24
38 #define DB_HEADER_CSIZE_OFFSET 32
39 #define DB_HEADER_LAST_OFFSET 36
42 * Magic Cookie for database files.
43 * MAXIMUM 12 CHARS! (DB_HEADER_VERS_OFFSET)
45 #define ASL_DB_COOKIE "ASL DB"
46 #define ASL_DB_COOKIE_LEN 6
48 #define DB_VERSION_LEGACY_1 1
50 #define ASL_FILE_FLAG_READ_ONLY 0x00000001
51 #define ASL_FILE_FLAG_UNLIMITED_CACHE 0x00000002
52 #define ASL_FILE_FLAG_PRESERVE_MSG_ID 0x00000004
53 #define ASL_FILE_FLAG_LEGACY_STORE 0x00000008
55 #define ASL_FILE_TYPE_MSG 0
56 #define ASL_FILE_TYPE_STR 1
58 #define ASL_FILE_POSITION_FIRST 0
59 #define ASL_FILE_POSITION_PREVIOUS 1
60 #define ASL_FILE_POSITION_NEXT 2
61 #define ASL_FILE_POSITION_LAST 3
63 /* NB CACHE_SIZE must be > 1 */
64 #define CACHE_SIZE 256
66 /* Size of the fixed-length part of a MSG record */
67 #define MSG_RECORD_FIXED_LENGTH 122
70 * The first record (header) in the database has the format:
72 * | 12 | 4 | 8 | 8 | 4 | 8 | 36 | (80 bytes)
73 * | Cookie | Vers | First | Time | String cache size | Last | Zero |
75 * MSG records have the format:
77 * | 2 | 4 | 8 | 8 | 8 | 4 | 2 | 2 | 4 | 4 | 4 | 4 | 4 | 4 | 4
78 * | 00 | Len | Next | ID | Time | Nano | Level | Flags | PID | UID | GID | RUID | RGID | RefPID | KV count ...
80 * | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | | 8
81 * | Host | Sender | Facility | Message | RefProc | Session | Key0 | Val0 | ... | Previous |
83 * STR records have the format:
85 * | 2 | 4 | Len | (Len + 6 bytes)
86 * | 01 | Len | Data+NUL |
90 typedef struct file_string_s
94 struct file_string_s
*next
;
102 uint32_t string_count
;
103 file_string_t
*string_list
;
116 typedef struct asl_file_list_s
119 struct asl_file_list_s
*next
;
122 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
);
123 void asl_file_list_close(asl_file_list_t
*list
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
125 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
);
126 uint32_t asl_file_close(asl_file_t
*s
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
128 uint32_t asl_file_save(asl_file_t
*s
, aslmsg msg
, uint64_t *mid
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
130 uint32_t asl_file_open_read(const char *path
, asl_file_t
**s
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
131 uint32_t asl_file_fetch(asl_file_t
*s
, uint64_t mid
, aslmsg
*msg
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
133 uint32_t asl_file_read_set_position(asl_file_t
*s
, uint32_t pos
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
134 uint32_t asl_file_fetch_next(asl_file_t
*s
, aslmsg
*msg
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
135 uint32_t asl_file_fetch_previous(asl_file_t
*s
, aslmsg
*msg
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
137 uint32_t asl_file_match(asl_file_t
*s
, aslresponse query
, aslresponse
*res
, uint64_t *last_id
, uint64_t start_id
, uint32_t count
, int32_t direction
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
138 uint32_t asl_file_list_match_timeout(asl_file_list_t
*list
, aslresponse query
, aslresponse
*res
, uint64_t *last_id
, uint64_t start_id
, uint32_t count
, int32_t direction
, uint32_t usec
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_3_2
);
139 uint32_t asl_file_list_match(asl_file_list_t
*list
, aslresponse query
, aslresponse
*res
, uint64_t *last_id
, uint64_t start_id
, uint32_t count
, int32_t direction
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
141 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
);
142 uint32_t asl_file_list_match_next(void *token
, aslresponse query
, aslresponse
*res
, uint32_t count
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
143 void asl_file_list_match_end(void *token
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
145 size_t asl_file_size(asl_file_t
*s
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
146 uint64_t asl_file_ctime(asl_file_t
*s
) __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_2_0
);
148 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
);
150 #endif /* __ASL_FILE_H__ */