1/*
2 * Copyright (c) 1999-2008 Apple Computer, 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#include <IOKit/IOKitLib.h>
25#include <IOKit/IOReturn.h>
26#include <stdarg.h>
27#include <asl.h>
28#include "IOHIDLibPrivate.h"
29#include "IOHIDBase.h"
30
31void _IOObjectCFRelease(        CFAllocatorRef          allocator  __unused,
32                                const void *            value)
33{
34    IOObjectRelease((io_object_t)(uintptr_t) value);
35}
36
37const void * _IOObjectCFRetain( CFAllocatorRef          allocator  __unused,
38                                const void *            value)
39{
40    if (kIOReturnSuccess != IOObjectRetain((io_object_t)(uintptr_t)value))
41        return NULL;
42
43    return value;
44}
45
46void _IOHIDCallbackApplier(const void *callback,
47                           const void *callbackContext,
48                           void *applierContext)
49{
50    IOHIDCallbackApplierContext *context = (IOHIDCallbackApplierContext*)applierContext;
51    if (callback && context)
52        ((IOHIDCallback)callback)((void *)callbackContext, context->result, context->sender);
53}
54
55void _IOHIDLog(int level, const char *format, ...)
56{
57    aslmsg msg = NULL;
58
59    if (1) {
60        msg = asl_new(ASL_TYPE_MSG);
61        asl_set(msg, ASL_KEY_FACILITY, "com.apple.iokit.IOHID");
62    }
63    va_list ap;
64    va_start(ap, format);
65    asl_vlog(NULL, msg, level, format, ap);
66    va_end(ap);
67    if (msg) {
68        asl_free(msg);
69    }
70}
71