/*
 ******************************************************************************
 *  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_SRL.H
 *
 *	Header file for serial table API.
 *
 * History:
 *		bjc 10/25/93	Created. 
 */


#ifndef _SRL_INCLUDED
#define _SRL_INCLUDED

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

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

/*
 *  Return codes from functions srlid_...()
 */

#define SRLID_GOOD	0
#define SRLID_ERROR	(-1)
#define SRLID_NOTFOUND	(-2)

#define SRLID_LEN_TBL	32		/* length of serial table name */
#define SRLID_LEN_KEY	64		/* length of serial key name */


/*
 ************************************************************************
 *                          Types & Structures                          *
 ************************************************************************
 */

typedef struct
{
	char	table_ref[SRLID_LEN_TBL+1];
	char	key_ref[SRLID_LEN_KEY+1];
	long	cur_val;
	short	increment;
} SRLID_REC;

/*
 *  Prototype for Serial ID Fetch Handler callback routines
 */

typedef int (*SRLID_FH) (SRLID_REC*, void*);

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

#define srlid_get_table_ref(p)	((p)->table_ref)
#define srlid_get_key_ref(p)	((p)->key_ref)
#define srlid_get_cur_val(p)	((p)->cur_val)
#define srlid_get_increment(p)	((p)->increment)


/*
 ************************************************************************
 *                           Global Variables                           *       
 ************************************************************************
 */

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

extern int	srlid_init(DBS *dbs,  char *table_ref, char *key_ref,
		           unsigned long base, short incr);

extern int 	srlid_read_last(DBS *dbs, char *table_ref, 
		                char *key_ref, LANA *sid);

extern int	srlid_get_next(DBS *dbs, char *table_ref, 
		               char *key_ref, LANA *sid);

extern int	srlid_fetch(DBS *dbs, char *table_ref, char *key_ref,
		            SRLID_FH srlid_fh, void *udata);

extern int	srlid_reset_base(DBS *dbs, char *table_ref, 
		                 char *key_ref, unsigned long base);

extern int	srlid_delete(DBS *dbs, char *table_ref, char *key_ref);


#endif

