// -----------------------------------------------------------------
// Created automagically from ../names.aisc
// using aisc-script '../AISC/aisc.pa'
// DO NOT EDIT THIS FILE!!!
// -----------------------------------------------------------------

#ifndef AISC_GEN_SERVER_INCLUDED
#define AISC_GEN_SERVER_INCLUDED

typedef char       *aisc_string;
typedef const char *aisc_cstring;

#ifndef AISC_GLOBAL_H
#include <aisc_global.h>
#endif
// NAMES_COM/aisc_include.header [empty] 


// the keys
typedef enum enum_t_key {
    KEY_AN_COMMON = 0x10000*0,
    KEY_AN_REVERS = 0x10000*4,
    KEY_AN_SHORTS = 0x10000*3,
    KEY_AN_LOCAL  = 0x10000*2,
    KEY_AN_MAIN   = 0x10000*1,
    KEY_MAX
} t_key;

// forward decl dll types
struct dllpublic_ext;
struct dllheader_ext;

// "public" version of dll
struct dll_public { // parent of dll (=DoubledLinkedList)
    t_key          key;    // The key
    int            cnt;    // Number of elements
    long           hash;   // Hash Table
    dllheader_ext *parent; // My Owner
    dllheader_ext *last;   // Pointer to the last element
};
struct dll_header { // link header (should be head of each function)
    t_key        key;    // The Key
    dll_public  *parent; // Pointer to dll_public
    aisc_string  ident;  // The ident [not necessary]
};

template <typename USERTYPE>
struct dll {
    dll_header  mh; // ***ANOTHEROLIHACK**
    USERTYPE   *previous, *next;
    int get_count() const { return mh.parent ? mh.parent->cnt : 0; }
};

// "private" (i.e. real) version of dll (DoubledLinkedList)
struct dllpublic_ext : public dll_public { 
    dllheader_ext *first; 
};
// pseudo-base-class of dll<USERTYPE> (bit-equal)
struct dllheader_ext : dll<dllheader_ext> {}; // pseudo-base-class of dll<USERTYPE> (bit-equal)

// forward decl user datatypes
struct AN_revers;
struct AN_shorts;
struct AN_local;
struct AN_main;

// user defined datatypes
struct AN_revers : public dll<AN_revers> { // revers mapping for shorts
    aisc_string  full_name; // the full name of a species
    aisc_string  acc;       // accession number
    aisc_string  add_id;    // additional id data
};
struct AN_shorts : public dll<AN_shorts> { // a dictionary
    aisc_string  full_name; // the full name of a species
    aisc_string  acc;       // accession number
    aisc_string  add_id;    // additional id data
    aisc_string  shrt;      // The Short
};
struct AN_local : public dll<AN_local> { // local communication buffer
    int          socket;    // the callback
    aisc_string  whoami;    // who am i
    aisc_string  full_name; // the full name of a species
    aisc_string  acc;       // accession number
    aisc_string  add_id;    // additional id data
    aisc_string  advice;    // advice for the short name
};
struct AN_main { // global data
    t_key        key;               // the KEY
    dll_public   ploc_st;
    AN_local    *loc_st;            // the parameters
    dll_public   pshorts1;
    AN_shorts   *shorts1;           // the unique letters for a word
    dll_public   pnames;
    AN_shorts   *names;             // the unique names first*second*S*accession
    dll_public   prevers;
    AN_revers   *revers;            // the revers unique names first*second*S*accession
    int          touched;           // does the database need to be saved?
    aisc_string  server_file;       // The filename of the keys
    int          server_filedate;   // The filedate of server_file
    int          dbversion;         // Nameserver database version
    aisc_string  add_field;         // additional field used for identification
    aisc_string  add_field_default; // default value for add_field, if field is missing
    long         prefix_hash;       // prefix hash table
};

extern const char *aisc_server_error;

#else 
#error header included twice 
#endif // AISC_GEN_SERVER_INCLUDED
