XBinder  Version 2.8.x
rtxError.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2003-2022 Objective Systems, Inc.
3  *
4  * This software is furnished under a license and may be used and copied
5  * only in accordance with the terms of such license and with the
6  * inclusion of the above copyright notice. This software or any other
7  * copies thereof may not be provided or otherwise made available to any
8  * other person. No title to and ownership of the software is hereby
9  * transferred.
10  *
11  * The information in this software is subject to change without notice
12  * and should not be construed as a commitment by Objective Systems, Inc.
13  *
14  * PROPRIETARY NOTICE
15  *
16  * This software is an unpublished work subject to a confidentiality agreement
17  * and is protected by copyright and trade secret law. Unauthorized copying,
18  * redistribution or other use of this work is prohibited.
19  *
20  * The above notice of copyright on this source code product does not indicate
21  * any actual or intended publication of such source code.
22  *
23  *****************************************************************************/
28 #ifndef __RTXERROR_H__
29 #define __RTXERROR_H__
30 
31 #include "rtxsrc/rtxContext.h"
32 #include "rtxsrc/rtxErrCodes.h"
33 
34 /* errno.h is supported on both windows and UNIX, though the values in UNIX
35  * systems are usually extended. The VC++ compiler has its own thread-safe
36  * version when building the DLLs, so we avoid defining errno in this case;
37  * see http://cygwin.com/ml/pthreads-win32/2001/msg00047.html; also, WinCE
38  * has its own version, apparently. */
39 #if !defined(_DLL) && !defined(_MT) && !defined(_WIN32_WCE)
40 #include <errno.h>
41 /* extern int errno; //okay for older UNIXes but not for newer */
42 #endif
43 
44 /* Define a cross-platform way to get the error number. */
45 #if defined(_WIN32) || defined(_WIN64)
46 #define ERRNO WSAGetLastError()
47 #elif !defined (_WIN32_WCE)
48 #define ERRNO errno
49 #else
50 #define ERRNO -1 /* must be an int */
51 #endif
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 /* Error handling */
58 
76 #ifndef _COMPACT
77 
78 #ifndef __MODULE__
79 #define LOG_RTERR(pctxt,stat) \
80 rtxErrSetData(pctxt,stat,__FILE__,__LINE__)
81 
82 #define LOG_RTERRNEW(pctxt,stat) \
83 rtxErrSetNewData(pctxt,stat,__FILE__,__LINE__)
84 
85 #else /* Should significantly decrease use of RAM in ARM systems */
86 #define LOG_RTERR(pctxt,stat) \
87 rtxErrSetData(pctxt,stat,__MODULE__,__LINE__)
88 
89 #define LOG_RTERRNEW(pctxt,stat) \
90 rtxErrSetNewData(pctxt,stat,__MODULE__,__LINE__)
91 #endif /* not defined __MODULE__ */
92 
93 #define RETURN_RTERR(pctxt, stat) \
94 return LOG_RTERR(pctxt, stat)
95 
104 #define OSRTASSERT(condition) \
105 if (!(condition)) { rtxErrAssertionFailed(#condition,__LINE__,__FILE__); }
106 
113 #define OSRTCHECKPARAM(condition) if (condition) { /* do nothing */ }
114 #else
115 #define LOG_RTERR(pctxt,stat) \
116 rtxErrSetData(pctxt,stat,0,0)
117 
118 #define LOG_RTERRNEW(pctxt,stat) \
119 rtxErrSetNewData(pctxt,stat,0,0)
120 
121 #define RETURN_RTERR(pctxt, stat) return stat
122 
123 #define OSRTASSERT(condition)
124 #define OSRTCHECKPARAM(condition)
125 #endif /* _COMPACT */
126 
127 #define LOG_RTERR1(pctxt,stat,a) \
128 (a,LOG_RTERR (pctxt, stat),stat)
129 
130 #define LOG_RTERRNEW1(pctxt,stat,a) \
131 (a,LOG_RTERRNEW (pctxt, stat),stat)
132 
133 #define LOG_RTERR2(pctxt,stat,a,b) \
134 (a,b,LOG_RTERR (pctxt, stat),stat)
135 
136 #define LOG_RTERRNEW2(pctxt,stat,a,b) \
137 (a,b,LOG_RTERRNEW (pctxt, stat),stat)
138 
149 #define LOG_RTERR_AND_FREE_MEM(ctxt_p,stat,mem_p) \
150 rtxMemFreePtr ((ctxt_p),(mem_p)), LOG_RTERR(ctxt_p, stat)
151 
152 typedef int (*OSErrCbFunc) (const char* ptext, void* cbArg_p);
153 
163 EXTERNRT OSBOOL rtxErrAddCtxtBufParm (OSCTXT* pctxt);
164 
174 EXTERNRT OSBOOL rtxErrAddDoubleParm (OSCTXT* pctxt, double errParm);
175 
188 EXTERNRT OSBOOL rtxErrAddErrorTableEntry
189 #if !defined(_ARMTCC) && !defined(__SYMBIAN32__)
190 (const char* const* ppStatusText, OSINT32 minErrCode, OSINT32 maxErrCode);
191 #else
192 (OSVOIDARG);
193 #endif
194 
205 EXTERNRT OSBOOL rtxErrAddElemNameParm (OSCTXT* pctxt);
206 
219 EXTERNRT OSBOOL rtxErrAddIntParm (OSCTXT* pctxt, int errParm);
220 
221 #if !defined(_NO_INT64_SUPPORT)
222 
235 EXTERNRT OSBOOL rtxErrAddInt64Parm (OSCTXT* pctxt, OSINT64 errParm);
236 #endif /* !defined(_NO_INT64_SUPPORT) */
237 
250 EXTERNRT OSBOOL rtxErrAddSizeParm (OSCTXT* pctxt, OSSIZE errParm);
251 
261 EXTERNRT OSBOOL rtxErrAddStrParm (OSCTXT* pctxt, const char* pErrParm);
262 
273 EXTERNRT OSBOOL rtxErrAddStrnParm
274  (OSCTXT* pctxt, const char* pErrParm, OSSIZE nchars);
275 
285 EXTERNRT OSBOOL rtxErrAddUIntParm (OSCTXT* pctxt, unsigned int errParm);
286 
287 #if !defined(_NO_INT64_SUPPORT)
288 
297 EXTERNRT OSBOOL rtxErrAddUInt64Parm (OSCTXT* pctxt, OSUINT64 errParm);
298 #endif /* !defined(_NO_INT64_SUPPORT) */
299 
310 EXTERNRT void rtxErrAssertionFailed
311 (const char* conditionText, int lineNo, const char* fileName);
312 
322 EXTERNRT const char* rtxErrFmtMsg
323 (OSRTErrInfo* pErrInfo, char* bufp, OSSIZE bufsiz);
324 
332 EXTERNRT void rtxErrFreeParms (OSCTXT* pctxt);
333 
355 EXTERNRT char* rtxErrGetText (OSCTXT* pctxt, char* pBuf, OSSIZE* pBufSize);
356 
366 EXTERNRT char* rtxErrGetTextBuf (OSCTXT* pctxt, char* pbuf, OSSIZE bufsiz);
367 
380 EXTERNRT char* rtxErrGetMsgText (OSCTXT* pctxt);
381 
393 EXTERNRT char* rtxErrGetMsgTextBuf (OSCTXT* pctxt, char* pbuf, OSSIZE bufsiz);
394 
405 EXTERNRT OSRTErrInfo* rtxErrNewNode (OSCTXT* pctxt);
406 
413 EXTERNRT void rtxErrInit (OSVOIDARG);
414 
422 EXTERNRT int rtxErrReset (OSCTXT* pctxt);
423 
433 EXTERNRT int rtxErrResetErrInfo (OSCTXT* pctxt);
434 
456 EXTERNRT void rtxErrLogUsingCB (OSCTXT* pctxt, OSErrCbFunc cb, void* cbArg_p);
457 
465 EXTERNRT void rtxErrPrint (OSCTXT* pctxt);
466 
474 EXTERNRT void rtxErrPrintElement (OSRTErrInfo* pErrInfo);
475 
489 EXTERNRT int rtxErrSetData (OSCTXT* pctxt, int status,
490  const char* module, int lineno);
491 
503 EXTERNRT int rtxErrSetNewData (OSCTXT* pctxt, int status,
504  const char* module, int lineno);
505 
513 EXTERNRT void rtxErrSetNonFatal(OSCTXT* pctxt);
514 
521 EXTERNRT int rtxErrGetFirstError (const OSCTXT* pctxt);
522 
529 EXTERNRT int rtxErrGetLastError (const OSCTXT* pctxt);
530 
538 EXTERNRT OSSIZE rtxErrGetErrorCnt (const OSCTXT* pctxt);
539 
551 EXTERNRT int rtxErrGetStatus (const OSCTXT* pctxt);
552 
563 EXTERNRT int rtxErrResetLastErrors (OSCTXT* pctxt, OSSIZE errorsToReset);
564 
578 EXTERNRT int rtxErrCopy (OSCTXT* pDestCtxt, const OSCTXT* pSrcCtxt);
579 
593 EXTERNRT int rtxErrAppend (OSCTXT* pDestCtxt, const OSCTXT* pSrcCtxt);
594 
602 EXTERNRT int rtxErrInvUIntOpt (OSCTXT* pctxt, OSUINT32 ident);
603 
608 #ifdef __cplusplus
609 }
610 #endif
611 
612 #endif
EXTERNRT void rtxErrLogUsingCB(OSCTXT *pctxt, OSErrCbFunc cb, void *cbArg_p)
This function allows error information to be logged using a user-defined callback routine...
EXTERNRT void rtxErrPrintElement(OSRTErrInfo *pErrInfo)
This function is used to print the error information stored in the error information element to the s...
EXTERNRT int rtxErrCopy(OSCTXT *pDestCtxt, const OSCTXT *pSrcCtxt)
This function copies error information from one context into another.
EXTERNRT OSSIZE rtxErrGetErrorCnt(const OSCTXT *pctxt)
This function returns the total number of error records, including non-fatal errors.
EXTERNRT int rtxErrGetFirstError(const OSCTXT *pctxt)
This function returns the error code, stored in the first error record.
EXTERNRT OSBOOL rtxErrAddInt64Parm(OSCTXT *pctxt, OSINT64 errParm)
This function adds a 64-bit integer parameter to an error information structure.
EXTERNRT int rtxErrInvUIntOpt(OSCTXT *pctxt, OSUINT32 ident)
This function create an &#39;invalid option&#39; error (RTERR_INVOPT) in the context using an unsigned intege...
EXTERNRT int rtxErrResetLastErrors(OSCTXT *pctxt, OSSIZE errorsToReset)
This function resets last &#39;errorsToReset` errors in the context.
EXTERNRT int rtxErrSetNewData(OSCTXT *pctxt, int status, const char *module, int lineno)
This function is used to record an error in the context structure.
EXTERNRT char * rtxErrGetTextBuf(OSCTXT *pctxt, char *pbuf, OSSIZE bufsiz)
This function returns error text in the given fixed-size memory buffer.
Common run-time context definitions.
EXTERNRT OSBOOL rtxErrAddCtxtBufParm(OSCTXT *pctxt)
This function adds the contents of the context buffer to the error information structure in the conte...
EXTERNRT char * rtxErrGetMsgTextBuf(OSCTXT *pctxt, char *pbuf, OSSIZE bufsiz)
This function returns error message text in a static memory buffer.
EXTERNRT OSRTErrInfo * rtxErrNewNode(OSCTXT *pctxt)
This function creates a new empty error record for the passed context.
EXTERNRT void rtxErrFreeParms(OSCTXT *pctxt)
This function is used to free dynamic memory that was used in the recording of error parameters...
EXTERNRT OSBOOL rtxErrAddSizeParm(OSCTXT *pctxt, OSSIZE errParm)
This function adds a size-typed parameter to an error information structure.
EXTERNRT OSBOOL rtxErrAddUIntParm(OSCTXT *pctxt, unsigned int errParm)
This function adds an unsigned integer parameter to an error information structure.
EXTERNRT char * rtxErrGetText(OSCTXT *pctxt, char *pBuf, OSSIZE *pBufSize)
This function returns error text in a memory buffer.
EXTERNRT OSBOOL rtxErrAddErrorTableEntry(const char *const *ppStatusText, OSINT32 minErrCode, OSINT32 maxErrCode)
This function adds a set of error codes to the global error table.
EXTERNRT void rtxErrSetNonFatal(OSCTXT *pctxt)
This marks the last error recorded in the context as non-fatal.
EXTERNRT void rtxErrAssertionFailed(const char *conditionText, int lineNo, const char *fileName)
This function is used to record an assertion failure.
EXTERNRT OSBOOL rtxErrAddUInt64Parm(OSCTXT *pctxt, OSUINT64 errParm)
This function adds an unsigned 64-bit integer parameter to an error information structure.
EXTERNRT OSBOOL rtxErrAddStrParm(OSCTXT *pctxt, const char *pErrParm)
This function adds a character string parameter to an error information structure.
EXTERNRT int rtxErrGetStatus(const OSCTXT *pctxt)
This function returns the status value from the context.
EXTERNRT int rtxErrResetErrInfo(OSCTXT *pctxt)
This function is used to reset the error state recorded in the context to successful.
EXTERNRT OSBOOL rtxErrAddStrnParm(OSCTXT *pctxt, const char *pErrParm, OSSIZE nchars)
This function adds a given number of characters from a character string parameter to an error informa...
EXTERNRT int rtxErrReset(OSCTXT *pctxt)
This function is used to reset the error state recorded in the context to successful.
Run-time error information structure.
Definition: rtxContext.h:67
List of numeric status codes that can be returned by common run-time functions and generated code...
EXTERNRT int rtxErrAppend(OSCTXT *pDestCtxt, const OSCTXT *pSrcCtxt)
This function appends error information from one context into another.
EXTERNRT void rtxErrInit(OSVOIDARG)
This function is a one-time initialization function that must be called before any other error proces...
EXTERNRT OSBOOL rtxErrAddIntParm(OSCTXT *pctxt, int errParm)
This function adds an integer parameter to an error information structure.
EXTERNRT OSBOOL rtxErrAddElemNameParm(OSCTXT *pctxt)
This function adds an element name parameter to the context error information structure.
Run-time context structure.
Definition: rtxContext.h:198
EXTERNRT int rtxErrSetData(OSCTXT *pctxt, int status, const char *module, int lineno)
This function is used to record an error in the context structure.
EXTERNRT char * rtxErrGetMsgText(OSCTXT *pctxt)
This function returns error message text in a memory buffer.
EXTERNRT int rtxErrGetLastError(const OSCTXT *pctxt)
This function returns the error code, stored in the last error record.
EXTERNRT OSBOOL rtxErrAddDoubleParm(OSCTXT *pctxt, double errParm)
This function adds a double parameter to an error information structure.
EXTERNRT const char * rtxErrFmtMsg(OSRTErrInfo *pErrInfo, char *bufp, OSSIZE bufsiz)
This function formats a given error structure from the context into a finished status message includi...
EXTERNRT void rtxErrPrint(OSCTXT *pctxt)
This function is used to print the error information stored in the context to the standard output dev...