/*
 ******************************************************************************
 *  Copyright 1984-1993 United States Data Corporation. All Rights Reserved.
 ******************************************************************************
 *                                - NOTICE -
 *
 *  The information contained herein is confidential information of United
 *  States Data Corporation, a Delaware corporation, and is protected by
 *  United States copyright and trade secret law and international treaties.
 *  This information is not to be disclosed, used or copied by or transferred
 *  to any individual, corporation, company or other person without the
 *  express written permission of United States Data Corporation.
 ******************************************************************************
 *
 * Module:	HDT_CMAP.H
 *
 *	Header file for column mapping API.
 *
 * History:
 *		bjc 08/07/93	Created. 
 */


#ifndef _CMAP_INCLUDED
#define _CMAP_INCLUDED

#include <hdt_base.h>		/* Base Definitions for the API */

/*
 ************************************************************************
 *                              Constants                               *       
 ************************************************************************
 */

/*
 *  Type of binding contained in CMAP
 */

#define CMAP_DBT	0	/* Map of DBT to DBT */
#define CMAP_HSDA	1	/* Map of HSDA to HSDA */

/*
 *  Column status constants
 */

#define CMAP_COLUMN_OK		0	/* column def syncs */
#define CMAP_NO_COLUMN		(-1)	/* column not in both sets */
#define CMAP_TYPE_DIFF		(-2)	/* column type differs between sets */
#define CMAP_SIZE_DIFF		(-3)	/* column size differs between sets */


/*
 ************************************************************************
 *                              Structures                              * 
 ************************************************************************
 */

typedef	struct
{
	short	colno_a;	/* field number in schema A  */
	short	colno_b;	/* field number in schema B  */
	short	status;		/* status of the binding   */
} CMAP_REC;

typedef	struct 
{
	HS_DA		*hsda_a;	/* field set A */
	HS_DA		*hsda_b;	/* field set B */
	short		num_colmap;	/* number of field map records */
	CMAP_REC	*col_maps;	/* field map between databases */
} CMAP;


/*
 ************************************************************************
 *                              Macros                                  *       
 ************************************************************************
 */

/*
 *  CMAP access macros
 */

#define cmap_get_num_colmap(cmap)	((cmap)->num_colmap)
#define cmap_get_map_type(cmap)		((cmap)->map_type)

#define cmap_get_hsda_a(cmap)		((cmap)->hsda_a)
#define cmap_set_hsda_a(cmap, hsda)	((cmap)->hsda_a = (hsda))

#define cmap_get_hsda_b(cmap)		((cmap)->hsda_b)
#define cmap_set_hsda_b(cmap, hsda)	((cmap)->hsda_b = (hsda))

/*
 *  CMAP_FLD access macros
 */

#define cmap_get_colno_a(cmap, n)	((cmap)->col_maps[n].colno_a)
#define cmap_set_colno_a(cmap, n, fld)	((cmap)->col_maps[n].colno_a = (fld))

#define cmap_get_colno_b(cmap, n)	((cmap)->col_maps[n].colno_b)
#define cmap_set_colno_b(cmap, n, fld)	((cmap)->col_maps[n].colno_b = (fld))

#define cmap_get_status(cmap, n)	((cmap)->col_maps[n].status)


/*
 ************************************************************************
 *                         Function Prototypes                          * 
 ************************************************************************
 */

extern CMAP*	cmap_create(short num_colmap);

extern CMAP*	cmap_bind_hsda(HS_DA *hsda_a, HS_DA *hsda_b);

extern void	cmap_destroy(CMAP *cmap);

#endif

