(file) Return to return.h CVS log (file) (dir) Up to [OMI] / omi / base

 1 mike  1.1 /*
 2           **==============================================================================
 3           **
 4           ** Open Management Infrastructure (OMI)
 5           **
 6           ** Copyright (c) Microsoft Corporation
 7           ** 
 8           ** Licensed under the Apache License, Version 2.0 (the "License"); you may not 
 9           ** use this file except in compliance with the License. You may obtain a copy 
10           ** of the License at 
11           **
12           **     http://www.apache.org/licenses/LICENSE-2.0 
13           **
14           ** THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15           ** KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 
16           ** WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 
17           ** MERCHANTABLITY OR NON-INFRINGEMENT. 
18           **
19           ** See the Apache 2 License for the specific language governing permissions 
20           ** and limitations under the License.
21           **
22 mike  1.1 **==============================================================================
23           */
24           
25           #ifndef _omi_return_h
26           #define _omi_return_h
27           
28           #include "config.h"
29           #include <stdio.h>
30           #include <common.h>
31 krisbash 1.3 #include <nits/base/nits.h>
32 mike     1.1 
33              /*
34              **==============================================================================
35              **
36              ** This file defines two tracing macros: 
37              **
38              **     MI_RETURN(EXPR) 
39              **     MI_RETURN_ERR(EXPR)
40              **
41              ** These override the macros with the same names in MI.h and add printf
42              ** tracing on onon-zero MI_Result objects (those not equal to MI_RESULT_OK).
43              ** Functions that use these macros can enable tracing of bad return values
44              ** by simply including this file.
45              **
46              **==============================================================================
47              */
48              
49              #if defined(MI_RETURN)
50              # undef MI_RETURN
51              #endif
52              
53 mike     1.1 #define MI_RETURN(EXPR) \
54                  for (;;) \
55                  { \
56                      MI_Result __r = EXPR; \
57 krisbash 1.3         NitsCompare(__r, MI_RESULT_OK, PAL_T("Failed"));\
58 mike     1.1         return __r; \
59                      break; \
60                  }
61              
62              #if defined(MI_RETURN_ERR)
63              # undef MI_RETURN_ERR
64              #endif
65              
66              #define MI_RETURN_ERR(EXPR) \
67                  for (;;) \
68                  { \
69                      MI_Result r = EXPR; \
70                      if (r != MI_RESULT_OK) \
71                      { \
72 krisbash 1.3             NitsCompare(r, MI_RESULT_OK, PAL_T("Failed")); \
73 mike     1.1             return r; \
74                      } \
75                      break; \
76                  }
77              
78              #endif /* _omi_return_h */

ViewCVS 0.9.2