udbconv

Converts data from the format with which Uniface supplies it to the connector, to a specified connector-level packing code.

short udbconv(uc, src, dst, len, flist, pack)

struct uctrl*uc;

unsigned char*src;

unsigned char*dst;

shortlen;

struct ufldlst*flist;

shortpack;

Parameters

  • uc—address of the current control block.
  • src—pointer to the data to be converted.
  • dst—pointer to a buffer in which to store the result. The connector must define this buffer.
  • len—length of the data pointed to by src. flist. An entry in the ufldlst structure describing the field to be converted.
  • pack—connector-level packing code to which to convert.

If pack is zero, the following defaults are used:

Default connector-level packing codes
Data type Default packing code
B B2
D D3
E E4
F N20
N N20
T T1

Return Values

The length of the converted data.

Description

Converts data from the format with which Uniface supplies it to the connector, to a specified connector-level packing code.

For example, udbconv can be used to convert binary data in the if list to ASCII string format when a SQL query must be constructed.

The example converts data from an input buffer called InputData to ASCII. The variable FieldNumber contains the number of the field to convert.

ConvertData ( struct uctrl *ControlBlock,
unsigned char *InputData,
short FieldNumber )
{
short LengthIn, LengthOut;
unsigned char Buffer[MAX_BUF];
struct ufldlst *FieldList;
FieldList = (struct ufldlst *)ControlBlock->ufldlst + FieldNumber + 1;
/* +1 because first entry is dummy. */
LengthIn = strlen ( InputData );
LengthOut = udbconv ( ControlBlock, InputData,
(unsigned char *)Buffer,
LengthIn, FieldList, pN20 );
}