]>
git.saurik.com Git - apple/hfs.git/blob - fsck_hfs/fsck_debug.c
2 * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
25 #include "fsck_debug.h"
28 /* Current debug level of fsck_hfs for printing messages via DPRINTF */
29 unsigned long cur_debug_level
;
33 * Description: Debug function similar to printf except the first parameter
34 * which indicates the type of message to be printed by DPRINTF. Based on
35 * current debug level and the type of message, the function decides
36 * whether to print the message or not.
38 * Each unique message type has a bit assigned to it. The message type
39 * passed to DPRINTF can be one or combination (OR-ed value) of pre-defined
40 * debug message types. Only the messages whose type have one or more similar
41 * bits set in comparison with current global debug level are printed.
43 * For example, if cur_debug_level = 0x11 (d_info|d_xattr)
44 * ----------------------------------------
45 * message type - printed/not printed
46 * ----------------------------------------
48 * d_error|d_xattr - printed
49 * d_error - not printed
50 * d_overlap - not printed
53 * message_type - type of message, to determine when to print the message
54 * variable arguments - similar to printfs
59 void DPRINTF (unsigned long type
, char *fmt
, ...)
61 if (cur_debug_level
& type
) {
71 void HexDump(const void *p_arg
, unsigned length
, int showOffsets
)
73 const u_int8_t
*p
= p_arg
;
80 for (i
=0; i
<length
; ++i
)
82 if (showOffsets
&& (i
& 0xF) == 0)
87 if (byte
< 32 || byte
> 126)
90 ascii
[i
& 0xF] = byte
;
101 for (j
= i
& 0xF; j
< 16; ++j
)
104 plog(" %s\n", ascii
);