Objective Systems, Inc.  
Home
About ASN.1
Products
Free Software
Documents
Services
Resources
Resellers
Customers
Careers
About Us
Contact Us
 

Google


Objective Systems, Inc.

Binary Coded Decimal (BCD) Helper Functions
[C Runtime Common Functions]


Detailed Description

Binary Coded Decimal (BCD) helper functions provide assistance in working with BCD numbers. Two functions are provided: one to convert to a BCD value to a string and one to perform the opposite conversion.


Functions

ASN1ConstCharPtr rtBCDToString (ASN1UINT numocts, ASN1ConstOctetPtr data, char *buffer, size_t bufsiz)
size_t rtStringToBCD (ASN1ConstCharPtr str, ASN1OCTET *bcdStr, size_t bufsiz)


Function Documentation

ASN1ConstCharPtr rtBCDToString ASN1UINT  numocts,
ASN1ConstOctetPtr  data,
char *  buffer,
size_t  bufsiz
 

This function converts a packed BCD value to a standard null-terminated string. Octet value can contain the filler digit to represent the odd number of BCD digits. BCD digits can be 0(0000) to 9(1001). Filler digits can be A(1010), B(1011), C(1100), D(1101), E(1110) or F(1111)

Parameters:
numocts The number of octets in the BCD value.
data The pointer to the BCD value.
buffer The destination buffer. Should not be less than buffsiz argument is.
bufsiz The size of the destination buffer (in octets). The buffer size should be atleast ((numocts * 2) + 1) to hold the BCD to String conversion.
Returns:
The converted null-terminated string. NULL, if error has occurred or destination buffer is not enough.

size_t rtStringToBCD ASN1ConstCharPtr  str,
ASN1OCTET *  bcdStr,
size_t  bufsiz
 

This function converts a standard null-terminated string into a BCD value. The source string should contain only characters '0' - '9', 'A' - 'F', or 'a' - 'f'. Otherwise, an error will occur.

Parameters:
str The source standard null-terminated string.
bcdStr The destination buffer. Should not be less than bufsiz is.
bufsiz The size of the destination buffer (in octets).
Returns:
The number of octets in the resulting BCD value.


Copyright © 1997-2004 Objective Systems,Inc.
All Rights Reserved.
This document may be distributed in any form, electronic
or otherwise, provided that it is distributed in its entirety
and that the copyright and this notice are included.

This file was last modified on 1 Oct 2004.
ASN1C C/C++ Common Runtime, ASN1C v5.7x