/********************************************************************
 *
 * Implementation of the adaptive algorithm for determining
 * strings from substrings.
 * Prefix tree version.
 *
 * Includes header file.
 *
 * (C) February - December 1994, Dimitris Margaritis, Steven Skiena
 *
 * $Id: includes.h,v 2.3 1995/04/18 21:34:53 dmarg Exp dmarg $
 *
 ********************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <malloc.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>

#define MOREDEBUG		/* Skiena and Bradley 2/5/96 */
#ifdef MOREDEBUG
#ifndef DEBUG
#define DEBUG
#endif
#endif

#define MIN(a, b) ((a) <= (b) ? (a) : (b))

#define STREE_INFINITY INT_MAX
#define STREE_COUNT_INFINITY (-1)

typedef struct node {
    int depth;              /* How many chars this node is from the root. */
    struct node *suff_link; /* Pointer to my prev-to-last node in prefix. */
    struct arc **arcarray;  /* Array of downward arcs. */
} NODE;

typedef struct arc {
    int first;  /* First pos of the string for this arc. */
    int last;   /* Last pos of the string for this arc. */
    NODE *comesfrom; /* Node that this arc is coming from. */
    NODE *pointsto;  /* Node that this arc leads to. */
} ARC;
    

typedef enum {FALSE = 0, TRUE = 1} BOOL;

extern char *getmem(unsigned);
extern int stree_count_strings(unsigned, unsigned, int);
extern void stree_print_strings(NODE *, unsigned, unsigned, char *, unsigned);
extern NODE *node_create(void);
extern void stree_destroy(NODE *);
extern ARC *arc_create(int, NODE *, NODE *);
extern NODE *stree_create_node(NODE *, int, int);
extern BOOL end_point(NODE *, int, int, char);
extern NODE *create_node(void);
extern ARC *create_arc(int, int, NODE *, NODE *);
extern NODE *stree_create_node(NODE *, int, int);
extern void canonise(NODE *, int, int, NODE **, int *);
extern void update(NODE *, int, int, NODE **, int *);
extern NODE *create_suffix_tree();
extern void print_suffix_tree(NODE *, unsigned);

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