]>
git.saurik.com Git - apple/syslog.git/blob - libsystem_asl.tproj/include/asl_file.h
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 128
75 /* This makes the maximum size of a file_string_t 128 bytes */
76 #define CACHE_MAX_STRING_LEN 108
78 /* Size of the fixed-length part of a MSG record */
79 #define MSG_RECORD_FIXED_LENGTH 122
82 * The first record (header) in the database has the format:
84 * | 12 | 4 | 8 | 8 | 4 | 8 | 1 | 35 | (80 bytes)
85 * | Cookie | Vers | First | Time | String cache size | Last | Mask | Zero |
87 * MSG records have the format:
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 ...
92 * | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | | 8
93 * | Host | Sender | Facility | Message | RefProc | Session | Key0 | Val0 | ... | Previous |
95 * STR records have the format:
97 * | 2 | 4 | Len | (Len + 6 bytes)
98 * | 01 | Len | Data+NUL |
102 typedef struct file_string_s
106 struct file_string_s
* next
;
107 char str
[ CACHE_MAX_STRING_LEN
];
110 typedef struct asl_file_s
112 uint32_t asl_type
; //ASL OBJECT HEADER
113 int32_t refcount
; //ASL OBJECT HEADER
116 uint32_t string_cache_count
;
118 file_string_t
* string_list
;
119 file_string_t
* string_spare
;
133 typedef struct asl_file_list_s
136 struct asl_file_list_s
* next
;
141 const asl_jump_table_t
* asl_file_jump_table ( void );
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 ));
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 ));
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 ));
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 ));
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 ));
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 ));
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 ));
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 ));
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 ));
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 ));
177 #endif /* __ASL_FILE_H__ */