VirtualBox

source: kStuff/trunk/kRdr/kRdrInternal.h

Last change on this file was 29, checked in by bird, 15 years ago

Finally got around execute the switch to the MIT license.

  • Property svn:keywords set to Id Revision
File size: 4.2 KB
Line 
1/* $Id: kRdrInternal.h 29 2009-07-01 20:30:29Z bird $ */
2/** @file
3 * kRdr - Internal Header.
4 */
5
6/*
7 * Copyright (c) 2006-2007 Knut St. Osmundsen <bird-kStuff-spamix@anduin.net>
8 *
9 * Permission is hereby granted, free of charge, to any person
10 * obtaining a copy of this software and associated documentation
11 * files (the "Software"), to deal in the Software without
12 * restriction, including without limitation the rights to use,
13 * copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following
16 * conditions:
17 *
18 * The above copyright notice and this permission notice shall be
19 * included in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 * OTHER DEALINGS IN THE SOFTWARE.
29 */
30
31#ifndef ___kRdrInternal_h___
32#define ___kRdrInternal_h___
33
34#include <k/kHlpAssert.h>
35#include <k/kMagics.h>
36#include <k/kRdrAll.h>
37#include <k/kErrors.h>
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
43/** @defgroup grp_kRdrInternal - Internals
44 * @internal
45 * @addtogroup grp_kRdr
46 * @{
47 */
48
49/** @def KRDR_STRICT
50 * If defined the kRdr assertions and other runtime checks will be enabled. */
51#ifdef K_ALL_STRICT
52# undef KRDR_STRICT
53# define KRDR_STRICT
54#endif
55
56/** @name Our Assert macros
57 * @{ */
58#ifdef KRDR_STRICT
59# define kRdrAssert(expr) kHlpAssert(expr)
60# define kRdrAssertReturn(expr, rcRet) kHlpAssertReturn(expr, rcRet)
61# define kRdrAssertMsg(expr, msg) kHlpAssertMsg(expr, msg)
62# define kRdrAssertMsgReturn(expr, msg, rcRet) kHlpAssertMsgReturn(expr, msg, rcRet)
63#else /* !KRDR_STRICT */
64# define kRdrAssert(expr) do { } while (0)
65# define kRdrAssertReturn(expr, rcRet) do { if (!(expr)) return (rcRet); } while (0)
66# define kRdrAssertMsg(expr, msg) do { } while (0)
67# define kRdrAssertMsgReturn(expr, msg, rcRet) do { if (!(expr)) return (rcRet); } while (0)
68#endif /* !KRDR_STRICT */
69
70#define kRdrAssertPtr(ptr) kRdrAssertMsg(K_VALID_PTR(ptr), ("%s = %p\n", #ptr, (ptr)))
71#define kRdrAssertPtrReturn(ptr, rcRet) kRdrAssertMsgReturn(K_VALID_PTR(ptr), ("%s = %p -> %d\n", #ptr, (ptr), (rcRet)), (rcRet))
72#define kRdrAssertPtrNull(ptr) kRdrAssertMsg(!(ptr) || K_VALID_PTR(ptr), ("%s = %p\n", #ptr, (ptr)))
73#define kRdrAssertPtrNullReturn(ptr, rcRet) kRdrAssertMsgReturn(!(ptr) || K_VALID_PTR(ptr), ("%s = %p -> %d\n", #ptr, (ptr), (rcRet)), (rcRet))
74#define kRdrAssertRC(rc) kRdrAssertMsg((rc) == 0, ("%s = %d\n", #rc, (rc)))
75#define kRdrAssertRCReturn(rc, rcRet) kRdrAssertMsgReturn((rc) == 0, ("%s = %d -> %d\n", #rc, (rc), (rcRet)), (rcRet))
76#define kRdrAssertFailed() kRdrAssert(0)
77#define kRdrAssertFailedReturn(rcRet) kRdrAssertReturn(0, (rcRet))
78#define kRdrAssertMsgFailed(msg) kRdrAssertMsg(0, msg)
79#define kRdrAssertMsgFailedReturn(msg, rcRet) kRdrAssertMsgReturn(0, msg, (rcRet))
80/** @} */
81
82/** Return / crash validation of a reader argument. */
83#define KRDR_VALIDATE_EX(pRdr, rc) \
84 do { \
85 if ( (pRdr)->u32Magic != KRDR_MAGIC \
86 || (pRdr)->pOps == NULL \
87 )\
88 { \
89 return (rc); \
90 } \
91 } while (0)
92
93/** Return / crash validation of a reader argument. */
94#define KRDR_VALIDATE(pRdr) \
95 KRDR_VALIDATE_EX(pRdr, KERR_INVALID_PARAMETER)
96
97/** Return / crash validation of a reader argument. */
98#define KRDR_VALIDATE_VOID(pRdr) \
99 do { \
100 if ( !K_VALID_PTR(pRdr) \
101 || (pRdr)->u32Magic != KRDR_MAGIC \
102 || (pRdr)->pOps == NULL \
103 )\
104 { \
105 return; \
106 } \
107 } while (0)
108
109
110/** @name Built-in Providers
111 * @{ */
112extern const KRDROPS g_kRdrFileOps;
113/** @} */
114
115/** @} */
116
117#ifdef __cplusplus
118}
119#endif
120
121#endif
122
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette