ia64/xen-unstable

view tools/vtpm_manager/util/log.h @ 6946:e703abaf6e3d

Add behaviour to the remove methods to remove the transaction's path itself. This allows us to write Remove(path) to remove the specified path rather than having to slice the path ourselves.
author emellor@ewan
date Sun Sep 18 14:42:13 2005 +0100 (2005-09-18)
parents 3233e7ecfa9f
children 06d84bf87159
line source
1 // ===================================================================
2 //
3 // Copyright (c) 2005, Intel Corp.
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions
8 // are met:
9 //
10 // * Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 // * Redistributions in binary form must reproduce the above
13 // copyright notice, this list of conditions and the following
14 // disclaimer in the documentation and/or other materials provided
15 // with the distribution.
16 // * Neither the name of Intel Corporation nor the names of its
17 // contributors may be used to endorse or promote products derived
18 // from this software without specific prior written permission.
19 //
20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31 // OF THE POSSIBILITY OF SUCH DAMAGE.
32 // ===================================================================
34 #ifndef __VTPM_LOG_H__
35 #define __VTPM_LOG_H__
37 #include <stdint.h> // for uint32_t
38 #include <stddef.h> // for pointer NULL
40 // =========================== LOGGING ==============================
42 // the logging module numbers
43 #define VTPM_LOG_CRYPTO 1
44 #define VTPM_LOG_BSG 2
45 #define VTPM_LOG_TXDATA 3
46 #define VTPM_LOG_TCS 4
47 #define VTPM_LOG_TCS_DEEP 5
48 #define VTPM_LOG_VTSP 6
49 #define VTPM_LOG_VTPM 7
50 #define VTPM_LOG_VTPM_DEEP 8
52 static char *module_names[] = { "",
53 "CRYPTO",
54 "BSG",
55 "TXDATA",
56 "TCS",
57 "TCS",
58 "VTSP",
59 "VTPM",
60 "VTPM"
61 };
63 // Default to standard logging
64 #ifndef LOGGING_MODULES
65 #define LOGGING_MODULES (BITMASK(VTPM_LOG_VTPM))
66 #endif
68 // bit-access macros
69 #define BITMASK(idx) ( 1U << (idx) )
70 #define GETBIT(num,idx) ( ((num) & BITMASK(idx)) >> idx )
71 #define SETBIT(num,idx) (num) |= BITMASK(idx)
72 #define CLEARBIT(num,idx) (num) &= ( ~ BITMASK(idx) )
74 #define vtpmloginfo(module, fmt, args...) \
75 if (GETBIT (LOGGING_MODULES, module) == 1) { \
76 fprintf (stdout, "INFO[%s]: " fmt, module_names[module], ##args); \
77 }
79 #define vtpmloginfomore(module, fmt, args...) \
80 if (GETBIT (LOGGING_MODULES, module) == 1) { \
81 fprintf (stdout, fmt,##args); \
82 }
84 #define vtpmlogerror(module, fmt, args...) \
85 fprintf (stderr, "ERROR[%s]: " fmt, module_names[module], ##args);
87 //typedef UINT32 tpm_size_t;
89 // helper function for the error codes:
90 const char* tpm_get_error_name (TPM_RESULT code);
92 #endif // _VTPM_LOG_H_