home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / warphead.zip / H / ERRORRPT.H < prev    next >
C/C++ Source or Header  |  1997-02-28  |  10KB  |  274 lines

  1. /* @(#)Z 1.6 com/src/cm/ErrorRpt.h, odstorage, od96os2, odos29646d 96/11/15 15:27:04 (96/10/29 09:18:11) */
  2. /*====START_GENERATED_PROLOG======================================
  3.  */
  4. /*
  5.  *   COMPONENT_NAME: odstorage
  6.  *
  7.  *   CLASSES: none
  8.  *
  9.  *   ORIGINS: 82,27
  10.  *
  11.  *
  12.  *   (C) COPYRIGHT International Business Machines Corp. 1995,1996
  13.  *   All Rights Reserved
  14.  *   Licensed Materials - Property of IBM
  15.  *   US Government Users Restricted Rights - Use, duplication or
  16.  *   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  17.  *
  18.  *   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  19.  *   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  20.  *   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  21.  *   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  22.  *   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  23.  *   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
  24.  *   OR PERFORMANCE OF THIS SOFTWARE.
  25.  */
  26. /*====END_GENERATED_PROLOG========================================
  27.  */
  28.  
  29. /*
  30.     File:        ErrorRpt.h
  31.  
  32.     Contains:    Container Manager Error Reporting Interfaces
  33.  
  34.     Written by:    Ira L. Ruben
  35.  
  36.     Owned by:    Ed Lai
  37.  
  38.     Copyright:    ⌐ 1991-1994 by Apple Computer, Inc., all rights reserved.
  39.  
  40.     Change History (most recent first):
  41.  
  42.          <2>     8/26/94    EL        #1181622 Ownership update.
  43.          <2>      5/9/94    MB        #1162181: Changes necessary to install MMM.
  44.          <1>      2/3/94    EL        first checked in
  45.  
  46.     To Do:
  47. */
  48.  
  49. /*---------------------------------------------------------------------------*
  50.  |                                                                           |
  51.  |                         <<<    ErrorRpt.h    >>>                          |
  52.  |                                                                           |
  53.  |                Container Manager Error Reporting Interfaces               |
  54.  |                                                                           |
  55.  |                               Ira L. Ruben                                |
  56.  |                                 12/06/91                                  |
  57.  |                                                                           |
  58.  |                  Copyright Apple Computer, Inc. 1991-1994                 |
  59.  |                           All rights reserved.                            |
  60.  |                                                                           |
  61.  *---------------------------------------------------------------------------*
  62.  
  63.  This file defines the stuff the Container Manager itself needs to report errors to the
  64.  user defined error handler.  The user never sees this stuff. The error reporting routines
  65.  defined in     CMErrOps.c      are provided as a convenience to allow the user to
  66.  convert error codes that we report to their corresponding messages.  The user need not
  67.  use them however.
  68. */
  69.  
  70. #ifndef __ERRORRPT__
  71. #define __ERRORRPT__
  72.  
  73. #ifndef __CMTYPES__
  74. #include "CMTypes.h"
  75. #endif
  76. #ifndef __CM_API_TYPES__
  77. #include "CMAPITyp.h"
  78. #endif
  79. #ifndef __CM_API_ERRNO__
  80. #include "CMAPIErr.h"            /* internally we always use    ErrorRpt.h    to get this    */
  81. #endif
  82. #ifndef __TOCENTRIES__
  83. #include "TOCEnts.h"   
  84. #endif
  85. #ifndef __TOCOBJECTS__
  86. #include "TOCObjs.h"   
  87. #endif
  88. #ifndef __CONTAINEROPS__
  89. #include "Containr.h"  
  90. #endif
  91. #ifndef __SESSIONDATA__
  92. #include "Session.h"          
  93. #endif
  94.  
  95.  
  96. /* To make it easier and more readable for the Container Manager to call the error             */
  97. /* reporter (whose pointer is in the session global data), the following macros are         */
  98. /* defined.  They take 0 to 5 inserts.  They all assume that the current container             */
  99. /* pointer is always contained in the variable named "container".                                                */
  100.  
  101. #define ERROR(n) \
  102.     {if(SESSION->cmReportError) \
  103.        { \
  104.         (*SESSION->cmReportError)((CMErrorNbr)(n)); \
  105.        } \
  106.     }
  107.  
  108.  
  109. #define ERROR1(n,i1) \
  110.     {if (SESSION->cmReportError) \
  111.      { \
  112.       (*SESSION->cmReportError)((CMErrorNbr)(n),(char *)(i1)); \
  113.      } \
  114.     } 
  115.  
  116.  
  117. #define ERROR2(n, i1, i2)  \
  118.     {if(SESSION->cmReportError)  \
  119.         { \
  120.           (*SESSION->cmReportError)((CMErrorNbr)(n), (char *)(i1), (char *)(i2)); \
  121.         }  \
  122.     }
  123.  
  124.  
  125. #define ERROR3(n, i1, i2, i3)  \
  126.     {if(SESSION->cmReportError)  \
  127.        { \
  128.          (*SESSION->cmReportError)((CMErrorNbr)(n), (char *)(i1), (char *)(i2), (char *)(i3)); \
  129.        } \
  130.     }
  131.  
  132.  
  133. #define ERROR4(n, i1, i2, i3, i4) \
  134.     {if(SESSION->cmReportError)  \
  135.        {  \
  136.           (*SESSION->cmReportError)((CMErrorNbr)(n),(char *)(i1), (char *)(i2),    (char *)(i3), (char *)(i4)); \
  137.        } \
  138.     }
  139.  
  140.  
  141. #define ERROR5(n, i1, i2, i3, i4, i5) \
  142.    {if(SESSION->cmReportError)  \
  143.       { \
  144.         (*SESSION->cmReportError)((CMErrorNbr)(n), (char *)(i1), (char *)(i2), (char *)(i3), (char *)(i4), (char *)(i5)); \
  145.       } \
  146.    }
  147.  
  148.  
  149. /* The following are the "moral equivalent" of the above, but access the error reporter    */
  150. /* directly through the session global data pointer. Just as the above assumed                    */
  151. /* "container" as the container pointer, here we assume "sessionData" is the session        */
  152. /* data pointer.  It is used by the macro SessionError defined in the header                        */
  153. /*      Session.h      which was included above.                                                                                */
  154.  
  155. #define SessionERROR(n) \
  156.     {if(SessionError) \
  157.        { \
  158.          SessionError((CMErrorNbr)(n)); \
  159.        } \
  160.     }
  161.  
  162.  
  163. #define SessionERROR1(n, i1)  \
  164.    {if(SessionError)  \
  165.        {  \
  166.           SessionError((CMErrorNbr)(n), (char *)(i1)); \
  167.        } \
  168.    }
  169.  
  170.  
  171. #define SessionERROR2(n, i1, i2) \
  172.   {if(SessionError)  \
  173.      {  \
  174.         SessionError((CMErrorNbr)(n), (char *)(i1), (char *)(i2));  \
  175.      } \
  176.   }
  177.  
  178.  
  179. #define SessionERROR3(n, i1, i2, i3) \
  180.     {if(SessionError) \
  181.        {  \
  182.           SessionError((CMErrorNbr)(n), (char *)(i1), (char *)(i2),    (char *)(i3)); \
  183.        } \
  184.     }
  185.  
  186.  
  187. #define SessionERROR4(n, i1, i2, i3, i4) \
  188.     {if(SessionError)  \
  189.        {  \
  190.           SessionError((CMErrorNbr)(n),    (char *)(i1), (char *)(i2), (char *)(i3), (char *)(i4));  \
  191.        }  \
  192.     }
  193.  
  194.  
  195.  
  196. #define SessionERROR5(n, i1, i2, i3, i4, i5) \
  197.     {if(SessionError)  \
  198.        {  \
  199.           SessionError((CMErrorNbr)(n), (char *)(i1), (char *)(i2), (char *)(i3), (char *)(i4), (char *)(i5));  \
  200.        } \
  201.     }
  202.  
  203.  
  204. /* As a "safety valve" to try to protect the Container Manager, the following macro is     */
  205. /* called by every routine (possibly indirectly through the validate routines described    */
  206. /* later).  It effectively turns a routine into a "nop" (no operation) if                             */
  207. /* CMStartSession() was not called.  This is all we can do.  Without the error routine     */
  208. /* which is defined by CMStartSession() how do we tell the user anyway else?  Since         */
  209. /* this macro can be placed in functions that return a value, the macro parameter is         */
  210. /* used on the generated return statement.  The parameter must be the macro CM_NOVALUE     */
  211. /* when no value is to be returned.  This gets round the preprocessor's insistance on     */
  212. /* requiring an explicit macro parameter to a definition that has one!                                    */
  213.  
  214. #if CMVALIDATE
  215. #define NOPifNotInitialized(x) if (container == NULL || SESSION == NULL) return x
  216. #else
  217. #define NOPifNotInitialized(x)
  218. #endif
  219.  
  220. #define CM_NOVALUE                     /* NOPifNotInitialized(CM_NOVALUE) for functs with no value */
  221.  
  222. /* Note, the above macro assumes the standard convent we use everywhere in the Container*/
  223. /* Manager.  Namely, that the container refNum is always loaded into the variable                */
  224. /* "container".                                                                                                                                                    */
  225.  
  226. /* Caution -- the above test is NOT perfect!  If CMStartSession() is not called, the         */
  227. /* odds are that CMOpen[New]Container() will most likely blow.  They test for                     */
  228. /* CMStartSession() by checking the global data session pointer for NULL.  We also do     */
  229. /* that here as an added test.  If the user's session data pointer is indeed NULL, the     */
  230. /* open routines will return NULL for the container refNum.  Then we're safe!                        */
  231.  
  232.  
  233. /* The following are similar to NOPifNotInitialized(x) but are used to exit if we detect*/
  234. /* a bad object, property, type, or value.  The "x" has the same meaning as above.            */
  235.  
  236. #if CMVALIDATE
  237. #define ExitIfBadObject(o, x)     if (!cmValidateCMObject((CMObject)(o))) return x
  238. #define ExitIfBadProperty(p, x) if (!cmValidateCMProperty((CMObject)(p))) return x
  239. #define ExitIfBadType(t, x)         if (!cmValidateCMType((CMObject)(t))) return x
  240. #define ExitIfBadValue(v, x)       if (!cmValidateCMValue((CMValue)(v))) return x
  241. #else
  242. #define ExitIfBadObject(o, x)
  243. #define ExitIfBadProperty(p, x)
  244. #define ExitIfBadType(t, x)
  245. #define ExitIfBadValue(v, x)
  246. #endif
  247.  
  248. /* Note, that a NOPifNotInitialized() is implicit in these "ExitIfBad..." calls.  So         */
  249. /* NOPifNotInitialized() does not need to be used if there is at least one "                        */
  250. /* "ExitIfBad..." call.                                                                                                                                    */
  251.  
  252.  
  253. /* The following macros are used to get the container type name passed when the                    */
  254. /* container was opened.  This may be used for error message inserts.  See the comments    */
  255. /* for CMReturnContainerName() below for additional info on this.   These macros, like     */
  256. /* the ERRORn() macros always assume that the container pointer is in a variable named     */
  257. /* "container".  A more general TYPENAMEx is also provided where you do supply the             */
  258. /* container pointer.                                                                                                                                        */
  259.  
  260. #define TYPENAME      TYPENAMEx(container)
  261. #define TYPENAMEx(container) ((char *)(((ContainerPtr)container)->metaHandlerProc->typeName))
  262.  
  263.  
  264. /* The following macros are the counterparts to TYPENAME and TYPENAMEx above.  But here */
  265. /* the macros expand to calls to CMReturnContainerName() (which, by the way, is a                */
  266. /* handler macro defined in Handlers.h).  These are the ones that should be used for         */
  267. /* error inserts.  The TYPENAME and TYPENAMEx macros are actually only used by                     */
  268. /* CMReturnContainerName() when no name handler is provided.                                                        */
  269.     
  270. #define CONTAINERNAME        CONTAINERNAMEx(container)
  271. #define CONTAINERNAMEx(container)    ((char *)CMReturnContainerName((CMContainer)container))
  272.  
  273. #endif
  274.