Objective Systems, Inc.  

Context Management Functions
[C Runtime Common Functions]

Context initialization functions handle the allocation, initialization, and destruction of ASN.1 context variables (variables of type OOCTXT). More...

Defines

#define ZEROCONTEXT(pctxt)   memset(pctxt,0,sizeof(OOCTXT))

Functions

EXTERN int initContextBuffer (OOCTXT *pctxt, const ASN1OCTET *bufaddr, ASN1UINT bufsiz)
 This function assigns a buffer to a context block.
EXTERN int initContext (OOCTXT *pctxt)
 This function initializes a context block.
EXTERN void freeContext (OOCTXT *pctxt)
 This function frees all dynamic memory associated with a context.
EXTERN OOCTXTnewContext (void)
 This function allocates a new OOCTXT block and initializes it.
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)

Detailed Description

Context initialization functions handle the allocation, initialization, and destruction of ASN.1 context variables (variables of type OOCTXT).

These variables hold all of the working data used during the process of encoding or decoding a message. The context provides thread safe operation by isolating what would otherwise be global variables within this structure. The context variable is passed from function to function as a message is encoded or decoded and maintains state information on the encoding or decoding process.


Function Documentation

EXTERN int initContextBuffer ( OOCTXT pctxt,
const ASN1OCTET bufaddr,
ASN1UINT  bufsiz 
)

This function assigns a buffer to a context block.

The block should have been previously initialized by initContext.

Parameters:
pctxt The pointer to the context structure variable to be initialized.
bufaddr For encoding, the address of a memory buffer to receive and encode a message. For decoding the address of a buffer that contains the message data to be decoded. This address will be stored within the context structure. For encoding it might be zero, the dynamic buffer will be used in this case.
bufsiz The size of the memory buffer. For encoding, it might be zero; the dynamic buffer will be used in this case.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

EXTERN int initContext ( OOCTXT pctxt  ) 

This function initializes a context block.

It makes sure that if the block was not previosly initialized, that all key working parameters are set to thier correct initial state values (i.e. declared within a function as a normal working variable), it is required that they invoke this function before using it.

Parameters:
pctxt The pointer to the context structure variable to be initialized.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • negative return value is error.

EXTERN void freeContext ( 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).

Parameters:
pctxt A pointer to a context structure.

EXTERN OOCTXT* newContext ( void   ) 

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.

Returns:
Pointer to newly created context


This file was last modified on 28 May 2010.
Objective Open H.323 Stack, 0.9.1