XBinder  Version 2.6.x
rtxError.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2003-2018 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 
102 #define OSRTASSERT(condition) \
103 if (!(condition)) { rtxErrAssertionFailed(#condition,__LINE__,__FILE__); }
104 
111 #define OSRTCHECKPARAM(condition) if (condition) { /* do nothing */ }
112 #else
113 #define LOG_RTERR(pctxt,stat) \
114 rtxErrSetData(pctxt,stat,0,0)
115 
116 #define LOG_RTERRNEW(pctxt,stat) \
117 rtxErrSetNewData(pctxt,stat,0,0)
118 
119 #define OSRTASSERT(condition)
120 #define OSRTCHECKPARAM(condition)
121 #endif /* _COMPACT */
122 
123 #define LOG_RTERR1(pctxt,stat,a) \
124 (a,LOG_RTERR (pctxt, stat),stat)
125 
126 #define LOG_RTERRNEW1(pctxt,stat,a) \
127 (a,LOG_RTERRNEW (pctxt, stat),stat)
128 
129 #define LOG_RTERR2(pctxt,stat,a,b) \
130 (a,b,LOG_RTERR (pctxt, stat),stat)
131 
132 #define LOG_RTERRNEW2(pctxt,stat,a,b) \
133 (a,b,LOG_RTERRNEW (pctxt, stat),stat)
134 
145 #define LOG_RTERR_AND_FREE_MEM(ctxt_p,stat,mem_p) \
146 rtxMemFreePtr ((ctxt_p),(mem_p)), LOG_RTERR(ctxt_p, stat)
147 
148 typedef int (*OSErrCbFunc) (const char* ptext, void* cbArg_p);
149 
159 EXTERNRT OSBOOL rtxErrAddCtxtBufParm (OSCTXT* pctxt);
160 
170 EXTERNRT OSBOOL rtxErrAddDoubleParm (OSCTXT* pctxt, double errParm);
171 
184 EXTERNRT OSBOOL rtxErrAddErrorTableEntry
185 #if !defined(_ARMTCC) && !defined(__SYMBIAN32__)
186 (const char* const* ppStatusText, OSINT32 minErrCode, OSINT32 maxErrCode);
187 #else
188 (OSVOIDARG);
189 #endif
190 
201 EXTERNRT OSBOOL rtxErrAddElemNameParm (OSCTXT* pctxt);
202 
215 EXTERNRT OSBOOL rtxErrAddIntParm (OSCTXT* pctxt, int errParm);
216 
217 #if !defined(_NO_INT64_SUPPORT)
218 
231 EXTERNRT OSBOOL rtxErrAddInt64Parm (OSCTXT* pctxt, OSINT64 errParm);
232 #endif /* !defined(_NO_INT64_SUPPORT) */
233 
246 EXTERNRT OSBOOL rtxErrAddSizeParm (OSCTXT* pctxt, OSSIZE errParm);
247 
257 EXTERNRT OSBOOL rtxErrAddStrParm (OSCTXT* pctxt, const char* pErrParm);
258 
269 EXTERNRT OSBOOL rtxErrAddStrnParm
270  (OSCTXT* pctxt, const char* pErrParm, size_t nchars);
271 
281 EXTERNRT OSBOOL rtxErrAddUIntParm (OSCTXT* pctxt, unsigned int errParm);
282 
283 #if !defined(_NO_INT64_SUPPORT)
284 
293 EXTERNRT OSBOOL rtxErrAddUInt64Parm (OSCTXT* pctxt, OSUINT64 errParm);
294 #endif /* !defined(_NO_INT64_SUPPORT) */
295 
306 EXTERNRT void rtxErrAssertionFailed
307 (const char* conditionText, int lineNo, const char* fileName);
308 
318 EXTERNRT const char* rtxErrFmtMsg
319 (OSRTErrInfo* pErrInfo, char* bufp, size_t bufsiz);
320 
328 EXTERNRT void rtxErrFreeParms (OSCTXT* pctxt);
329 
351 EXTERNRT char* rtxErrGetText (OSCTXT* pctxt, char* pBuf, size_t* pBufSize);
352 
362 EXTERNRT char* rtxErrGetTextBuf (OSCTXT* pctxt, char* pbuf, size_t bufsiz);
363 
376 EXTERNRT char* rtxErrGetMsgText (OSCTXT* pctxt);
377 
389 EXTERNRT char* rtxErrGetMsgTextBuf (OSCTXT* pctxt, char* pbuf, size_t bufsiz);
390 
400 EXTERNRT OSRTErrInfo* rtxErrNewNode (OSCTXT* pctxt);
401 
408 EXTERNRT void rtxErrInit (OSVOIDARG);
409 
417 EXTERNRT int rtxErrReset (OSCTXT* pctxt);
418 
440 EXTERNRT void rtxErrLogUsingCB (OSCTXT* pctxt, OSErrCbFunc cb, void* cbArg_p);
441 
449 EXTERNRT void rtxErrPrint (OSCTXT* pctxt);
450 
458 EXTERNRT void rtxErrPrintElement (OSRTErrInfo* pErrInfo);
459 
471 EXTERNRT int rtxErrSetData (OSCTXT* pctxt, int status,
472  const char* module, int lineno);
473 
485 EXTERNRT int rtxErrSetNewData (OSCTXT* pctxt, int status,
486  const char* module, int lineno);
493 EXTERNRT int rtxErrGetFirstError (const OSCTXT* pctxt);
494 
501 EXTERNRT int rtxErrGetLastError (const OSCTXT* pctxt);
502 
509 EXTERNRT OSSIZE rtxErrGetErrorCnt (const OSCTXT* pctxt);
510 
521 EXTERNRT int rtxErrGetStatus (const OSCTXT* pctxt);
522 
533 EXTERNRT int rtxErrResetLastErrors (OSCTXT* pctxt, OSSIZE errorsToReset);
534 
548 EXTERNRT int rtxErrCopy (OSCTXT* pDestCtxt, const OSCTXT* pSrcCtxt);
549 
563 EXTERNRT int rtxErrAppend (OSCTXT* pDestCtxt, const OSCTXT* pSrcCtxt);
564 
572 EXTERNRT int rtxErrInvUIntOpt (OSCTXT* pctxt, OSUINT32 ident);
573 
578 #ifdef __cplusplus
579 }
580 #endif
581 
582 #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.
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 OSBOOL rtxErrAddStrnParm(OSCTXT *pctxt, const char *pErrParm, size_t nchars)
This function adds a given number of characters from a character string parameter to an error informa...
EXTERNRT char * rtxErrGetTextBuf(OSCTXT *pctxt, char *pbuf, size_t bufsiz)
This function returns error text in the given fixed-size memory buffer.
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 * rtxErrGetMsgTextBuf(OSCTXT *pctxt, char *pbuf, size_t bufsiz)
This function returns error message text in a static 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 * rtxErrGetText(OSCTXT *pctxt, char *pBuf, size_t *pBufSize)
This function returns error text in a memory buffer.
EXTERNRT OSRTErrInfo * rtxErrNewNode(OSCTXT *pctxt)
This function creates a new empty error record for the passed context.
EXTERNRT const char * rtxErrFmtMsg(OSRTErrInfo *pErrInfo, char *bufp, size_t bufsiz)
This function formats a given error structure from the context into a finished status message includi...
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 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 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 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:185
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 void rtxErrPrint(OSCTXT *pctxt)
This function is used to print the error information stored in the context to the standard output dev...