Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
virtual P6R::P6ERR P6R::p6IAsn1_2::encodeLength_2 ( P6UINT8 pBuffer,
P6UINT32  bufSize,
P6UINT32 pIndex,
P6UINT32  length,
P6INT8  useOctets 
)
pure virtual

Representing a type in BER encoding of ASN.1 requires that the type be represented in the following format: [tag value] [length of value] [value].

The "length of value" is it self encoded. If the length is 1 to 127 bytes then the length is encoded in a single byte. Otherwise multiple bytes are required to encode its value. For BER transfer encoding this library only allows the definite forms of length encoding.

Currently, this function does not handle lengths which require greater than 16 bits to encode. (That is a maximum of 3 octets, since the first octet is the length of the length.)

Parameters
pBuffer[ in out ] array of bytes to build an ASN.1 encoded message
bufSize[ in ] size in octets (i.e., bytes) of pBuffer
pIndex[ in ] current offset into pBuffer, that is, the next free byte to write into [ out ] As the length is encoded in pBuffer this index value increases in value
length[ in ] the length of the current ASN.1 field being constructed (e.g., length to encode)
useOctets[ in ] if useOctets < 0 then this function will determine the proper way to encode the length. Otherwise, the value in useOctets defines the number of octets to use to encode length.
Returns
SuccessP6R::eOk 
FailureP6R::eNotInitializedA successful call to initialize was not made before this call.
P6R::eInvalidStateMore than 16 bits (3 octets) where required to encode the lemgth.
P6R::eInvalidArgOne of the parameters is set to NULL.
P6R::eTooBigThe remaining space in pBuffer is insufficient to encode the length.