/* nato.h */
/* Definitions for numerical address table optimization package */


/* Include for the definition of Objid.	*/
#include <p_objid_type.h>

#define	NATOC_TABLE_FORM_LIST		0
#define	NATOC_TABLE_FORM_ARRAY		1

#define	NATOC_TWO_COMPONENT_ADDR	2
#define NATOC_ONE_COMPONENT_ADDR	1

#define	NATOC_INDEX_INVALID			-1
#define NATOC_TABLE_FORM_INVALID		-1
#define NATOC_TABLE_FORM_VALID			1
#define NATOC_TABLE_REGISTRATION_VALID	1

#define NATOC_LOWER_LAYER_ADDR_UNDEFINED	-2
#define	NATOC_LOWER_LAYER_ADDR_EXISTS		1
#define	NATOC_LOWER_LAYER_ADDR_DOES_NOT_EXIST	0

#define NATOC_NUM_LOWER_LAYER_ADDRS		3
#define NATOC_LOWER_LAYER_ADDR_TYPE_0		0
#define NATOC_LOWER_LAYER_ADDR_TYPE_1		1
#define NATOC_LOWER_LAYER_ADDR_TYPE_2		2

#define NATOC_LOWER_LAYER_ADDR_TYPE_INVALID	-3

/* Data Structures */
typedef struct
    {
    int							addr_major;
    int							addr_minor;
    int							lower_layer_addr [NATOC_NUM_LOWER_LAYER_ADDRS];
    }NatoT_Table_Entry;


typedef struct
    {
    List*			address_list;
    NatoT_Table_Entry**		address_array;
    int				array_size;
    int				table_form;
    char*			table_name;
    int				addr_component_count;
    }NatoT_Table;

typedef	NatoT_Table*				NatoT_Table_Handle;

/* Procedure Declarations */
NatoT_Table_Handle			nato_table_build_start();
void						nato_table_build_complete();
NatoT_Table_Handle			nato_table_handle_get();
int							nato_table_address_register();
int							nato_table_address_to_index();
int							nato_table_size();
int							nato_table_print();
int							nato_binary_tree_search();
int							nato_two_comp_addr_compare_proc();
int							nato_one_comp_addr_compare_proc();
int							nato_table_lower_layer_address_register ();
int							nato_table_lower_layer_address_lookup ();
int							nato_table_lower_layer_address_exists ();

/* ### fbasas: New nato table iterations functions. */
NatoT_Table_Entry *			nato_table_entry_get (NatoT_Table_Handle table_handle, int index);
int							nato_table_entry_major_addr_get (NatoT_Table_Entry *table_entry_ptr);
int							nato_table_entry_minor_addr_get (NatoT_Table_Entry *table_entry_ptr);
int							nato_table_entry_phys_addr_get (NatoT_Table_Entry *table_entry_ptr, 
	                            int phys_addr_type);
