XER C Decode Functions.
[XER Runtime Library Functions.]

Functions

int xerDecBMPStr (OSCTXT *pctxt, ASN1BMPString *outdata)
int xerDecBase64Str (OSCTXT *pctxt, OSOCTET *pvalue, OSUINT32 *pnocts, OSINT32 bufsize)
int xerDecBigInt (OSCTXT *pctxt, char **ppvalue, int radix)
int xerDecBitStr (OSCTXT *pctxt, OSOCTET *pvalue, OSUINT32 *pnbits, OSINT32 bufsize)
int xerDecBitStrMemBuf (OSRTMEMBUF *pMemBuf, const XMLCHAR *inpdata, int length, OSBOOL skipWhitespaces)
int xerDecBool (OSCTXT *pctxt, OSBOOL *pvalue)
int xerDecCopyBitStr (OSCTXT *pctxt, OSOCTET *pvalue, OSUINT32 *pnbits, OSINT32 bufsize, int lastBitOffset)
int xerDecCopyDynBitStr (OSCTXT *pctxt, ASN1DynBitStr *pvalue, int lastBitOffset)
int xerDecCopyDynOctStr (OSCTXT *pctxt, ASN1DynOctStr *pvalue, int lastBitOffset)
int xerDecCopyOctStr (OSCTXT *pctxt, OSOCTET *pvalue, OSUINT32 *pnocts, OSINT32 bufsize, int lastBitOffset)
int xerDecDynAscCharStr (OSCTXT *pctxt, const char **outdata)
int xerDecDynBase64Str (OSCTXT *pctxt, ASN1DynOctStr *pvalue)
int xerDecDynBitStr (OSCTXT *pctxt, ASN1DynBitStr *pvalue)
int xerDecDynOctStr (OSCTXT *pctxt, ASN1DynOctStr *pvalue)
int xerDecDynUTF8Str (OSCTXT *pctxt, ASN1UTF8String *outdata)
int xerDecInt (OSCTXT *pctxt, OSINT32 *pvalue)
int xerDecInt8 (OSCTXT *pctxt, OSINT8 *pvalue)
int xerDecInt16 (OSCTXT *pctxt, OSINT16 *pvalue)
int xerDecInt64 (OSCTXT *pctxt, OSINT64 *pvalue)
int xerDecObjId (OSCTXT *pctxt, ASN1OBJID *pvalue)
int xerDecObjId64 (OSCTXT *pctxt, ASN1OID64 *pvalue)
int xerDecOctStr (OSCTXT *pctxt, OSOCTET *pvalue, OSUINT32 *pnocts, OSINT32 bufsize)
int xerDecOctStrMemBuf (OSRTMEMBUF *pMemBuf, const XMLCHAR *inpdata, int length, OSBOOL skipWhitespaces)
int xerDecOpenType (OSCTXT *pctxt, ASN1OpenType *pvalue)
int xerDecReal (OSCTXT *pctxt, OSREAL *pvalue)
int xerDecReal10 (OSCTXT *pctxt, const OSUTF8CHAR **pvalue)
int xerDecRelativeOID (OSCTXT *pctxt, ASN1OBJID *pvalue)
int xerDecUInt (OSCTXT *pctxt, OSUINT32 *pvalue)
int xerDecUInt8 (OSCTXT *pctxt, OSUINT8 *pvalue)
int xerDecUInt16 (OSCTXT *pctxt, OSUINT16 *pvalue)
int xerDecUInt64 (OSCTXT *pctxt, OSUINT64 *pvalue)
int xerDecUnivStr (OSCTXT *pctxt, ASN1UniversalString *outdata)
int xerSetDecBufPtr (OSCTXT *pCtxt, const OSOCTET *bufaddr, size_t bufsiz)

Detailed Description

XER runtime library decode functions handle the decoding of the primitive ASN.1 data types and length variables. Calls to these functions are assembled in the C source code generated by the ASN1C complier to decode complex ASN.1 structures. These functions are also directly callable from within a user's application program if the need to decode a primitive data item exists.


Function Documentation

int xerDecBase64Str ( OSCTXT *  pctxt,
OSOCTET *  pvalue,
OSUINT32 *  pnocts,
OSINT32  bufsize 
)

This function will decode a variable of teh ASN.1 OCTET STRING type into a static memory structure. The octet string must be Base64 encoded. This function call is used to decode a sized octet string production.

Parameters:
pctxt A pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
pvalue A pointer to a variable to receive the decoded bit string. This is assumed to be a static array large enough to hold the number of octets specified in the bufsize input parameter.
pnocts A pointer to an integer value to receive the decoded number of octets.
bufsize A integer variable containing the size (in octets) of the sized ASN.1 octet string. An error will occur if the number of octets in the decoded string is larger than this value.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecBigInt ( OSCTXT *  pctxt,
char **  ppvalue,
int  radix 
)

This function will decode a variable of the ASN.1 INTEGER type. In this case, the integer is assumed to be of a larger size than can fit in a C or C++ long type (normally 32 or 64 bits). For example, parameters used to calculate security values are typically larger than these sizes.

These variables are stored in character string constant variables. Depending on specified radix, they could be represented as binary, octal, decimal or hexadecimal strings starting with appropriate prefix. If it is necessary to convert to another radix, then use rtxBigIntSetStr or rtxBigIntToString functions.

Parameters:
pctxt Pointer to context block structure.
ppvalue Pointer to a character pointer variable to receive the decoded unsigned value. Dynamic memory is allocated for the variable using the rtxMemAlloc function. The decoded variable is represented as a string starting with appropriate prefix.
radix The expected radix of the decoded value. The only radices 2, 8, 10 and 16 are supported.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecBitStr ( OSCTXT *  pctxt,
OSOCTET *  pvalue,
OSUINT32 *  pnbits,
OSINT32  bufsize 
)

This function will decode a variable of the ASN.1 BIT STRING type into a static memory structure. This function call is generated by ASN1C to decode a sized bit production.

Parameters:
pctxt A pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
pvalue A pointer to a variable to receive the decoded bit string. This is assumed to be a static array large enough to hold the number of octets specified in the bufsize input parameter.
pnbits A pointer to an integer value to receive the decoded number of bits.
bufsize An integer variable containing the size (in octets) of the sized ASN.1 bit string. An error will occur if the number of octets in the decoded string is larger than this value.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecBitStrMemBuf ( OSRTMEMBUF *  pMemBuf,
const XMLCHAR *  inpdata,
int  length,
OSBOOL  skipWhitespaces 
)

This function decodes a variable of the ASN.1 BIT STRING type to a memory buffer. The decoded data will be put into the memory buffer starting from the current position and bit offset. After all data is decoded the bit string may be fetched out by call to xerDecCopyBitStr or xerDecCopyDynBitStr functions.

Usually, this function is used in the 'characters' SAX handler.

Parameters:
pMemBuf Pointer to the destination memory buffer.
inpdata Pointer to a source string to be decoded.
length Length of the source string (in characters).
skipWhitespaces Indicates, could whitespaces be ignored or they are illegal.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecBMPStr ( OSCTXT *  pctxt,
ASN1BMPString *  outdata 
)

This function will decode a variable ASN.1 16-bit character BMPString type. This function will allocate dynamic memory to store the decoded result.

Parameters:
pctxt A pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
outdata A pointer to a structure variable to receive the decoded string. The string is stored as an array of short integer characters. The memory is allocated for the string by the rtxMemAlloc function.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecBool ( OSCTXT *  pctxt,
OSBOOL *  pvalue 
)

This function decodes a variable of the ASN.1 BOOLEAN type.

Parameters:
pctxt Pointer to context block structure.
pvalue Pointer to a variable to receive the decoded BOOLEAN value.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecCopyBitStr ( OSCTXT *  pctxt,
OSOCTET *  pvalue,
OSUINT32 *  pnbits,
OSINT32  bufsize,
int  lastBitOffset 
)

This function copies the decoded BIT STRING from the memory buffer. This function call is generated by ASN1C to decode a sized bit string production.

Parameters:
pctxt Pointer to context block structure. Its buffer should be set to point to the decoded data.
pvalue Pointer to a buffer to receive the decoded data.
pnbits Pointer to an integer value to receive the decoded number of bits.
bufsize An integer variable containing the size (in octets) of the sized ASN.1 bit string. An error will occur if the number of octets in the decoded string is larger than this value.
lastBitOffset A number of actual bits in the last octet.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecCopyDynBitStr ( OSCTXT *  pctxt,
ASN1DynBitStr *  pvalue,
int  lastBitOffset 
)

This function copies the decoded BIT STRING from the memory buffer. This function will allocate dynamic memory to store the decoded result.

Parameters:
pctxt Pointer to context block structure. Its buffer should be set to point to the decoded data.
pvalue Pointer to a dynamic bit string structure to receive the decoded bit string. Dynamic memory is allocated to hold the string using the rtxMemAlloc function.
lastBitOffset A number of actual bits in the last octet.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecCopyDynOctStr ( OSCTXT *  pctxt,
ASN1DynOctStr *  pvalue,
int  lastBitOffset 
)

This function copies the decoded OCTET STRING from the memory buffer. This function will allocate dynamic memory to store the decoded result.

Parameters:
pctxt Pointer to context block structure. Its buffer should be set to point to the decoded data.
pvalue Pointer to a dynamic octet string structure to receive the decoded octet string. Dynamic memory is allocated to hold the string using the rtxMemAlloc function.
lastBitOffset A number of actual bits in the last octet.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecCopyOctStr ( OSCTXT *  pctxt,
OSOCTET *  pvalue,
OSUINT32 *  pnocts,
OSINT32  bufsize,
int  lastBitOffset 
)

This function copies the decoded OCTET STRING from the memory buffer. This function call is generated by ASN1C to decode a sized octet string production.

Parameters:
pctxt Pointer to context block structure. Its buffer should be set to point to the decoded data.
pvalue Pointer to a variable to receive the decoded bit string. This is assumed to be a static array large enough to hold the number of octets specified in the 'bufsize' input parameter.
pnocts Pointer to an integer value to receive the decoded number of octets.
bufsize An integer variable containing the size (in octets) of the sized ASN.1 octet string. An error will occur if the number of octets in the decoded string is larger than this value.
lastBitOffset A number of actual bits in the last octet.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecDynAscCharStr ( OSCTXT *  pctxt,
const char **  outdata 
)

This function will decode a variable of one of the ASN.1 8-bit character string types. These types include IA5String, VisibleString, PrintableString, and NumericString. This function will allocate dynamic memory to store the result.

Parameters:
pctxt A pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
outdata A pointer to a character string pointer variable to receive the decoded string. The string as stored as a standard null-terminated C string. Memory is allocated for the string by the rtxMemAlloc function.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecDynBase64Str ( OSCTXT *  pctxt,
ASN1DynOctStr *  pvalue 
)

This function will decode a variable of the ASN.1 OCTET STRING type. The octet string must be Base64 encoded. This function will allocate dynamic memory to store the decoded result.

Parameters:
pctxt A pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
pvalue A pointer to a dynamic octet string structure to receive the decoded octet string. Dynamic memory is allocated to hold the string using the rtxMemAlloc function.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecDynBitStr ( OSCTXT *  pctxt,
ASN1DynBitStr *  pvalue 
)

This function will decode a variable of the ASN.1 BIT STRING type. This function will allocate dynamic memory to store the decoded result.

Parameters:
pctxt A pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
pvalue A pointer to a dynamic bit string structure to receive the decoded bit string. Dynamic memory is allocated to hold the string using the rtxMemAlloc function.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecDynOctStr ( OSCTXT *  pctxt,
ASN1DynOctStr *  pvalue 
)

This function will decode a variable of the ASN.1 OCTET STRING type. This function will allocate dynamic memory to store the decoded result.

Parameters:
pctxt A pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
pvalue A pointer to a dynamic bit string structure to receive the decoded bit string. Dynamic memory is allocated to hold the string using the rtxMemAlloc function.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecDynUTF8Str ( OSCTXT *  pctxt,
ASN1UTF8String *  outdata 
)

This function will decode a variable of UTF8String ASN.1 type. Generally, the SAX parser converts all UTF8 format strings to 16-bit Unicode format automatically. This function converts the Unicode string back to UTF8 format. This function will allocate dynamic memory to store the decoded result.

Parameters:
pctxt A pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
outdata A pointer to a character string pointer variable to receive the decoded string. The string as stored as a UTF8 null-terminated string. Memory is allocated for the string by the rtxMemAlloc function.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecInt ( OSCTXT *  pctxt,
OSINT32 *  pvalue 
)

This function decodes a variable of the ASN.1 INTEGER type.

Parameters:
pctxt Pointer to context block structure.
pvalue Pointer to a variable to receive the decoded integer value.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecInt16 ( OSCTXT *  pctxt,
OSINT16 *  pvalue 
)

This function decodes a 16-bit variable of the ASN.1 INTEGER type.

Parameters:
pctxt Pointer to context block structure.
pvalue Pointer to a 16-bit variable to receive the decoded integer value.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecInt64 ( OSCTXT *  pctxt,
OSINT64 *  pvalue 
)

This function decodes a 64-bit variable of the ASN.1 INTEGER type.

Parameters:
pctxt Pointer to context block structure.
pvalue Pointer to a 64-bit variable to receive the decoded integer value. The OSINT64 type is set to the C type '__int64', 'long long' or 'long' in the asn1type.h file (depends on the used platform and the compiler).
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecInt8 ( OSCTXT *  pctxt,
OSINT8 *  pvalue 
)

This function decodes an 8-bit variable of the ASN.1 INTEGER type.

Parameters:
pctxt Pointer to context block structure.
pvalue Pointer to an 8-bit variable to receive the decoded integer value.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecObjId ( OSCTXT *  pctxt,
ASN1OBJID *  pvalue 
)

This function decodes a value of the ASN.1 OBJECT IDENTIFIER type.

Parameters:
pctxt Pointer to context block structure.
pvalue Pointer to value to receive decoded result. The ASN1OBJID structure contains an integer to hold the number of subidentifiers and an array to hold the subidentifier values.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecObjId64 ( OSCTXT *  pctxt,
ASN1OID64 *  pvalue 
)

This function decodes a value of the ASN.1 OBJECT IDENTIFIER type using 64-bit subidentifiers.

Parameters:
pctxt Pointer to context block structure.
pvalue Pointer to value to receive decoded result. The ASN1OID64 structure contains an integer to hold the number of subidentifiers and an array of 64-bit unsigned integers to hold the subidentifier values.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecOctStr ( OSCTXT *  pctxt,
OSOCTET *  pvalue,
OSUINT32 *  pnocts,
OSINT32  bufsize 
)

This function will decode a variable of the ASN.1 OCTET STRING type into a static memory structure. This function call is generated by ASN1C to decode a sized octet string production.

Parameters:
pctxt A pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
pvalue A pointer to a variable to receive the decoded bit string. This is assumed to be a static array large enough to hold the number of octets specified in the bufsize input parameter.
pnocts Pointer to an integer value to receive the number of octets.
bufsize An integer variable containing the size (in octets) of the sized ASN.1 octet string. An error will occur if the number of octets in the decoded string is larger than this value.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecOctStrMemBuf ( OSRTMEMBUF *  pMemBuf,
const XMLCHAR *  inpdata,
int  length,
OSBOOL  skipWhitespaces 
)

This function decodes a variable of the ASN.1 OCTET STRING type to a memory buffer. The decoded data will be put into the memory buffer starting from the current position and bit offset. After all data is decoded the octet string may be fetched out by call to xerDecCopyOctStr or xerDecCopyDynOctStr functions.

Usually, this function is used in the 'characters' SAX handler.

Parameters:
pMemBuf Pointer to the destination memory buffer.
inpdata Pointer to a source string to be decoded.
length Length of the source string (in characters).
skipWhitespaces Indicates, could whitespaces be ignored or they are illegal.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecOpenType ( OSCTXT *  pctxt,
ASN1OpenType *  pvalue 
)

This function will decode an ASN.1 open type. This used to be the ASN.1 ANY type, but now is used in a variety of applications requiring an encoding that can be interpreted by a decoder without prior knowledge of the type of the variable.

Parameters:
pctxt A pointer to a context block structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
pvalue A pointer to a structure variable to receive the decoded string. The string as stored as an array of unsigned integer characters. Memory is allocated for the string by the rtxMemAlloc function.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecReal ( OSCTXT *  pctxt,
OSREAL *  pvalue 
)

This function will decode a variable of the ASN.1 32-bit character UniversalString type. This includes the UniversalString type.

Parameters:
pctxt A pointer to a context block structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
pvalue A pointer to a structure variable to receive the decoded string. The string as stored as an array of unsigned integer characters. Memory is allocated for the string by the rtxMemAlloc function.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecReal10 ( OSCTXT *  pctxt,
const OSUTF8CHAR **  pvalue 
)

This function will decode a variable of the ASN.1 REAL type into a OSUTF8CHAR*. It is intended for use when the REAL type is constrained to base 10 and OSUTF8CHAR* is the chosen representation.

Parameters:
pctxt A pointer to a context block structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
pvalue A pointer to a structure variable to receive the decoded string. The string is stored as an array of unsigned integer characters. Memory is allocated for the string by the rtxMemAlloc function.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecRelativeOID ( OSCTXT *  pctxt,
ASN1OBJID *  pvalue 
)

This function decodes a value of the ASN.1 RELATIVE-OID type.

Parameters:
pctxt Pointer to context block structure.
pvalue Pointer to value to receive decoded result. The ASN1OBJID structure contains an integer to hold the number of subidentifiers and an array to hold the subidentifier values.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecUInt ( OSCTXT *  pctxt,
OSUINT32 *  pvalue 
)

This function decodes a variable of the unsigned variant of ASN.1 INTEGER type.

Parameters:
pctxt Pointer to context block structure.
pvalue Pointer to a variable to receive the decoded unsigned integer value.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecUInt16 ( OSCTXT *  pctxt,
OSUINT16 *  pvalue 
)

This function decodes a 16-bit variable of the unsigned variant of ASN.1 INTEGER type.

Parameters:
pctxt Pointer to context block structure.
pvalue Pointer to a 16-bit variable to receive the decoded unsigned integer value.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecUInt64 ( OSCTXT *  pctxt,
OSUINT64 *  pvalue 
)

This function decodes a 64-bit variable of the unsigned variant of ASN.1 INTEGER type.

Parameters:
pctxt Pointer to context block structure.
pvalue Pointer to a 64-bit variable to receive the decoded unsigned integer value. The OSUINT64 type is set to the C type 'unsigned __int64', 'unsigned long long' or 'unsigned long' in the asn1type.h file (depends on the used platform and the compiler).
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecUInt8 ( OSCTXT *  pctxt,
OSUINT8 *  pvalue 
)

This function decodes an 8-bit variable of the unsigned variant of ASN.1 INTEGER type.

Parameters:
pctxt Pointer to context block structure.
pvalue Pointer to an 8-bit variable to receive the decoded unsigned integer value.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.
int xerDecUnivStr ( OSCTXT *  pctxt,
ASN1UniversalString *  outdata 
)

This function will decode a variable an ASN.1 32-bit character UniversalString type. This includes the UniversalString type.

Parameters:
pctxt A pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
outdata A pointer to a structure variable to receive the decoded string. The string as stored as an array of unsigned integer characters. Memory is allocated for the string by the rtxMemAlloc function.
int xerSetDecBufPtr ( OSCTXT *  pCtxt,
const OSOCTET *  bufaddr,
size_t  bufsiz 
)

This function is used to set the internal decode buffer pointer within the runtime library decode module. It must be called prior to calling any other complier generated or runtime library decode functions.

Parameters:
pCtxt A pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
bufaddr A pointer to a memory buffer containing the ASN.1 message. The pointer must point at the first byte in the message.
bufsiz The size of the message that was read. This is used to set an internal message size to check for field length errors. If this size is not known, a zero value can be passed to cause these checks to be bypassed.