xref: /NextBSD/lib/libasl/asl_client.h (revision 33da5adc555b3bc29986eeadca03829e4ad06b1e)
1 /*
2  * Copyright (c) 2012 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_CLIENT_H__
25 #define __ASL_CLIENT_H__
26 
27 #include <stdint.h>
28 #include <asl.h>
29 #include <asl_file.h>
30 #include <asl_store.h>
31 #include <asl_msg.h>
32 #include <asl_msg_list.h>
33 #include <Availability.h>
34 #include <asl_object.h>
35 
36 #define CLIENT_FLAG_WRITE_SYS   0x00000001
37 #define CLIENT_FLAG_WRITE_STORE 0x00000002
38 #define CLIENT_FLAG_WRITE_FILE  0x00000004
39 #define CLIENT_FLAG_READ_SYS    0x00000100
40 #define CLIENT_FLAG_READ_STORE  0x00000200
41 #define CLIENT_FLAG_READ_FILE   0x00000400
42 
43 typedef struct
44 {
45 	int fd;
46 	uint32_t encoding;
47 	uint32_t filter;
48 	char *mfmt;
49 	char *tfmt;
50 } asl_out_file_t;
51 
52 typedef struct asl_client_s
53 {
54 	uint32_t asl_type;	//ASL OBJECT HEADER
55 	int32_t refcount;	//ASL OBJECT HEADER
56 	uint32_t flags;
57 	uint32_t options;
58 	pid_t pid;
59 	uid_t uid;
60 	gid_t gid;
61 	asl_msg_t *kvdict;
62 	uint32_t filter;
63 	int notify_token;
64 	int notify_master_token;
65 	uint32_t out_count;
66 	asl_out_file_t *out_list;
67 	asl_file_t *aslfile;
68 	uint64_t aslfileid;
69 	asl_store_t *store;
70 	uint32_t reserved1;
71 	void *reserved2;
72 } asl_client_t;
73 
74 __BEGIN_DECLS
75 
76 const asl_jump_table_t *asl_client_jump_table(void);
77 
78 asl_client_t *asl_client_open(const char *ident, const char *facility, uint32_t opts) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_0);
79 asl_client_t *asl_client_open_from_file(int descriptor, const char *ident, const char *facility) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_0);
80 asl_client_t *asl_client_retain(asl_client_t *client) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_0);
81 void asl_client_release(asl_client_t *client) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_0);
82 
83 int asl_client_set_filter(asl_client_t *client, int filter) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_0);
84 ASL_STATUS asl_client_add_output_file(asl_client_t *client, int descriptor, const char *mfmt, const char *tfmt, int filter, int text_encoding) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_0);
85 int asl_client_set_output_file_filter(asl_client_t *client, int fd, int filter) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_0);
86 ASL_STATUS asl_client_remove_output_file(asl_client_t *client, int descriptor) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_0);
87 
88 int asl_client_log_descriptor(asl_client_t *client, asl_msg_t *msg, int level, int descriptor, uint32_t fd_type) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_0);
89 
90 asl_msg_t *asl_client_kvdict(asl_client_t *client) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_0);
91 
92 int asl_client_log(asl_client_t *client, asl_msg_t *msg, int level, const char *format, ...) __printflike(4, 5) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_0);
93 int asl_client_vlog(asl_client_t *client, asl_msg_t *msg, int level, const char *format, va_list ap) __printflike(4, 0) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_0);
94 ASL_STATUS asl_client_send(asl_client_t *client, asl_msg_t *msg) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_0);
95 
96 asl_msg_list_t *asl_client_search(asl_client_t *client, asl_msg_t *query) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_0);
97 asl_msg_list_t *asl_client_match(asl_client_t *client, asl_msg_list_t *querylist, size_t *last, size_t start, size_t count, uint32_t duration, int32_t direction) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_0);
98 
99 __END_DECLS
100 
101 #endif /* __ASL_CLIENT_H__ */
102