/**********************************************************************
 
	Copyright (C) 2003 Hirohisa MORI <joshua@nichibun.ac.jp>
 
	This program is free software; you can redistribute it 
	and/or modify it under the terms of the GLOBALBASE 
	Library General Public License (G-LGPL) as published by 

	http://www.globalbase.org/
 
	This program is distributed in the hope that it will be 
	useful, but WITHOUT ANY WARRANTY; without even the 
	implied warranty of MERCHANTABILITY or FITNESS FOR A 
	PARTICULAR PURPOSE.

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



#ifndef ___DTREE_H___
#define ___DTREE_H___

#include	"favt.h"
#include	"long_char.h"

typedef struct dtree_node {
	L_CHAR			ch;
	unsigned int		tree;
	unsigned int		data;
} DTREE_NODE;


typedef struct dtree_trace_work {
	PDB * 			p;
	int 			(*func)();
	void *			w;
	int 			(*trace)();
	L_CHAR *		target;
} DTREE_TRACE_WORK;

void dtree_endian();
FAVT_ROOT * alloc_dtree(PDB * p,int type);
unsigned int search_dtree(int * errp,int * sizep,FAVT_ROOT * r,L_CHAR * str,int perfect_flag);
int dtree_trace_from_small(int * errp,FAVT_ROOT * r,int (*func)(),void * work);
int dtree_trace_from_large(int * errp,FAVT_ROOT * r,int (*func)(),void * work);
void change_endian_dtree_data_to_host(PN_DTREE_DATA * d);
void change_endian_dtree_data_to_net(PN_DTREE_DATA * d);
int dtree_cmp(DTREE_NODE * n1,DTREE_NODE * n2);
int data_segment(FAVT_ROOT * r,FAVT_NODE * n,unsigned int old,unsigned int data);
int insert_dtree(int * errp,FAVT_ROOT * r,L_CHAR * str,unsigned int old,unsigned int data);
int dtree_trace_func(int * errp,FAVT_NODE * a,DTREE_TRACE_WORK * w);

#endif

