xref: /trueos/lib/libasl/asl_legacy1.h (revision e0d5dc4e99cb0cffad102c7a22a16d828ef86ae5)
1 #ifndef __ASL_LEGACY1_H__
2 #define __ASL_LEGACY1_H__
3 
4 /*
5  * Copyright (c) 2007-2011 Apple Inc.  All rights reserved.
6  *
7  * @APPLE_LICENSE_HEADER_START@
8  *
9  * This file contains Original Code and/or Modifications of Original Code
10  * as defined in and that are subject to the Apple Public Source License
11  * Version 2.0 (the 'License'). You may not use this file except in
12  * compliance with the License. Please obtain a copy of the License at
13  * http://www.opensource.apple.com/apsl/ and read it before using this
14  * file.
15  *
16  * The Original Code and all software distributed under the License are
17  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
18  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
19  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
21  * Please see the License for the specific language governing rights and
22  * limitations under the License.
23  *
24  * @APPLE_LICENSE_HEADER_END@ */
25 
26 /*
27  * ASL Database VERSION 1 (LEGACY)
28  *
29  * Log messages are stored in 80 byte records of the form:
30  *
31  * | 1    | 4    | 8  | 4    | 4    | 8    | 8    | 8      | 8        | 4     | 4   | 4   | 4   | 8       | 2     | 1    | (80 bytes)
32  * | Type | Next | ID | RUID | RGID | Time | Host | Sender | Facility | LEVEL | PID | UID | GID | Message | Flags | Zero |
33  *
34  * If there are no additional key/value pairs in the message, Next will be zero.  If there are additional
35  * key/value pairs in the database, Next is a record number for a record with the format:
36  *
37  * | 1    | 4    | 4      | 8    | 8    | 8    | 8    | 8    | 8    | 8    | 8    | 7    | (80 bytes)
38  * | Type | Next | Count  | Key1 | Val1 | Key2 | Val2 | Key3 | Val3 | Key4 | Val4 | Zero |
39  *
40  * Additional records will be chained using the Next field, with the count field left zero.
41  *
42  * Strings stored in records of the form:
43  *
44  * | 1    | 4    | 8  | 4        | 4    | 4      | 55     | (80 bytes)
45  * | Type | Next | ID | Refcount | Hash | Length | String |
46  *
47  * If the string is longer than 55 bytes, Next is a record number for a record with the format:
48  *
49  * | 1    | 4    | 75     | (80 bytes)
50  * | Type | Next | String |
51  *
52  * The first record (header) in the database has the format:
53  *
54  * | 12     | 4    | 8      | 56   | (80 bytes)
55  * | Cookie | Vers | Max ID | Zero |
56  *
57  */
58 
59 #include <stdio.h>
60 #include <stdint.h>
61 #include <unistd.h>
62 #include <asl.h>
63 #include <asl_msg.h>
64 #include <asl_msg_list.h>
65 #include <Availability.h>
66 
67 typedef struct
68 {
69 	uint8_t type;
70 	uint32_t slot;
71 	uint64_t xid;
72 	uint32_t hash;
73 } asl_legacy1_slot_info_t;
74 
75 typedef struct
76 {
77 	asl_legacy1_slot_info_t *slotlist;
78 	uint32_t slotlist_count;
79 	FILE *db;
80 } asl_legacy1_t;
81 
82 uint32_t asl_legacy1_open(const char *path, asl_legacy1_t **s) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
83 uint32_t asl_legacy1_close(asl_legacy1_t *s) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
84 uint32_t asl_legacy1_fetch(asl_legacy1_t *s, uint64_t msgid, asl_msg_t **msg) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
85 uint32_t asl_legacy1_match(asl_legacy1_t *s, asl_msg_list_t *query, asl_msg_list_t **res, uint64_t *last, uint64_t start, uint32_t count, int32_t direction) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
86 
87 #endif /*__ASL_LEGACY1_H__*/
88