This code segment is an example of how to initialize two of the C data structures, written as TbParm and TbCmdArea for tableBASE before calling the tableBASE API (DK1TCALL) with these data structures. The remaining code for initialization of all data structures is found in your.hlq.SRC(DKINITC).
/*
* This file contains examples of functions that can be used to
* initialize the data structures needed for calling tableBASE.
* The definitions of these structures are in your.hlq.SRC(DKH).
*/
#include <stdio.h>
#include <string.h>
#include "dkh.h"
/********************************************************************/
void initCmdArea( TbCmdArea * ca, char * table_name )
{
/* COBOL name: COMMAND-AREA */
int name_length = 0, i;
/*
* Initialize it all to zero and set individual members as needed.
*/
memset( ca, 0, sizeof(TbCmdArea) );
memset( ca->command, ' ', 2 );
ca->found = ' ';
memset( ca->lock_latch, ' ', 8 );
fixStringLength( table_name, ca->table, 8 );
}
/********************************************************************/
void initTbParm( TbParm * parm )
{
/* COBOL name: TB-PARM */
/*
* Initialize it all to zero and set individual members as needed.
*/
memset( parm, 0, sizeof(TbParm) );
parm->parm_id[0] = 'T';
parm->parm_id[1] = 'B';
parm->version = '5';
parm->format = '0';
}
/********************************************************************/