PROJECT        arboo_server
OBJECT_KEY     AN,             # MAIN PREFIX
MAX_KEY        21,             # MAX NUMBER OF AN ATTRIBUTE
MAX_OBJECT     4,              # MAX DIFFERENT USER STRUCTURES
MAX_STRING_LEN 1024,
MAX_PAR_CNT    16,
MAGIC_NUMBER   0x414e53,       # MAGIC_NUMBER 6 HEX DIGITS (see AISC/magic.lst@NAMESERVER)


SERVER_INCLUDES (~
#include <stdio.h>
#include <aisc.h>
#include <aisc_com.h>~)
INCLUDE_INCLUDES (~$$(#FILE aisc_include.header)~)

DATA {

# ********************************* USER DATA *******************************************

# ******************************* PRIVAT STRUCTURES: DO NOT CHANGE *********************************

@STRUCT, @SKEY, @SKEYC, @SDOCU;

dll_public, ,   ,   (~parent of dll (=DoubledLinkedList)~), {
@TYPE,         @IDENT, @REF, @ACC, @SAVE, @KEY,   @KEYC, @INIT, @DOCU;
t_key,         key,    t,    r,    ,      ,       ,      ,      (~The key~);
int,           cnt,    t,    r,    ,      CNT,    0,     ,      (~Number of elements~);
long,          hash,   t,    ,     ,      ,       ,      ,      (~Hash Table~);
dllheader_ext, parent, flt,  r,    ,      PARENT, 1,     ,      (~My Owner~);
dllheader_ext, last,   flt,  r,    ,      LAST,   2,     ,      (~Pointer to the last element~);
};


dll_header, COMMON, 0,  (~link header (should be head of each function)~), {
@TYPE,       @IDENT,             @REF, @ACC, @SAVE, @KEY,      @KEYC, @INIT, @DOCU;
t_key,       key,                t,    r,    ,      KEY,       0,     ,      (~The Key~);
aisc_string, aisc_get_keystring, %,    r,    ,      KEYSTRING, 1,     ,      (~THE STRING of the KEY~);
dll_public,  parent,             ls,   r,    ,      (~~),      2,     ,      (~Pointer to dll_public~);
aisc_string, ident,              t,    ,     1,     IDENT,     5,     ,      (~The ident [not necessary]~);
};


# ********************************* USER STRUCTURES *******************************************

AN_revers,  REVERS, 4,  (~revers mapping for shorts~), {
    @TYPE,       @IDENT,    @REF, @ACC, @SAVE, @KEY,       @KEYC,  @INIT,  @DOCU;
    dllh,        mh,        t,    ,     ,      (~~),       0,      ,       (~Header~);
    aisc_string, full_name, t,    rw,   ,      ,           ,       ,       (~the full name of a species~);
    aisc_string, acc,       t,    rw,   ,      ,           ,       ,       (~accession number~);
    aisc_string, add_id,    t,    rw,   ,      ,           ,       ,       (~additional id data~);
};

AN_shorts, SHORTS,  3,  (~a dictionary~), SAVEDIRECTION HORIZONTAL, {
    @TYPE,          @IDENT,         @REF,   @ACC,   @SAVE,  @KEY,       @KEYC,  @INIT,  @DOCU;
    dllh,           mh,             t,      ,       1,      (~~),       0,      ,       (~Header~);
    aisc_string,    full_name,      t,      r,      1,      FULL_NAME,  8,      ,       (~the full name of a species~);
    aisc_string,    acc,            t,      r,      1,      ACC,        9,      ,       (~accession number~);
    aisc_string,    add_id,         t,      r,      1,      ADDID,      10,     ,       (~additional id data~);
    aisc_string,    shrt,           t,      r,      1,      SHORT,      11,     ,       (~The Short~);
};


# called from code using id AN_LOCAL
# single functions: LOCAL_GET_SHORT LOCAL_DEL_SHORT

AN_local, LOCAL,    2,  (~local communication buffer~), {
    @TYPE,       @IDENT,     @REF, @ACC, @SAVE, @KEY,      @KEYC, @INIT,                   @DOCU;
    dllh,        mh,         t,    ,     ,      (~~),      0,     ,                        (~Header~);
    int,         socket,     t,    ,     ,      ,          ,      names_init_socket(THIS), (~the callback~), DESTROY names_destroy_socket(THIS);
    aisc_string, whoami,     t,    ,     ,      WHOAMI,    8,     ,                        (~who am i~);
    aisc_string, full_name,  t,    rw,   ,      FULL_NAME, 9,     "",                      (~the full name of a species~);
    aisc_string, acc,        t,    rw,   ,      ACCESSION, 10,    "",                      (~accession number~);
    aisc_string, add_id,     t,    rw,   ,      ADDID,     11,    "",                      (~additional id data~);
    aisc_string, advice,     t,    rw,   ,      ADVICE,    13,    "",                      (~advice for the short name~);
    aisc_string, get_short,  %,    r,    ,      GET_SHORT, 14,    ,                        (~get a short name~);
    int,         del_short,  %,    r,    ,      DEL_SHORT, 15,    ,                        (~forget stored short name~);
};


# called from code using id AN_MAIN
# single functions: MAIN_SHUTDOWN MAIN_SAVEALL

AN_main, MAIN, 1, (~global data~), SAVEDIRECTION VERTICAL, {
    @TYPE,          @IDENT,            @REF,  @ACC,   @SAVE,  @KEY,       @KEYC,  @INIT,  @DOCU;
    t_key,          key,               t,     n,      ,       ,           ,       ,       (~the KEY~);
    AN_local,       loc_st,            d,     ,       ,       LOCAL,      8,      ,       (~the parameters~);
    AN_shorts,      shorts1,           d,     r,      1,      SHORTS1,    10,     ,       (~the unique letters for a word~);
    AN_shorts,      names,             d,     r,      1,      NAMES,      12,     ,       (~the unique names first*second*S*accession~);
    AN_revers,      revers,            d,     r,      ,       ,           ,       ,       (~the revers unique names first*second*S*accession~);
    int,            touched,           t,     r,      ,       TOUCHED,    14,     0,      (~does the database need to be saved?~);
    aisc_string,    server_shutdown,   %,     w,      ,       SHUTDOWN,   15,     ,       (~SHUTDOWN command~);
    int,            server_save,       %,     w,      ,       SAVEALL,    16,     ,       (~SAVE everything~);
    aisc_string,    server_file,       t,     r,      ,       FILENAME,   17,     ,       (~The filename of the keys~);
    int,            server_filedate,   t,     ,       ,       FILEDATE,   18,     ,       (~The filedate of server_file~);
    int,            dbversion,         t,     ,       1,      DBVERSION,  19,     4,      (~Nameserver database version~);
    aisc_string,    add_field,         t,     r,      1,      ADD_FIELD,  20,     ,       (~additional field used for identification~);
    aisc_string,    add_field_default, t,     r,      1,      AF_DEFAULT, 21,     ,       (~default value for add_field, if field is missing~);
    long,           prefix_hash,       t,     ,       ,       ,           ,       0,      (~prefix hash table~)
    };
};
