]> git.saurik.com Git - apple/syslog.git/blob - libsystem_asl.tproj/include/asl_store.h
syslog-267.tar.gz
[apple/syslog.git] / libsystem_asl.tproj / include / asl_store.h
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_STORE_H__
25 #define __ASL_STORE_H__
26
27 #include <stdio.h>
28 #include <stdint.h>
29 #include <sys/time.h>
30 #include <asl.h>
31 #include <asl_file.h>
32 #include <asl_core.h>
33 #include <Availability.h>
34 #include <os/object.h>
35 #include <os/object_private.h>
36 #include <TargetConditionals.h>
37
38 #define PATH_ASL_STORE (asl_filesystem_path(ASL_PLACE_DATABASE))
39 #define PATH_ASL_ARCHIVE (asl_filesystem_path(ASL_PLACE_ARCHIVE))
40
41 #define FILE_ASL_STORE_DATA "StoreData"
42
43 #define ASL_STORE_FLAG_NO_ACLS 0x00000001
44 #define ASL_STORE_FLAG_NO_TTL 0x00000002
45
46 #define FILE_CACHE_SIZE 64
47 #define FILE_CACHE_TTL 300
48
49 typedef struct
50 {
51 time_t ts;
52 uid_t u;
53 gid_t g;
54 time_t bb;
55 char *path;
56 asl_file_t *f;
57 } asl_cached_file_t;
58
59 typedef struct asl_store_s
60 {
61 uint32_t asl_type; //ASL OBJECT HEADER
62 int32_t refcount; //ASL OBJECT HEADER
63 uint64_t curr;
64 char *base_dir;
65 FILE *storedata;
66 uint64_t next_id;
67 asl_cached_file_t file_cache[FILE_CACHE_SIZE];
68 void *work;
69 time_t start_today;
70 time_t start_tomorrow;
71 time_t last_write;
72 size_t max_file_size;
73 uint32_t flags;
74 } asl_store_t;
75
76 __BEGIN_DECLS
77
78 const asl_jump_table_t *asl_store_jump_table(void);
79
80 uint32_t asl_store_open_write(const char *basedir, asl_store_t **s) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
81 uint32_t asl_store_open_read(const char *basedir, asl_store_t **s) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
82 uint32_t asl_store_close(asl_store_t *s) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
83 asl_store_t *asl_store_retain(asl_store_t *s) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_0);
84 void asl_store_release(asl_store_t *s) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_0);
85 uint32_t asl_store_statistics(asl_store_t *s, asl_msg_t **msg) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
86
87 uint32_t asl_store_set_flags(asl_store_t *s, uint32_t flags) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_0);
88
89 uint32_t asl_store_save(asl_store_t *s, asl_msg_t *msg) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
90
91 asl_msg_list_t *asl_store_match(asl_store_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);
92
93 uint32_t asl_store_match_start(asl_store_t *s, uint64_t start_id, int32_t direction) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
94 uint32_t asl_store_match_next(asl_store_t *s, asl_msg_list_t *query, asl_msg_list_t **res, uint32_t count) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
95
96 uint32_t asl_store_max_file_size(asl_store_t *s, size_t max) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
97 uint32_t asl_store_sweep_file_cache(asl_store_t *s) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_2);
98
99 uint32_t asl_store_open_aux(asl_store_t *s, asl_msg_t *msg, int *fd, char **url) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
100
101 __END_DECLS
102
103 #endif /* __ASL_STORE_H__ */