/*******************************************/
/*                                         */
/*  File: tlstable.h                       */
/*  Purpose: Symbol Table routines         */
/*                                         */
/*  Author: Sfiligoi Igor                  */
/*                                         */
/*  Last modified: 10.10.1996              */
/*                                         */
/*******************************************/

#ifndef TL_STABLE_H
#define TL_STABLE_H

#define ST_OK		0
#define ST_Duplicate	-1
#define ST_NotFound	-2

#define ST_OK_Hit	1

/* Create a new Symbol Table of specified size*/
/* Size should be a primitive number in order to obtain good results (i.e. 211) */
/* if case_sensitive ==0 => case_insensitive */
/* Initialy it is empty */
/* Returns a pointer to the Symbol Table */

void *STableNew(unsigned int size,
                int case_sensitive);

/*Add name(max ST_varnamelng) to Symbol Table */
/*ST_Duplicate if error, ST_OK or ST_OK_Hit if OK */
/*ST_OK_Hit indicates a hash hit, this is not an error */
/* only speed penality */

int STableAdd(void *STable,	/* Symbol Table obtained from NewSTable() */
              char *name,	/* Name to add */
              void *data);	/* Data that you want to preserve */

/* Find name in the Symbol Table*/
/* Return ST_OK if found, ST_NotFound otherwise */

int STableFind(void *STable,	/* Symbol Table obtained from NewSTable() */
               char *name,	/* Name to find */
               void * *data);	/* OUT - Data of the found item */

/* Find name in the Symbol Table*/
/* and delete it from ST */
/* data must be be disposed by user */
/* Return ST_OK if found, ST_NotFound otherwise */

int STableCut(void *STable,	/* Symbol Table obtained from NewSTable() */
              char *name,	/* Name to find */
              void * *data);	/* OUT - Data of the found item */

/* Destroy a Symbol Table */
/* Call when you do not need the table anymore */

void STableDispose(void *STable,		/* Symbol Table obtained from NewSTable() */
                   void (*freedata)(void *));	/* function that disposes the data passed */

/***************************************************************************/

/* return a case insensitive string for case sensitive STable */
/* returned string must be freed by hand */

char *ST2insensitive(char *str);

#endif /* TL_STABLE_H */