1/* 2 * Copyright (c) 2009-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_MSG_H__ 25#define __ASL_MSG_H__ 26 27#include <stdint.h> 28#include <asl_core.h> 29#include <asl_private.h> 30 31#define IndexNull ((uint32_t)-1) 32 33#define ASL_MSG_PAGE_DATA_SIZE 800 34#define ASL_MSG_PAGE_SLOTS 24 35 36#define ASL_MSG_OFFSET_MASK 0x3fff 37#define ASL_MSG_KV_MASK 0xc000 38#define ASL_MSG_KV_INLINE 0x0000 39#define ASL_MSG_KV_DICT 0x8000 40#define ASL_MSG_KV_EXTERN 0x4000 41 42#define ASL_MSG_SLOT_FREE 0xffff 43 44#define ASL_STD_KEY_BASE 0x8000 45#define ASL_STD_KEY_TIME 0x8001 46#define ASL_STD_KEY_NANO 0x8002 47#define ASL_STD_KEY_HOST 0x8003 48#define ASL_STD_KEY_SENDER 0x8004 49#define ASL_STD_KEY_FACILITY 0x8005 50#define ASL_STD_KEY_PID 0x8006 51#define ASL_STD_KEY_UID 0x8007 52#define ASL_STD_KEY_GID 0x8008 53#define ASL_STD_KEY_LEVEL 0x8009 54#define ASL_STD_KEY_MESSAGE 0x800a 55#define ASL_STD_KEY_READ_UID 0x800b 56#define ASL_STD_KEY_READ_GID 0x800c 57#define ASL_STD_KEY_SESSION 0x800d 58#define ASL_STD_KEY_REF_PID 0x800e 59#define ASL_STD_KEY_REF_PROC 0x800f 60#define ASL_STD_KEY_MSG_ID 0x8010 61#define ASL_STD_KEY_EXPIRE 0x8011 62#define ASL_STD_KEY_OPTION 0x8012 63#define ASL_STD_KEY_LAST ASL_STD_KEY_OPTION 64 65#define ASL_MT_KEY_BASE 0x8100 66#define ASL_MT_KEY_DOMAIN 0x8101 67#define ASL_MT_KEY_SCOPE 0x8102 68#define ASL_MT_KEY_RESULT 0x8103 69#define ASL_MT_KEY_SIG 0x8104 70#define ASL_MT_KEY_SIG2 0x8105 71#define ASL_MT_KEY_SIG3 0x8106 72#define ASL_MT_KEY_SUCCESS 0x8107 73#define ASL_MT_KEY_UUID 0x8108 74#define ASL_MT_KEY_VAL 0x8109 75#define ASL_MT_KEY_VAL2 0x810a 76#define ASL_MT_KEY_VAL3 0x810b 77#define ASL_MT_KEY_VAL4 0x810c 78#define ASL_MT_KEY_VAL5 0x810d 79#define ASL_MT_KEY_LAST ASL_MT_KEY_VAL5 80 81#define ASL_PRIVATE_KEY_BASE 0x8200 82 83typedef struct asl_msg_s 84{ 85 uint32_t type; 86 int32_t refcount; 87 uint32_t count; 88 uint32_t data_size; 89 struct asl_msg_s *next; 90 uint16_t key[ASL_MSG_PAGE_SLOTS]; 91 uint16_t val[ASL_MSG_PAGE_SLOTS]; 92 uint32_t op[ASL_MSG_PAGE_SLOTS]; 93 char data[ASL_MSG_PAGE_DATA_SIZE]; 94} asl_msg_t; 95 96typedef struct __aslresponse 97{ 98 uint32_t count; 99 uint32_t curr; 100 asl_msg_t **msg; 101} asl_msg_list_t; 102 103#define asl_search_result_t asl_msg_list_t 104 105asl_msg_t *asl_msg_new(uint32_t type) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); 106asl_msg_t *asl_msg_retain(asl_msg_t *msg) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); 107void asl_msg_release(asl_msg_t *msg) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); 108 109int asl_msg_set_key_val(asl_msg_t *msg, const char *key, const char *val) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); 110int asl_msg_set_key_val_op(asl_msg_t *msg, const char *key, const char *val, uint32_t op) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); 111void asl_msg_unset(asl_msg_t *msg, const char *key) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); 112 113asl_msg_t *asl_msg_copy(asl_msg_t *msg) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_1); 114asl_msg_t *asl_msg_merge(asl_msg_t *target, asl_msg_t *msg) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_1); 115 116int asl_msg_lookup(asl_msg_t *msg, const char *key, const char **valout, uint32_t *opout) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); 117uint32_t asl_msg_fetch(asl_msg_t *msg, uint32_t n, const char **keyout, const char **valout, uint32_t *opout) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); 118 119uint32_t asl_msg_type(asl_msg_t *msg) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); 120uint32_t asl_msg_count(asl_msg_t *msg) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); 121 122char *asl_msg_to_string(asl_msg_t *in, uint32_t *len) __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0); 123char *asl_list_to_string(asl_search_result_t *, uint32_t *) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); 124asl_search_result_t *asl_list_from_string(const char *buf) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); 125 126char *asl_format_message(asl_msg_t *msg, const char *msg_fmt, const char *time_fmt, uint32_t text_encoding, uint32_t *outlen) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); 127 128asl_string_t *asl_msg_to_string_raw(uint32_t encoding, asl_msg_t *msg, const char *tfmt) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_1); 129 130#endif /* __ASL_MSG_H__ */ 131