ooasn1.h
来自「一个非常美妙的proxy。功能强大。基于sip的协议。如果还要的话」· C头文件 代码 · 共 1,600 行 · 第 1/5 页
H
1,600 行
* - negative return value is error. */EXTERN int initContext (OOCTXT* pctxt);/** * This function frees all dynamic memory associated with a context. This * includes all memory inside the block (in particular, the list of memory * blocks used by the mem functions). * * @param pctxt A pointer to a context structure. */EXTERN void freeContext (OOCTXT* pctxt);/** * This function allocates a new OOCTXT block and initializes it. Although * the block is allocated from the standard heap, it should not be freed using * free. The freeContext function should be used because this frees items * allocated within the block before freeing the block itself. * * @return Pointer to newly created context */EXTERN OOCTXT* newContext (void);EXTERN void copyContext (OOCTXT* pdest, OOCTXT* psrc);EXTERN int initSubContext (OOCTXT* pctxt, OOCTXT* psrc);EXTERN void setCtxtFlag (OOCTXT* pctxt, ASN1USINT mask);EXTERN void clearCtxtFlag (OOCTXT* pctxt, ASN1USINT mask);EXTERN int setPERBuffer (OOCTXT* pctxt, ASN1OCTET* bufaddr, ASN1UINT bufsiz, ASN1BOOL aligned);EXTERN int setPERBufferUsingCtxt (OOCTXT* pTarget, OOCTXT* pSource);#define ZEROCONTEXT(pctxt) memset(pctxt,0,sizeof(OOCTXT))/** * @} cmfun *//** * @defgroup errfp Error Formatting and Print Functions * @{ * * Error formatting and print functions allow information about the * encode/decode errors to be added to a context block structure and then * printed out when the error is propagated to the top level. *//** * This function adds an integer parameter to an error information structure. * Parameter substitution is done in much the same way as it is done in C * printf statments. The base error message specification that goes along with * a particular status code may have variable fields built in using '%' * modifiers. These would be replaced with actual parameter data. * * @param pErrInfo A pointer to a structure containing information on the * error to be printed. Typically, the error info * structure referred to is the one inside the OOCTXT * structure. (i.e. &pctxt->errInfo). * @param errParm The typed error parameter. * @return The status of the operation. */EXTERN int errAddIntParm (ASN1ErrInfo* pErrInfo, int errParm);/** * This function adds an string parameter to an error information structure. * Parameter substitution is done in much the same way as it is done in C * printf statments. The base error message specification that goes along with * a particular status code may have variable fields built in using '%' * modifiers. These would be replaced with actual parameter data. * * @param pErrInfo A pointer to a structure containing information on the * error to be printed. Typically, the error info * structure referred to is the one inside the OOCTXT * structure. (i.e. &pctxt->errInfo). * @param errprm_p The typed error parameter. * @return The status of the operation. */EXTERN int errAddStrParm (ASN1ErrInfo* pErrInfo, const char* errprm_p);/** * This function adds an unsigned integer parameter to an error information * structure. Parameter substitution is done in much the same way as it is done * in C printf statments. The base error message specification that goes along * with a particular status code may have variable fields built in using '%' * modifiers. These would be replaced with actual parameter data. * * @param pErrInfo A pointer to a structure containing information on the * error to be printed. Typically, the error info * structure referred to is the one inside the OOCTXT * structure. (i.e. &pctxt->errInfo). * @param errParm The typed error parameter. * @return The status of the operation. */EXTERN int errAddUIntParm (ASN1ErrInfo* pErrInfo, unsigned int errParm);EXTERN int errCopyData (ASN1ErrInfo* pSrcErrInfo, ASN1ErrInfo* pDestErrInfo);/** * This function frees memory associated with the storage of parameters * associated with an error message. These parameters are maintained on an * internal linked list maintained within the error information structure. The * list memory must be freed when error processing is complete. This function * is called from within errPrint after teh error has been printed out. It is * also called in teh freeContext function. * * @param pErrInfo A pointer to a structure containing information on the * error to be printed. Typically, the error info * structure referred to is the one inside the OOCTXT * structure. (i.e. &pctxt->errInfo). */EXTERN void errFreeParms (ASN1ErrInfo* pErrInfo);EXTERN char* errFmtMsg (ASN1ErrInfo* pErrInfo, char* bufp);/** * This function gets the text of the error * * @param pctxt A pointer to a context structure. */EXTERN char* errGetText (OOCTXT* pctxt);/** * This function prints error information to the standard output device. The * error information is stored in a structure of type ASN1ErrInfo. A structure * of the this type is part f the OOCTXT structure. This is where error * information is stored within the ASN1C generated and low-level encode/decode * functions. * * @param pErrInfo A pointer to a structure containing information on the * error to be printed. Typically, the error info * structure referred to is the one inside the OOCTXT * structure. (i.e. &pctxt->errInfo). */EXTERN void errPrint (ASN1ErrInfo* pErrInfo);/** * This function resets the error information in the error information * sturcture. * * @param pErrInfo A pointer to a structure containing information on the * error to be printed. Typically, the error info * structure referred to is the one inside the OOCTXT * structure. (i.e. &pctxt->errInfo). */EXTERN int errReset (ASN1ErrInfo* pErrInfo);/** * This function sets error information in an error information structure. The * information set includes status code, module name, and line number. Location * information (i.e. module name and line number) is pushed onto a stack within * the error information structure to provide a complete stack trace when the * information is printed out. * * @param pErrInfo A pointer to a structure containing information on the * error to be printed. Typically, the error info * structure referred to is the one inside the OOCTXT * structure. (i.e. &pctxt->errInfo). * @param status The error status code. This is one of the negative error * status codes. * @param module The name of the module (C or C++ source file) in which * the module occurred. This is typically obtained by * using the _FILE_ macro. * @param lno The line number at which the error occurred. This is * typically obtained by using the _LINE_ macro. * @return The status value passed to the operation in the third * argument. This makes it possible to set the error * information and return the status value in one line of * code. */EXTERN int errSetData (ASN1ErrInfo* pErrInfo, int status, const char* module, int lno);#ifndef _COMPACT#define LOG_ASN1ERR(ctxt,stat) \errSetData(&(ctxt)->errInfo,stat,__FILE__,__LINE__)#else#define LOG_ASN1ERR(ctxt,stat) \((ctxt)->errInfo.status = stat, stat)#endif#define LOG_ASN1ERR_AND_FREE(pctxt,stat,lctxt) \freeContext ((lctxt)), LOG_ASN1ERR(pctxt, stat)/** * @} */#define RT_MH_DONTKEEPFREE 0x1#define OSRTMH_PROPID_DEFBLKSIZE 1#define OSRTMH_PROPID_SETFLAGS 2#define OSRTMH_PROPID_CLEARFLAGS 3#define OSRTMH_PROPID_USER 10/** * @addtogroup rtmem * @{ *//** * Allocate memory. This macro allocates the given number of bytes. It is * similar to the C \c malloc run-time function. * * @param pctxt - Pointer to a context block * @param nbytes - Number of bytes of memory to allocate * @return - Void pointer to allocated memory or NULL if insufficient memory * was available to fulfill the request. */#define memAlloc(pctxt,nbytes) \memHeapAlloc(&(pctxt)->pTypeMemHeap,nbytes)/** * Allocate and zero memory. This macro allocates the given number of bytes * and then initializes the memory block to zero. * * @param pctxt - Pointer to a context block * @param nbytes - Number of bytes of memory to allocate * @return - Void pointer to allocated memory or NULL if insufficient memory * was available to fulfill the request. */#define memAllocZ(pctxt,nbytes) \memHeapAllocZ(&(pctxt)->pTypeMemHeap,nbytes)/** * Reallocate memory. This macro reallocates a memory block (either * expands or contracts) to the given number of bytes. It is * similar to the C \c realloc run-time function. * * @param pctxt - Pointer to a context block * @param mem_p - Pointer to memory block to reallocate. This must have been * allocated using the memHeapAlloc macro or the memHeapAlloc function. * @param nbytes - Number of bytes of memory to which the block is to be * resized. * @return - Void pointer to allocated memory or NULL if insufficient memory * was available to fulfill the request. This may be the same as the pmem * pointer that was passed in if the block did not need to be relocated. */#define memRealloc(pctxt,mem_p,nbytes) \memHeapRealloc(&(pctxt)->pTypeMemHeap, (void*)mem_p, nbytes)/** * Free memory pointer. This macro frees memory at the given pointer. * The memory must have been allocated using the memHeapAlloc (or similar) * macros or the mem memory allocation macros. This macro is * similar to the C \c free function. * * @param pctxt - Pointer to a context block * @param mem_p - Pointer to memory block to free. This must have * been allocated using the memHeapAlloc or memAlloc macro or the * memHeapAlloc function. */#define memFreePtr(pctxt,mem_p) \if (memHeapCheckPtr (&(pctxt)->pTypeMemHeap, (void*)mem_p)) \memHeapFreePtr(&(pctxt)->pTypeMemHeap, (void*)mem_p)/** * Free memory associated with a context. This macro frees all memory * held within a context. This is all memory allocated using the * memHeapAlloc (and similar macros) and the mem memory allocation * functions using the given context variable. * * @param pctxt - Pointer to a context block */#define memFree(pctxt) \memHeapFreeAll(&(pctxt)->pTypeMemHeap)/** * Reset memory associated with a context. This macro resets all memory * held within a context. This is all memory allocated using the memHeapAlloc * (and similar macros) and the mem memory allocation functions using the * given context variable. * * <p>The difference between this and the ASN1MEMFREE macro is that the * memory blocks held within the context are not actually freed. Internal * pointers are reset so the existing blocks can be reused. This can * provide a performace improvement for repetitive tasks such as decoding * messages in a loop. * * @param pctxt - Pointer to a context block */#define memReset(pctxt) \memHeapReset(&(pctxt)->pTypeMemHeap)/* Alias for __cdecl modifier; if __cdecl keyword is not supported, * redefine it as empty macro. */#if !defined(OSCDECL)#if defined(_MSC_VER) || defined(__BORLANDC__)#define OSCDECL __cdecl#else#define OSCDECL#endif#endif /* OSCDECL *//* Pointers to C Run-Time memory allocation functions * * (See memSetAllocFuncs) */typedef void *(OSCDECL *OSMallocFunc ) (size_t size);typedef void *(OSCDECL *OSReallocFunc) (void *ptr, size_t size);typedef void (OSCDECL *OSFreeFunc ) (void *ptr);EXTERN void memHeapAddRef (void** ppvMemHeap);EXTERN void* memHeapAlloc (void** ppvMemHeap, int nbytes);EXTERN void* memHeapAllocZ (void** ppvMemHeap, int nbytes);EXTERN int memHeapCheckPtr (void** ppvMemHeap, void* mem_p);EXTERN int memHeapCreate (void** ppvMemHeap);EXTERN void memHeapFreeAll (void** ppvMemHeap);EXTERN void memHeapFreePtr (void** ppvMemHeap, void* mem_p);EXTERN void* memHeapRealloc (void** ppvMemHeap, void* mem_p, int nbytes_);EXTERN void memHeapRelease (void** ppvMemHeap);EXTERN void memHeapReset (void** ppvMemHeap);EXTERN void* memHeapMarkSaved (void** ppvMemHeap, const void* mem_p, ASN1BOOL saved);EXTERN void memHeapSetProperty
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?