]> git.saurik.com Git - apple/syslog.git/blob - libsystem_asl.tproj/include/asl.h
syslog-377.60.2.tar.gz
[apple/syslog.git] / libsystem_asl.tproj / include / asl.h
1 /*
2 * Copyright (c) 2004-2015 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_H__
25 #define __ASL_H__
26
27 #include <stdint.h>
28 #include <stddef.h>
29 #include <stdarg.h>
30 #include <sys/cdefs.h>
31 #include <Availability.h>
32
33 /* Version number encodes the date YYYYMMDD */
34 #define ASL_API_VERSION 20150225
35
36 typedef struct __asl_object_s *asl_object_t;
37 typedef asl_object_t aslclient;
38 typedef asl_object_t aslmsg;
39 typedef asl_object_t aslresponse;
40
41 /*! @header
42 * These routines are deprecated and replaced by os_log(3). On OS versions
43 * with os_log(3), the ASL routines for emitting log messages are shimmed into
44 * the equivalent os_log functionality. Functions whose deprecation messages
45 * indicate they are unsupported will have no effect on OS versions with
46 * os_log(3) support.
47 *
48 * These routines provide an interface to the Apple System Log facility.
49 * The API allows client applications to create flexible, structured messages
50 * and send them to the syslogd server. Messages received by the server are
51 * saved in a data store, subject to input filtering constraints.
52 * This API also permits clients to create queries and search the message
53 * data store for matching messages.
54 */
55
56 /*
57 * NOTE FOR HeaderDoc
58 *
59 * These are added to allow headerdoc2html to process
60 * the prototypes of asl_log and asl_vlog correctly.
61 * The "-p" option to headerdoc2html is required.
62 */
63 #ifndef __printflike
64 /*! @parseOnly */
65 #define __printflike(a,b)
66 #endif
67
68 #pragma mark -
69
70 /*! @defineblock Log Message Priority Levels
71 * Log levels of the message.
72 */
73 #define ASL_LEVEL_EMERG 0
74 #define ASL_LEVEL_ALERT 1
75 #define ASL_LEVEL_CRIT 2
76 #define ASL_LEVEL_ERR 3
77 #define ASL_LEVEL_WARNING 4
78 #define ASL_LEVEL_NOTICE 5
79 #define ASL_LEVEL_INFO 6
80 #define ASL_LEVEL_DEBUG 7
81 /*! @/defineblock */
82
83 #pragma mark -
84
85 /*! @defineblock Log Message Priority Level Strings
86 * Strings corresponding to log levels.
87 */
88 #define ASL_STRING_EMERG "Emergency"
89 #define ASL_STRING_ALERT "Alert"
90 #define ASL_STRING_CRIT "Critical"
91 #define ASL_STRING_ERR "Error"
92 #define ASL_STRING_WARNING "Warning"
93 #define ASL_STRING_NOTICE "Notice"
94 #define ASL_STRING_INFO "Info"
95 #define ASL_STRING_DEBUG "Debug"
96 /*! @/defineblock */
97
98 #pragma mark -
99
100 /*! @defineblock Attribute Matching
101 * Attribute value comparison operations.
102 */
103 #define ASL_QUERY_OP_CASEFOLD 0x0010
104 #define ASL_QUERY_OP_PREFIX 0x0020
105 #define ASL_QUERY_OP_SUFFIX 0x0040
106 #define ASL_QUERY_OP_SUBSTRING 0x0060
107 #define ASL_QUERY_OP_NUMERIC 0x0080
108 #define ASL_QUERY_OP_REGEX 0x0100
109
110 #define ASL_QUERY_OP_EQUAL 0x0001
111 #define ASL_QUERY_OP_GREATER 0x0002
112 #define ASL_QUERY_OP_GREATER_EQUAL 0x0003
113 #define ASL_QUERY_OP_LESS 0x0004
114 #define ASL_QUERY_OP_LESS_EQUAL 0x0005
115 #define ASL_QUERY_OP_NOT_EQUAL 0x0006
116 #define ASL_QUERY_OP_TRUE 0x0007
117 /*! @/defineblock */
118
119 #pragma mark -
120
121 /*! @defineblock Message Attributes
122 * These attributes are known by ASL, and are generally
123 * associated with all log messages.
124 * Additional attributes may be added as desired.
125 */
126 #define ASL_KEY_TIME "Time" /* Timestamp. Set automatically */
127 #define ASL_KEY_TIME_NSEC "TimeNanoSec" /* Nanosecond time. */
128 #define ASL_KEY_HOST "Host" /* Sender's address (set by the server). */
129 #define ASL_KEY_SENDER "Sender" /* Sender's identification string. Default is process name. */
130 #define ASL_KEY_FACILITY "Facility" /* Sender's facility. Default is "user". */
131 #define ASL_KEY_PID "PID" /* Sending process ID encoded as a string. Set automatically. */
132 #define ASL_KEY_UID "UID" /* UID that sent the log message (set by the server). */
133 #define ASL_KEY_GID "GID" /* GID that sent the log message (set by the server). */
134 #define ASL_KEY_LEVEL "Level" /* Log level number encoded as a string. See levels above. */
135 #define ASL_KEY_MSG "Message" /* Message text. */
136 #define ASL_KEY_READ_UID "ReadUID" /* User read access (-1 is any user). */
137 #define ASL_KEY_READ_GID "ReadGID" /* Group read access (-1 is any group). */
138 #define ASL_KEY_EXPIRE_TIME "ASLExpireTime" /* Expiration time for messages with long TTL. */
139 #define ASL_KEY_MSG_ID "ASLMessageID" /* 64-bit message ID number (set by the server). */
140 #define ASL_KEY_SESSION "Session" /* Session (set by the launchd). */
141 #define ASL_KEY_REF_PID "RefPID" /* Reference PID for messages proxied by launchd */
142 #define ASL_KEY_REF_PROC "RefProc" /* Reference process for messages proxied by launchd */
143 #define ASL_KEY_AUX_TITLE "ASLAuxTitle" /* Auxiliary title string */
144 #define ASL_KEY_AUX_UTI "ASLAuxUTI" /* Auxiliary Uniform Type ID */
145 #define ASL_KEY_AUX_URL "ASLAuxURL" /* Auxiliary Uniform Resource Locator */
146 #define ASL_KEY_AUX_DATA "ASLAuxData" /* Auxiliary in-line data */
147 #define ASL_KEY_OPTION "ASLOption" /* Internal */
148 #define ASL_KEY_MODULE "ASLModule" /* Internal */
149 #define ASL_KEY_SENDER_INSTANCE "SenderInstance" /* Sender instance UUID. */
150 #define ASL_KEY_SENDER_MACH_UUID "SenderMachUUID" /* Sender Mach-O UUID. */
151 #define ASL_KEY_FINAL_NOTIFICATION "ASLFinalNotification" /* syslogd posts value as a notification when message has been processed */
152 #define ASL_KEY_OS_ACTIVITY_ID "OSActivityID" /* Current OS Activity for the logging thread */
153 /*! @/defineblock */
154
155 #pragma mark -
156
157 /*! @defineblock ASL Object Types
158 * The library uses only one opaque type - asl_object_t.
159 * Many of the routines can operate on several different types.
160 * For example, asl_search() can be used to search a list of messages,
161 * an ASL database directory or data file, or the main ASL database.
162 * It can even be used to check a single message against a query
163 * message, or against another message to check for exact match.
164 *
165 * The first three types are container objects - messages, queries,
166 * and lists of messages or queries. The following types are
167 * abstractions for ASL data files and ASL data stores (directories
168 * containing data files).
169 *
170 * ASL_TYPE_CLIENT is a high-level object that abstracts ASL
171 * interactions. It may access ASL stores or files directly,
172 * and it may communicate with ASL daemons.
173 *
174 */
175 #define ASL_TYPE_UNDEF 0xffffffff
176 #define ASL_TYPE_MSG 0
177 #define ASL_TYPE_QUERY 1
178 #define ASL_TYPE_LIST 2
179 #define ASL_TYPE_FILE 3
180 #define ASL_TYPE_STORE 4
181 #define ASL_TYPE_CLIENT 5
182 /*! @/defineblock */
183
184 #pragma mark -
185
186 /*! @defineblock search directions
187 * Used for asl_store_match(), asl_file_match(), and asl_match().
188 */
189 #define ASL_MATCH_DIRECTION_FORWARD 1
190 #define ASL_MATCH_DIRECTION_REVERSE -1
191 /*! @/defineblock */
192
193 #pragma mark -
194
195 /*! @defineblock Filter Masks
196 * Used in client-side filtering, which determines which
197 * messages are sent by the client to the syslogd server.
198 */
199 #define ASL_FILTER_MASK_EMERG 0x01
200 #define ASL_FILTER_MASK_ALERT 0x02
201 #define ASL_FILTER_MASK_CRIT 0x04
202 #define ASL_FILTER_MASK_ERR 0x08
203 #define ASL_FILTER_MASK_WARNING 0x10
204 #define ASL_FILTER_MASK_NOTICE 0x20
205 #define ASL_FILTER_MASK_INFO 0x40
206 #define ASL_FILTER_MASK_DEBUG 0x80
207 /*! @/defineblock */
208
209 #pragma mark -
210
211 /*! @defineblock Filter Mask Macros
212 * Macros to create bitmasks for filter settings - see asl_set_filter().
213 */
214 #define ASL_FILTER_MASK(level) (1 << (level))
215 #define ASL_FILTER_MASK_UPTO(level) ((1 << ((level) + 1)) - 1)
216 /*! @/defineblock */
217
218 #pragma mark -
219
220 /*! @defineblock Client Creation Options
221 * Options for asl_open().
222 * Note that ASL_OPT_NO_DELAY no longer has any effect.
223 */
224 #define ASL_OPT_STDERR 0x00000001
225 #define ASL_OPT_NO_DELAY 0x00000002
226 #define ASL_OPT_NO_REMOTE 0x00000004
227 /*! @/defineblock */
228
229 #pragma mark -
230
231 /*! @defineblock File and Store Open Options
232 * Options for asl_open_path().
233 */
234 #define ASL_OPT_OPEN_WRITE 0x00000001
235 #define ASL_OPT_CREATE_STORE 0x00000002
236 /*! @/defineblock */
237
238 #pragma mark -
239
240 /*! @defineblock File Descriptor Types
241 * Instructions on how to treat the file descriptor in asl_log_descriptor().
242 */
243 #define ASL_LOG_DESCRIPTOR_READ 1
244 #define ASL_LOG_DESCRIPTOR_WRITE 2
245
246 #pragma mark -
247
248 /*! @defineblock Output file message and time formats.
249 * These select internally defined formats for printed log messages for
250 * asl_add_output_file(). Custom message and time formats may also be
251 * used. These pre-defined formats and custom formats are described in detail
252 * in the syslog(1) manual page.
253 */
254 #define ASL_MSG_FMT_RAW "raw"
255 #define ASL_MSG_FMT_STD "std"
256 #define ASL_MSG_FMT_BSD "bsd"
257 #define ASL_MSG_FMT_XML "xml"
258 #define ASL_MSG_FMT_MSG "msg"
259
260 #define ASL_TIME_FMT_SEC "sec"
261 #define ASL_TIME_FMT_UTC "utc"
262 #define ASL_TIME_FMT_LCL "lcl"
263
264 #pragma mark -
265
266 /*! @defineblock Text Encoding Types
267 * These are used by the library when formatting messages to be written
268 * to file descriptors associated with an ASL client handle with
269 * asl_add_output_file(). The syslog(1) manual page describes text encoding
270 * in detail. ASL_ENCODE_ASL corresponds to the "vis" encoding option
271 * described in the syslog(1) manual. ASL_ENCODE_XML should be used in
272 * combination with ASL_MSG_FMT_XML to ensure that special XML characters
273 * are correctly encoded.
274 */
275 #define ASL_ENCODE_NONE 0
276 #define ASL_ENCODE_SAFE 1
277 #define ASL_ENCODE_ASL 2
278 #define ASL_ENCODE_XML 3
279
280 #pragma mark -
281
282 /*!
283 * ASL_PREFILTER_LOG is a macro similar to asl_log(), but it first checks
284 * if the message will simply be ignored due to local filter settings.
285 * This prevents the variable argument list from being evaluated.
286 * Note that the message may still be processed if it will be written
287 * to a file or stderr.
288 *
289 * @param client
290 * (input) An ASL_TYPE_CLIENT object.
291 * @param msg
292 * (input) An asl_object_t of type ASL_TYPE_MSG (default attributes will be supplied if msg is NULL).
293 * @param level
294 * (input) Log level (ASL_LEVEL_DEBUG to ASL_LEVEL_EMERG).
295 * @param format
296 * (input) A printf() - style format string followed by a list of arguments.
297 */
298 #define ASL_PREFILTER_LOG(client, msg, level, format, ...) \
299 do { \
300 asl_object_t _client = (client); \
301 asl_object_t _msg = (msg); \
302 uint32_t _asl_eval = _asl_evaluate_send(_client, _msg, (level)); \
303 if (_asl_eval != 0) _asl_lib_log(_client, _asl_eval, _msg, (format), ## __VA_ARGS__); \
304 } while (0)
305
306 #pragma mark -
307
308 __BEGIN_DECLS
309
310 /* ASL Library SPI - do not call directly */
311 int _asl_lib_log(asl_object_t client, uint32_t eval, asl_object_t msg, const char *format, ...) __printflike(4, 5);
312 uint32_t _asl_evaluate_send(asl_object_t client, asl_object_t msg, int level);
313
314 /*!
315 * Initialize a connection to the ASL server.
316 *
317 * This call is optional in many cases. The library will perform any
318 * necessary initializations on the fly. A call to asl_open() is required
319 * if optional settings must be made before messages are sent to the server.
320 * These include setting the client filter and managing additional output
321 * file descriptors. Note that the default setting of the client filter is
322 * ASL_FILTER_MASK_UPTO(ASL_LEVEL_NOTICE), so ASL_LEVEL_DEBUG and ASL_LEVEL_INFO
323 * messages are not sent to the server by default.
324 * A separate client connection is required for multiple threads or
325 * dispatch queues.
326 *
327 * Options (defined above) may be set using the opts parameter. They are:
328 *
329 * ASL_OPT_STDERR - adds stderr as an output file descriptor
330 *
331 * ASL_OPT_NO_REMOTE - disables the remote-control mechanism for adjusting
332 * filter levers for processes using e.g. syslog -c ...
333 *
334 * @param ident
335 * (input) Sender name.
336 * @param facility
337 * (input) Facility name.
338 * @param opts
339 * (input) Options (see Client Creation Options).
340 * @result Returns an ASL client handle (asl_object_t of type ASL_TYPE_CLIENT).
341 */
342 asl_object_t asl_open(const char *ident, const char *facility, uint32_t opts) __API_DEPRECATED("os_log(3) has replaced asl(3); see os_log_create(3)", macosx(10.4,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
343
344 /*!
345 * Open an ASL database or ASL data file for read or write access.
346 *
347 * Opens an ASL database if the path specifies a directory, or
348 * an ASL data file if the path specifies a file. Opens the system
349 * ASL database if path is NULL.
350 *
351 * If the ASL_OPT_OPEN_READ option is specified, the database or data file may be
352 * searched with asl_search() or asl_match(). asl_next() and asl_prev() may be used
353 * to iterate over the messages in the database or file.
354 *
355 * If the ASL_OPT_OPEN_WRITE option is specified, an existing file or database is
356 * opened for writing. New messages may be added to the file or database using
357 * asl_append(), asl_send(), asl_log(), or asl_vlog(). Existing messages in the
358 * store or file may not be deleted or modified.
359 *
360 * If the path does not exist, asl_open_path() will create a new database if
361 * ASL_OPT_CREATE_STORE is set in the options, or a new data file otherwise.
362 * The file will be created with the user's effective UID and GID as owner and
363 * group. The mode will be 0644. If a different mode, UID, or GID is desired,
364 * an empty file or directory may be pre-created with the desired settings.
365 *
366 * @param path
367 * (input) Location of the ASL database or ASL data file in the filesystem.
368 * A value of NULL may be used to open the system's database.
369 * @param opts
370 * (input) Options (see File and Store Open Options).
371 * @result Returns an ASL object of type ASL_TYPE_STORE or ASL_TYPE_FILE, or NULL on failure.
372 */
373 asl_object_t asl_open_path(const char *path, uint32_t opts) __API_DEPRECATED("os_log(3) has replaced asl(3); this functionality is no longer supported", macosx(10.10,10.12), ios(8.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
374
375 /*!
376 * Shuts down a connection to the server.
377 * This routine is identical to asl_release().
378 *
379 * @param obj
380 * (input) An ASL object.
381 */
382 void asl_close(asl_object_t obj) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.4,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
383
384 /*!
385 * Write log messages to the given file descriptor.
386 *
387 * Log messages will be written to this file as well as to the server.
388 * This is equivalent to calling:
389 * asl_add_output_file(asl, descriptor, ASL_MSG_FMT_STD, ASL_TIME_FMT_LCL, ASL_FILTER_MASK_UPTO(ASL_LEVEL_DEBUG), ASL_ENCODE_SAFE)
390 *
391 * @param client
392 * (input) An ASL client handle (asl_object_t of type ASL_TYPE_CLIENT).
393 * @param descriptor
394 * (input) A file descriptor.
395 * @result Returns 0 on success, non-zero on failure.
396 */
397 int asl_add_log_file(asl_object_t client, int descriptor) __API_DEPRECATED("os_log(3) has replaced asl(3); this functionality is no longer supported", macosx(10.4,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
398
399 /*!
400 * Write log messages to the given file descriptor.
401 *
402 * Log messages will be written to this file as well as to the server.
403 * This routine extends the basic interface offered by asl_add_log_file(),
404 * allowing control of the format used to write log message written to the file.
405 * control of the time zone used when printing time values, and allowing
406 * individual filtering control for each log file.
407 *
408 * @param client
409 * (input) An ASL client handle (asl_object_t of type ASL_TYPE_CLIENT).
410 * @param descriptor
411 * (input) A file descriptor.
412 * @param mfmt
413 * (input) A character string specifying the message format.
414 * @param tfmt
415 * (input) A character string specifying the time format.
416 * @param filter
417 * (input) A filter value.
418 * @param text_encoding
419 * (input) A text encoding type.
420 * @result Returns 0 on success, non-zero on failure.
421 */
422 int asl_add_output_file(asl_object_t client, int fd, const char *mfmt, const char *tfmt, int filter, int text_encoding) __API_DEPRECATED("os_log(3) has replaced asl(3); this functionality is no longer supported", macosx(10.10,10.12), ios(7.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
423
424 /*!
425 * Write log messages to the given file descriptor.
426 *
427 * Sets or changes a filter value for filtering messages written to a file associated
428 * with an ASL client handle using asl_add_output_file() or asl_add_log_file().
429 *
430 * @param client
431 * (input) An ASL client handle (asl_object_t of type ASL_TYPE_CLIENT).
432 * @param descriptor
433 * (input) A file descriptor.
434 * @param filter
435 * (input) A filter value.
436 * @result Returns the previous filter value.
437 */
438 int asl_set_output_file_filter(asl_object_t client, int fd, int filter) __API_DEPRECATED("os_log(3) has replaced asl(3); this functionality is no longer supported", macosx(10.10,10.12), ios(7.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
439
440 /*!
441 * Stop writing log messages to the given file descriptor.
442 * The file descriptor is not closed by this routine.
443 *
444 * @param client
445 * (input) An ASL client handle (asl_object_t of type ASL_TYPE_CLIENT).
446 * @param descriptor
447 * (input) A file descriptor.
448 * @result Returns 0 on success, non-zero on failure.
449 */
450 int asl_remove_log_file(asl_object_t client, int descriptor) __API_DEPRECATED("os_log(3) has replaced asl(3); this functionality is no longer supported", macosx(10.4,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
451
452 /*!
453 * Set a filter for messages being sent to the server.
454 * The filter is a bitmask representing priorities. The ASL_FILTER_MASK
455 * macro may be used to convert a priority level into a bitmask for that
456 * level. The ASL_FILTER_MASK_UPTO macro creates a bitmask for all
457 * priorities up to and including a given priority.
458 * Messages with priority levels that do not have a corresponding bit
459 * set in the filter are not sent to the server, although they will be
460 * sent to any file descripters added with asl_add_log_file().
461 * The default setting is ASL_FILTER_MASK_UPTO(ASL_LEVEL_NOTICE).
462 * Returns the previous filter value.
463 *
464 * @param client
465 * (input) An ASL client handle (asl_object_t of type ASL_TYPE_CLIENT).
466 * @param f
467 * (input) A filter value.
468 * @result Returns the previous filter value.
469 */
470 int asl_set_filter(asl_object_t client, int f) __API_DEPRECATED("os_log(3) has replaced asl(3); see log(1)'s config command", macosx(10.4,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
471
472 /*
473 * Examine attribute keys.
474 *
475 * @param msg
476 * (input) An ASL message or query (asl_object_t of type ASL_TYPE_MSG or ASL_TYPE_QUERY).
477 * @param n
478 * (input) An index value.
479 * @result Returns the key of the nth attribute in a message (beginning at zero),
480 * or NULL if n is greater than the largest message index.
481 */
482 const char *asl_key(asl_object_t msg, uint32_t n) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.4,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
483
484 /*
485 * Examine attribute keys.
486 *
487 * @param msg
488 * (input) An ASL message or query (asl_object_t of type ASL_TYPE_MSG or ASL_TYPE_QUERY).
489 * @param key
490 * (output) key at the given index. May be NULL.
491 * @param val
492 * (output) val at the given index. May be NULL.
493 * @param op
494 * (output) op at the given index. May be NULL.
495 * @param n
496 * (input) An index value.
497 * @result returns 0 for success, non-zero for failure.
498 */
499 int asl_fetch_key_val_op(asl_object_t msg, uint32_t n, const char **key, const char **val, uint32_t *op) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.10,10.12), ios(8.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
500
501 /*!
502 * Create a new log message, query message, message list, or a connection to the system database.
503 *
504 * @param type
505 * (input) ASL_TYPE_MSG, ASL_TYPE_QUERY, ASL_TYPE_LIST, or ASL_TYPE_CLIENT.
506 * @result Returns a newly allocated asl_object_t of the specified type.
507 *
508 * @discussion
509 * New objects of type ASL_TYPE_CLIENT will be created with default settings for
510 * a client connection, equivalent to asl_open(NULL, NULL, 0).
511 * The Sender and Facility values associated with an ASL_TYPE_CLIENT may
512 * be reset using asl_set().
513 */
514 asl_object_t asl_new(uint32_t type) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.4,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
515
516 /*!
517 * Set or re-set a message or query attribute.
518 * May also be used to set values associated with an ASL_TYPE_CLIENT object,
519 * such as Sender and Facility.
520 *
521 * @param obj
522 * (input) An ASL object of type ASL_TYPE_MSG, ASL_TYPE_QUERY, or ASL_TYPE_CLIENT.
523 * @param key
524 * (input) Attribute key.
525 * @param value
526 * (input) Attribute value.
527 * @result returns 0 for success, non-zero for failure.
528 */
529 int asl_set(asl_object_t obj, const char *key, const char *value) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.4,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
530
531 /*!
532 * Remove a key/value attribute.
533 *
534 * @param obj
535 * (input) An ASL object of type ASL_TYPE_MSG, ASL_TYPE_QUERY, or ASL_TYPE_CLIENT.
536 * @param key
537 * (input) Attribute key.
538 * returns 0 for success, non-zero for failure.
539 */
540 int asl_unset(asl_object_t obj, const char *key) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.4,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
541
542 /*!
543 * Get the value associated with an attribute key.
544 *
545 * @param obj
546 * (input) An ASL object of type ASL_TYPE_MSG, ASL_TYPE_QUERY, or ASL_TYPE_CLIENT.
547 * @param key
548 * (input) Attribute key.
549 * @result Returns the attribute value, or NULL if the object does not contain the key.
550 */
551 const char *asl_get(asl_object_t msg, const char *key) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.4,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
552
553 /*!
554 * Log a message with a particular log level.
555 *
556 * @param obj
557 * (input) An asl_object_t or NULL.
558 * @param msg
559 * (input) An asl_object_t of type ASL_TYPE_MSG (default attributes will be supplied if msg is NULL).
560 * @param level
561 * (input) Log level (ASL_LEVEL_DEBUG to ASL_LEVEL_EMERG).
562 * @param format
563 * (input) A printf() - style format string followed by a list of arguments.
564 * @result Returns 0 for success, non-zero for failure.
565 *
566 * @discussion
567 * The input object may be of any type.
568 * In typical usage, obj is of type ASL_TYPE_CLIENT or obj is NULL.
569 * NULL causes the library to use the default ASL client handle.
570 * This routine prepares a message for tranmission to the ASL server daemon (syslogd),
571 * The message is sent to the server subject to filter settings. The message may also
572 * be formatted and printed to various output files.
573 *
574 * For ASL_TYPE_MSG, this routine will set all key/value pairs in the input object as
575 * they would appear if the message were being sent to the server. This includes
576 * setting alues for ASL_KEY_TIME, ASL_KEY_TIME_NSEC, ASL_KEY_HOST, and so on.
577 *
578 * If the object is of type ASL_TYPE_STORE or ASL_TYPE_FILE, a message will be
579 * constructed (as above) and saved in the file or data store. No filtering is done.
580 *
581 * If obj is of type ASL_TYPE_LIST, a message is created and appended to the list.
582 *
583 * The object type ASL_TYPE_QUERY is supported, but the key/value pairs set in the
584 * object will have an operator value of zero.
585 */
586 int asl_log(asl_object_t client, asl_object_t msg, int level, const char *format, ...) __printflike(4, 5) __not_tail_called __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.4,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
587
588 /*!
589 * Log a message with a particular log level.
590 *
591 * This API is a simplified version of asl_log(). It uses the default (NULL) ASL client handle,
592 * and does not have a msg parameter to supply additonal key/value pairs to be attached to the
593 * message sent to the syslogd server.
594 *
595 * @param level
596 * (input) Log level (ASL_LEVEL_DEBUG to ASL_LEVEL_EMERG).
597 * @param format
598 * (input) A printf() - style format string followed by a list of arguments.
599 * @result Returns 0 for success, non-zero for failure.
600 */
601 int asl_log_message(int level, const char *format, ...) __printflike(2, 3) __not_tail_called __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.10,10.12), ios(8.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
602
603 /*!
604 * Log a message with a particular log level.
605 * Similar to asl_log, but takes a va_list argument.
606 *
607 * @param asl
608 * (input) An ASL object or NULL.
609 * @param msg
610 * (input) An asl_object_t of type ASL_TYPE_MSG (default attributes will be supplied if msg is NULL).
611 * @param level
612 * (input) Log level (ASL_LEVEL_DEBUG to ASL_LEVEL_EMERG).
613 * @param format
614 * (input) A printf() - style format string followed by a list of arguments.
615 * @param ap
616 * (input) A va_list containing the values for the format string.
617 * @result Returns 0 for success, non-zero for failure.
618 * @discussion
619 * See the discussion for asl_log() for a description of how this routine treats different
620 * types of input object.
621 *
622 */
623 int asl_vlog(asl_object_t obj, asl_object_t msg, int level, const char *format, va_list ap) __printflike(4, 0) __not_tail_called __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.4,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
624
625 /*!
626 * Log a message.
627 *
628 * This routine may be used instead of asl_log() or asl_vlog() if asl_set()
629 * has been used to set all of a message's attributes.
630 *
631 * @param asl
632 * (input) An ASL object or NULL.
633 * @param msg
634 * (input) An asl_object_t of type ASL_TYPE_MSG.
635 * @result Returns 0 for success, non-zero for failure.
636 * @discussion
637 * See the discussion for asl_log() for a description of how this routine treats different
638 * types of input object.
639 */
640 int asl_send(asl_object_t obj, asl_object_t msg) __not_tail_called __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.4,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
641
642 /*!
643 * DEPRECATED: Free an ASL object and all internal resources associated with it.
644 * This routine is identical to asl_release(), which should be used instead.
645 * Note that we don't issue a deprecation warning - yet.
646 *
647 * @param obj
648 * (input) An ASL object to free.
649 */
650 void asl_free(asl_object_t obj) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.4,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
651
652 /*!
653 * Increment the internal reference count of an ASL object.
654 *
655 * @param obj
656 * (input) An ASL object to retain.
657 * @result Returns the object.
658 */
659 asl_object_t asl_retain(asl_object_t obj) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.10,10.12), ios(8.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
660
661 /*!
662 * Decrement the internal reference count of an ASL object.
663 * Frees the object when the reference count becomes zero.
664 *
665 * @param obj
666 * (input) An ASL object to release.
667 */
668 void asl_release(asl_object_t obj) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.10,10.12), ios(8.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
669
670 /*!
671 * Get the internal type of an ASL object.
672 *
673 * @param obj
674 * (input) An ASL object.
675 * @result Returns the object type.
676 */
677 uint32_t asl_get_type(asl_object_t obj) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.10,10.12), ios(8.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
678
679 /*!
680 * Set arbitrary parameters of a query.
681 * This is similar to asl_set, but allows richer query operations.
682 * See ASL_QUERY_OP_* above.
683 *
684 * @param msg
685 * (input) An ASL object of type ASL_TYPE_QUERY.
686 * @param key
687 * (input) Attribute key
688 * @param value
689 * (input) Attribute value
690 * @param op
691 * (input) An operation (ASL_QUERY_OP_*)
692 * @result Returns 0 for success, non-zero for failure
693 */
694 int asl_set_query(asl_object_t msg, const char *key, const char *value, uint32_t op) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.4,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
695
696 /*!
697 * Search for messages matching the criteria described by an query object.
698 * The caller should set the attributes to match using asl_set_query() or asl_set().
699 * The operation ASL_QUERY_OP_EQUAL is used for attributes set with asl_set().
700 *
701 * @param obj
702 * (input) An ASL object to search.
703 * @param query
704 * (input) An asl_object_t of type ASL_TYPE_QUERY or ASL_TYPE_MSG.
705 * query may be NULL, which matches anything.
706 * @result Returns an ASL object containing messages matching the query, or NULL if there are no matches.
707 *
708 * @discussion
709 * The object to search may be of any type.
710 * ASL_TYPE_CLIENT searches the main ASL database.
711 * ASL_TYPE_STORE searches an ASL database in the filesystem.
712 * ASL_TYPE_FILE searches an ASL data file in the filesystem.
713 * ASL_TYPE_LIST searches for matches in a list of messages.
714 *
715 * A NULL query matches anything.
716 *
717 * If obj is of type ASL_TYPE_MSG and query is of type ASL_TYPE_QUERY, obj is matched against the query,
718 * and a list containing the "obj" object is returned if the match succeeds.
719 *
720 * If both obj and query are objects of type ASL_TYPE_MSG or both are of type ASL_TYPE_QUERY,
721 * they are tested for exact match. A list containing the "obj" object is returned if the match is exact.
722 *
723 * If obj is of type ASL_TYPE_QUERY and query is of type ASL_TYPE_MSG, the routine returns NULL.
724 *
725 */
726 asl_object_t asl_search(asl_object_t obj, asl_object_t query) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.4,10.12), ios(2.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
727
728 /*!
729 * DEPRECATED: Iterate over messages in an asl_object_t (same as an aslresponse).
730 * This routine is identical to asl_next().
731 *
732 * @param list
733 * (input) An asl_object_t (aslresponse).
734 * @result Returns the next message contained in an ASL object, or NULL when there are no more messages.
735 *
736 * @discussion
737 * This routine is deprecated in favor of asl_next().
738 */
739 asl_object_t aslresponse_next(asl_object_t obj) __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_4,__MAC_10_10,__IPHONE_2_0,__IPHONE_7_0, "Use asl_next instead");
740
741 /*!
742 * DEPRECATED: Free an asl_object_t.
743 * This routine is identical to asl_release().
744 *
745 * @param list
746 * (input) An asl_object_t (aslresponse).
747 *
748 * @discussion
749 * This routine is deprecated in favor of asl_release().
750 */
751 void aslresponse_free(asl_object_t obj) __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_4,__MAC_10_10,__IPHONE_2_0,__IPHONE_7_0, "Use asl_release instead");
752
753 /*!
754 * Append messages to an object of type ASL_TYPE_LIST. The input "obj"
755 * parameter may be of type ASL_TYPE_MSG or ASL_TYPE_QUERY, in which case
756 * the object is appended to the list, or "obj" may be of type ASL_TYPE_LIST,
757 * in which case each object in that list is appended to the "list" object.
758 * Does nothing if either list or obj are NULL.
759 *
760 * @param obj
761 * (input) An object of type ASLTYPE_CLIENT or ASL_TYPE_LIST, or an object of type
762 * ASL_TYPE_FILE or ASL_TYPE_STORE that is open for write operations.
763 * @param obj_to_add
764 * (input) An object of type ASL_TYPE_MSG, ASL_TYPE_QUERY or type ASL_TYPE_LIST.
765 */
766 void asl_append(asl_object_t obj, asl_object_t obj_to_add) __not_tail_called __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.10,10.12), ios(8.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
767
768 /*!
769 * Prepend messages to an object of type ASL_TYPE_LIST. The input "obj"
770 * parameter may be of type ASL_TYPE_MSG or ASL_TYPE_QUERY, in which case
771 * the object is prepended to the list, or "obj" may be of type ASL_TYPE_LIST,
772 * in which case each object in that list is prepended to the "list" object.
773 * Does nothing if either list or obj are NULL.
774 *
775 * @param obj
776 * (input) An object of type ASL_TYPE_LIST.
777 * @param obj_to_add
778 * (input) An object of type ASL_TYPE_MSG, ASL_TYPE_QUERY or type ASL_TYPE_LIST.
779 */
780 void asl_prepend(asl_object_t obj, asl_object_t obj_to_add) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.10,10.12), ios(8.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
781
782 /*!
783 * Get the number of key/value pairs in an object of type ASL_TYPE_MSG or ASL_TYPE_QUERY,
784 * or the number of components in an object of type ASL_TYPE_LIST.
785 *
786 * @param obj
787 * (input) An asl_object_t of type ASL_TYPE_MSG, ASL_TYPE_QUERY, or ASL_TYPE_LIST.
788 * @result The number of components in the object.
789 * Returns zero if object is empty or NULL, or if the type is not
790 * ASL_TYPE_MSG, ASL_TYPE_QUERY, or ASL_TYPE_LIST.
791 */
792 size_t asl_count(asl_object_t obj) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.10,10.12), ios(8.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
793
794 /*!
795 * Retreive a message from an object of type ASL_TYPE_LIST.
796 *
797 * @param obj
798 * (input) An asl_object_t of type ASL_TYPE_LIST
799 * @result Returns the message (an object of type ASL_TYPE_MSG or ASL_TYPE_QUERY) at the specified index.
800 * Returns NULL if the index is out of range or if list is not an object of type ASL_TYPE_LIST.
801 */
802 asl_object_t asl_get_index(asl_object_t list, size_t index) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.10,10.12), ios(8.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
803
804 /*!
805 * Remove the message at a specified index from an object of type ASL_TYPE_LIST.
806 *
807 * @param list
808 * (input) An object of type ASL_TYPE_LIST.
809 */
810 void asl_remove_index(asl_object_t list, size_t index) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.10,10.12), ios(8.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
811
812 /*!
813 * Creates an auxiliary file that may be used to save arbitrary data. The ASL message msg
814 * will be saved at the time that the auxiliary file is closed with asl_close_auxiliary_file().
815 * The log entry will include any keys and values found in msg, and it will include the title
816 * and Uniform Type Identifier specified. If NULL is supplied as a value for the uti parameter,
817 * the type "public.data" is used. Console.app will display a hyperlink to the file.
818 * Output parameter out_descriptor will contain a readable and writable file descriptor for the new
819 * auxiliary file.
820 *
821 * By default, the file will be world-readable. If the message contains a ReadUID and/or a
822 * ReadGID key, then the values for those keys will determine read access to the file.
823 *
824 * The file will be deleted at the same time that the message expires from the ASL data store.
825 * The aslmanager utility manages message expiry. If msg contains a value for ASLExpireTime,
826 * then the message and the file will not be deleted before that time. The value may be in
827 * seconds after the Epoch, or it may be ctime() format, e.g "Thu Jun 24 18:22:48 2010".
828 *
829 * @param msg
830 * (input) An object of type ASL_TYPE_MSG.
831 * @param tite
832 * (input) A title string for the file.
833 * @param uti
834 * (input) Uniform Type Identifier for the file.
835 * @param out_descriptor
836 * (output) A writable file descriptor.
837 * @result Returns 0 for success, non-zero for failure
838 */
839 int asl_create_auxiliary_file(asl_object_t msg, const char *title, const char *uti, int *out_descriptor) __API_DEPRECATED("os_log(3) has replaced asl(3); this functionality is no longer supported", macosx(10.7,10.12), ios(5.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
840
841 /*!
842 * Close an auxiliary file opened by asl_create_auxiliary_file() when writing is complete.
843 * syslogd will log the message provided to asl_create_auxiliary_file() when this routine
844 * is called.
845 *
846 * @param descriptor
847 * (input) The file descriptor
848 * @result Returns 0 for success, non-zero for failure
849 */
850 int asl_close_auxiliary_file(int descriptor) __API_DEPRECATED("os_log(3) has replaced asl(3); this functionality is no longer supported", macosx(10.7,10.12), ios(5.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
851
852 /*!
853 * Sends an ASL message to syslogd along with a title string, Uniform Resource Locator,
854 * and Uniform Type Identifier specified. Console.app will hyperlink the title string to
855 * the specified URL. If NULL is supplied as a value for the uti parameter, the default
856 * type "public.data" is used.
857 *
858 * @param msg
859 * (input) An object of type ASL_TYPE_MSG.
860 * @param title
861 * (input) A title string for the file
862 * @param uti
863 * (input) Uniform Type Identifier for the file
864 * @param url
865 * (input) Uniform Type Locator
866 * @result Returns 0 for success, non-zero for failure
867 */
868 int asl_log_auxiliary_location(asl_object_t msg, const char *title, const char *uti, const char *url) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.7,10.12), ios(5.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
869
870 /*!
871 * Creates an object of type ASL_TYPE_CLIENT for logging to a file descriptor.
872 * The file must be opened for read and write access. This routine may be used in conjunction
873 * with asl_create_auxiliary_file() to save ASL format log messages to an auxiliary file.
874 *
875 * When logging to the file is complete, the returned object should be released with asl_release().
876 * The file descriptor should be closed using asl_close_auxiliary_file() if it was returned by
877 * asl_create_auxiliary_file(), or close() otherwise.
878 *
879 * The returned client object is thread-safe. It contains a lock that is aquired by
880 * the calling thread. Note that this may cause unexpected syncronization behavior
881 * if multiple threads log to the returned object, or in applications that use the
882 * object in multiple dispatch queues.
883 *
884 * Note that per-message read access controls (ReadUID and ReadGID) and message expire
885 * times (ASLExpireTime) keys have no effect for messages written to this file.
886 *
887 * Also note that files are NOT truncated. This is a change in OS X 10.9 and iOS 7.0.
888 * Previous versions of this routine truncated the file before writing. Callers
889 * may use ftruncate() to truncate the file if desired. If an existing non-empty
890 * file is used, it must be an ASL format data file.
891 *
892 * @param descriptor
893 * (input) A file descriptor
894 * @param ident
895 * (input) Sender name
896 * @param facility
897 * (input) Facility name
898 * @result An object of type ASL_TYPE_CLIENT.
899 */
900 asl_object_t asl_open_from_file(int descriptor, const char *ident, const char *facility) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.7,10.12), ios(5.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
901
902 /*!
903 * This API provides functionality to use file descriptors to send logging
904 * data to ASL.
905 *
906 * asl is retained by ASL and must still be closed by the caller by calling
907 * asl_close() if the caller loses reference to it. msg is copied by ASL and
908 * similarly must still be freed by the caller by calling asl_free() if the
909 * caller loses reference to it. Any changes made to it after calling
910 * asl_log_descriptor() are not applicable to the message used. descriptor
911 * is treated differently based on the value of fd_type.
912 *
913 * If fd_type is ASL_LOG_DESCRIPTOR_READ, the descriptor must be open for read
914 * access. ASL uses GCD to read from the descriptor as data becomes available.
915 * These data are line buffered and passed to asl_log. When EOF is read, the
916 * descriptor is closed.
917 *
918 * Example:
919 * asl_log_descriptor(c, m, ASL_LEVEL_NOTICE, STDIN_FILENO, ASL_LOG_DESCRIPTOR_READ);
920 *
921 * If fd_type is ASL_LOG_DESCRIPTOR_WRITE, the descriptor is closed and a new
922 * writable descriptor is created with the same fileno. Any data written to
923 * this new descriptor are line buffered and passed to asl_log. When EOF is
924 * sent, no further data are read. The caller is responsible for closing the
925 * new descriptor. One common use for this API is to redirect writes to stdout
926 * or stderr to ASL by passing STDOUT_FILENO or STDERR_FILENO as descriptor.
927 *
928 * Example:
929 * asl_log_descriptor(c, m, ASL_LEVEL_NOTICE, STDOUT_FILENO, ASL_LOG_DESCRIPTOR_WRITE);
930 * asl_log_descriptor(c, m, ASL_LEVEL_ERR, STDERR_FILENO, ASL_LOG_DESCRIPTOR_WRITE);
931 *
932 * @param client
933 * (input) An ASL object of type ASL_TYPE_CLIENT.
934 * @param msg
935 * (input) An asl_object_t of type ASL_TYPE_MSG (default attributes will be supplied if msg is NULL).
936 * @param level
937 * (input) Log level (ASL_LEVEL_DEBUG to ASL_LEVEL_EMERG)
938 * @param descriptor
939 * (input) An open file descriptor to read from
940 * @param fd_type
941 * (input) Either ASL_LOG_DESCRIPTOR_READ or ASL_LOG_DESCRIPTOR_WRITE
942 * @result Returns 0 for success, non-zero for failure
943 */
944 int asl_log_descriptor(asl_object_t asl, asl_object_t msg, int level, int descriptor, uint32_t fd_type) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.8,10.12), ios(5.1,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
945
946 #pragma mark -
947
948
949 /*!
950 * Creates a string representation of an ASL message.
951 *
952 * This utility creates a character string suitable for printing an ASL message.
953 * The returned string ends with a newline character. The caller is responsible
954 * for freeing the returned string.
955 * The message is formatted according to the specified format string. Timestamps
956 * are formatted accoring to the specified time format string. Special characters
957 * are enoded as specified by the text_encoding parameter.
958 *
959 * @param msg
960 * (input) An asl_object_t of type ASL_TYPE_MSG.
961 * @param fmt
962 * (input) A format specification string. See "Output file message and time formats"
963 * for standard formats. See the syslog(1) man page for more discussion on formats.
964 * @param fmt
965 * (input) A time format specification string. See "Output file message and time formats"
966 * for standard formats. See the syslog(1) man page for more discussion on time formats.
967 * @param text_encoding
968 * (input) Text encoding control (for special characters). See "Text Encoding Types".
969 * @result Returns a character string, or NULL in case of a failure.
970 */
971 char *asl_format(asl_object_t msg, const char *msg_fmt, const char *time_fmt, uint32_t text_encoding) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.10,10.12), ios(8.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
972
973 /*!
974 * Encodes a buffer with embedded nul characters into a nul terminated C string.
975 * The result must be freed by the caller.
976 *
977 * This utility is used to encode the value associated with ASL_KEY_AUX_DATA
978 * in an ASL_TYPE_MSG object. An ASL_KEY_AUX_DATA key/value pair is used to hold the
979 * data written to a file descriptor created by asl_create_auxiliary_file on iOS
980 * systems, where the ASL database is stored in memory.
981 *
982 * @param buf
983 * (input) Pointer to a data buffer.
984 * @param len
985 * (input) Length (in octets) of data buffer.
986 * @result Returns an encoded character string.
987 */
988 char *asl_encode_buffer(const char *buf, size_t len) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.10,10.12), ios(8.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
989
990 /*!
991 * Decodes a C string previously created by asl_encode_buffer back into a buffer,
992 * possibly containing embedded nul characters. Allocates memory for the buffer
993 * and returns a pointer in an output parameter "buf".
994 * The caller is responsible for freeing the buffer.
995 *
996 * This routine should be used to decode the value associated with an
997 * ASL_KEY_AUX_DATA key in an ASL_TYPE_MSG object.
998 *
999 * @param in
1000 * (input) Pointer to nul-terminated string created by asl_encode_buffer.
1001 * @param buf
1002 * (output) Pointer to a newly allocated data buffer.
1003 * @param len
1004 * (input) Length (in octets) of data buffer.
1005 * @result Returns 0 on success, non-zero on failure.
1006 */
1007 int asl_decode_buffer(const char *in, char **buf, size_t *len) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.10,10.12), ios(8.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
1008
1009 /*!
1010 * Iterate forward through messages in an asl_object_t.
1011 * The asl_object_t object maintains an internal position index for the underlying
1012 * collection of ASL messages, whether the asl_object_t represents a list, a
1013 * data file, or an ASL database. The position index is moved forward and the
1014 * "next" message is returned.
1015 *
1016 * @param obj
1017 * (input) An asl_object_t.
1018 * @result Returns the next message (an object of type ASL_TYPE_MSG or ASL_TYPE_QUERY) from the object,
1019 * which should be of type ASL_TYPE_CLIENT, ASL_TYPE_LIST, ASL_TYPE_STORE, or ASL_TYPE_FILE.
1020 * Returns NULL when there are no more messages or if obj is not a type that holds messages.
1021 */
1022 asl_object_t asl_next(asl_object_t obj) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.10,10.12), ios(8.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
1023
1024 /*!
1025 * Iterate backwards through messages in an asl_object_t.
1026 * The asl_object_t object maintains an internal position index for the underlying
1027 * collection of ASL messages, whether the asl_object_t represents a list, a
1028 * data file, or an ASL database. The position index is moved backward and the
1029 * "previous" message is returned.
1030 *
1031 * @param data
1032 * (input) An asl_object_t.
1033 * @result Returns the previous message (an object of type ASL_TYPE_MSG or ASL_TYPE_QUERY) from the object,
1034 * which should be of type ASL_TYPE_CLIENT, ASL_TYPE_LIST, ASL_TYPE_STORE, or ASL_TYPE_FILE.
1035 * Returns NULL when there are no more messages or if obj is not a type that holds messages.
1036 */
1037 asl_object_t asl_prev(asl_object_t obj) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.10,10.12), ios(8.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
1038
1039 /*!
1040 * Reset internal interation index in an asl_object_t.
1041 *
1042 * @param obj
1043 * (input) An object of type ASL_TYPE_CLIENT, ASL_TYPE_LIST, ASL_TYPE_STORE, or ASL_TYPE_FILE.
1044 * @param position
1045 * (input) Use 0 to position the internal interation index at the beginning of the asl_object_t object,
1046 * and SIZE_MAX to position it at the end. Other values of position may cause unpredictable behavior.
1047 */
1048 void asl_reset_iteration(asl_object_t obj, size_t position) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.10,10.12), ios(8.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
1049
1050 /*!
1051 * Searches an asl_object_t.
1052 * The search is controlled by a list of queries, and returns a list with matching messages.
1053 * A message is returned if it matches any of the queries in the query list.
1054 * A NULL querylist matches anything.
1055 *
1056 * The caller may provide a starting ASL message ID, a direction, and a count.
1057 * A start ID value of 0 means that matching should commence at the beginning of the target obj.
1058 * A value of SIZE_MAX indicates that matching should commence at the end (most recent message)
1059 * in the target. If a non-zero count value is supplied, the routine will return when it has
1060 * found that many messages, or it has checked all messages. If a non-zero duration is supplied,
1061 * the routine will return after the specified time (in microseconds).
1062 * If both count and duration are non-zero, the routine will return when the desired number of
1063 * items has been matched or when the specified duration has been exceeded, whichever occurs first.
1064 * The search direction may be ASL_MATCH_DIRECTION_FORWARD or ASL_MATCH_DIRECTION_REVERSE.
1065 * The routine sets the value of the out parameter last to be an index of the last message
1066 * checked while matching. To fetch matching messages in batches (using a small count or
1067 * duration value), the start value for each iteration should be set to (last + 1) if searching
1068 * forward, or (last - 1)for reverse search.
1069 *
1070 * @param data
1071 * (input) An asl_object_t object.
1072 * @param querylist
1073 * (input) An asl_object_t object containing zero or more queries.
1074 * @param last
1075 * (output) An internal position index of the last message checked while matching in the asl_object_t object.
1076 * @param start
1077 * (input) A position index specifying where matching should commence.
1078 * @param count
1079 * (input) The maximum number of messages to be returned in the res output list (zero indicates no limit).
1080 * @param duration
1081 * (input) A limit (in microseconds) on the time to be spent searching for results. Zero indicates no time limit.
1082 * @param direction
1083 * (input) ASL_MATCH_DIRECTION_FORWARD or ASL_MATCH_DIRECTION_REVERSE.
1084 * @result Returns an ASL object containing messages matching the querylist, or NULL if there are no matches.
1085 */
1086 asl_object_t asl_match(asl_object_t data, asl_object_t querylist, size_t *last, size_t start, size_t count, uint32_t duration, int32_t direction) __API_DEPRECATED("os_log(3) has replaced asl(3)", macosx(10.10,10.12), ios(8.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0));
1087
1088 __END_DECLS
1089
1090 #endif /* __ASL_H__ */