
/*******************************************************************************
*
* File queries.h
*
* Copyright (C) 2005,2007 Martin Luescher
*
* This software is distributed under the terms of the GNU General Public
* License (GPL)
*
* Query descriptions
*
*******************************************************************************/

#define QUERIES_H

#if (defined FLAGS_C)

static int (*query_fcts[QUERIES])(void)={NULL};


static int QueryUAllocated(void)
{
   return (lat.u>0);
}

static int QueryUdAllocated(void)
{
   return (lat.ud>0);
}

static int QueryUMatchUd(void)
{
   return ((lat.u==lat.ud)&&(lat.bc==lat.bcd));
}

static int QueryBcFlipped(void)
{
   return lat.bc;
}

static int QueryBcdFlipped(void)
{
   return lat.bcd;
}

static int QueryUbufUp2date(void)
{
   return ((lat.u==lat.ubuf)&&(lat.bc==lat.bcbuf));
}

static int QueryUdbufUp2date(void)
{
   return ((lat.udbuf==lat.ud)&&(lat.bcdbuf==lat.bcd));
}

static int QuerySwUp2date(void)
{
   return ((lat.u>0)&&(lat.sw[0]==lat.u));
}

static int QuerySwEInverted(void)
{
   return (lat.sw[1]==1);
}

static int QuerySwOInverted(void)
{
   return (lat.sw[2]==1);
}

static int QuerySwdUp2date(void)
{
   return ((lat.ud>0)&&(lat.swd[0]==lat.ud));
}

static int QuerySwdEInverted(void)
{
   return (lat.swd[1]==1);
}

static int QuerySwdOInverted(void)
{
   return (lat.swd[2]==1);
}

static int QueryDflmodesInitialized(void)
{
   return (lat.dfl[0]>0);
}

static int QueryDflmodesUp2date(void)
{
   return ((lat.ud>0)&&(lat.dfl[0]==lat.ud)&&(lat.dfl[1]==lat.bcd));
}

static int QueryZopnohatdbleUp2date(void)
{
   return ((lat.zop[ZOPNOHAT_DBLE][0]==lat.ud)&&
           (lat.zop[ZOPNOHAT_DBLE][1]==lat.bcd));
}

static int QueryZophatdbleUp2date(void)
{
   return ((lat.zop[ZOPHAT_DBLE][0]==lat.ud)&&
           (lat.zop[ZOPHAT_DBLE][1]==lat.bcd));
}

static int QueryZopnohatUp2date(void)
{
   return ((lat.zop[ZOPNOHAT][0]==lat.ud)&&
           (lat.zop[ZOPNOHAT][1]==lat.bcd));   
}

static int QueryZophatUp2date(void)
{
   return ((lat.zop[ZOPHAT][0]==lat.ud)&&
           (lat.zop[ZOPHAT][1]==lat.bcd));   
}


static void set_queries(void)
{
   query_fcts[U_ALLOCATED]=QueryUAllocated;
   query_fcts[UD_ALLOCATED]=QueryUdAllocated;
   query_fcts[U_MATCH_UD]=QueryUMatchUd;   
   query_fcts[BC_FLIPPED]=QueryBcFlipped;
   query_fcts[BCD_FLIPPED]=QueryBcdFlipped;
   query_fcts[UBUF_UP2DATE]=QueryUbufUp2date;
   query_fcts[UDBUF_UP2DATE]=QueryUdbufUp2date;
   query_fcts[SW_UP2DATE]=QuerySwUp2date;
   query_fcts[SW_E_INVERTED]=QuerySwEInverted;
   query_fcts[SW_O_INVERTED]=QuerySwOInverted;
   query_fcts[SWD_UP2DATE]=QuerySwdUp2date;
   query_fcts[SWD_E_INVERTED]=QuerySwdEInverted;
   query_fcts[SWD_O_INVERTED]=QuerySwdOInverted;
   query_fcts[DFLMODES_INITIALIZED]=QueryDflmodesInitialized;   
   query_fcts[DFLMODES_UP2DATE]=QueryDflmodesUp2date;
   query_fcts[ZOPNOHATDBLE_UP2DATE]=QueryZopnohatdbleUp2date;
   query_fcts[ZOPHATDBLE_UP2DATE]=QueryZophatdbleUp2date;
   query_fcts[ZOPNOHAT_UP2DATE]=QueryZopnohatUp2date;   
   query_fcts[ZOPHAT_UP2DATE]=QueryZophatUp2date;   
}

#endif
