#include "Demo.h"
#include "Daten.h"  
#include <exec/memory.h>
 
/*************************************************************************
 *************************************************************************
 *************************************************************************

Function: conhooktreib()
 Constructs an entry for fuel list.

Return: LONG

Author: Rüdiger Dreier

History:
 01.10.1993: Initial version

 *************************************************************************
 *************************************************************************
 *************************************************************************/
 
 __far __saveds __asm LONG conhooktreib(register __a0 struct Hook *hook,
                                        register __a1 struct NodeTreib *treib,
                                        register __a2 APTR mem)
  {
   struct NodeTreib *newtreib;
   
   newtreib = AllocVec(sizeof(struct NodeTreib),
                       MEMF_CLEAR|MEMF_PUBLIC);
   
   if(newtreib)
    {
     *newtreib = *treib;
    }
   return((LONG) newtreib);
  }
 
 
 
 
/*************************************************************************
 *************************************************************************
 *************************************************************************

Function: deshooktreib()
 Deletes an entry of fuel list.

Return: VOID

Author: Rüdiger Dreier

History:
 01.10.1993: Initial version

 *************************************************************************
 *************************************************************************
 *************************************************************************/
 
 __far __saveds __asm VOID deshooktreib(register __a0 struct Hook *hook,
                                        register __a1 struct NodeTreib *treib,
                                        register __a2 APTR mem)
  {
   if(treib) FreeVec(treib);
  }
 
 
 
/*************************************************************************
 *************************************************************************
 *************************************************************************

Function: cmphooktreib()
 Compares two entries of fuel list. Entries are compared by date.

Return: VOID

Author: Rüdiger Dreier

History:
 01.10.1993: Initial version
 03.12.1993: Two entries for one date are sorted by kilometers

 *************************************************************************
 *************************************************************************
 *************************************************************************/
 
 __far __saveds __asm LONG cmphooktreib(register __a0 struct Hook *hook,
                                        register __a1 struct NodeTreib *treib,
                                        register __a2 struct NodeTreib *treib2)
  {
   if(treib->Days <  treib2->Days) return(-1L);
   if(treib->Days == treib2->Days) 
    {
     if(treib->kmStand < treib2->kmStand) return(-1L);
     if(treib->kmStand > treib2->kmStand) return(1L);
     return(0L);
    }
   if(treib->Days >  treib2->Days) return(1L);
  }
 
 
 
 
/*************************************************************************
 *************************************************************************
 *************************************************************************

Function: disphooktreib()
 Display hook function for fuel list

Return: VOID

Author: Rüdiger Dreier

History:
 01.10.1993: Initial version

 *************************************************************************
 *************************************************************************
 *************************************************************************/
 
 __far __saveds __asm VOID disphooktreib(register __a0 struct Hook *hook,
                                         register __a1 struct NodeTreib *treib,
                                         register __a2 char **array)
  {
   *array++ = treib->Datum;
   *array++ = treib->kmstring;
   *array++ = treib->Preisstring;
   *array++ = treib->Literstring;
   *array++ = treib->deltakmstring;
   *array   = treib->Verbrauchstring;
  }
 
 
 
 
/*************************************************************************
 *************************************************************************
 *************************************************************************

Function: conhookunter()
 Constructs an entry for support list.

Return: LONG

Author: Rüdiger Dreier

History:
 01.10.1993: Initial version

 *************************************************************************
 *************************************************************************
 *************************************************************************/
 
 __far __saveds __asm LONG conhookunter(register __a0 struct Hook *hook,
                                        register __a1 struct NodeUnter *unter,
                                        register __a2 APTR mem)
  {
   struct NodeUnter *newunter;
   
   newunter = AllocVec(sizeof(struct NodeUnter),
                       MEMF_CLEAR|MEMF_PUBLIC);
   
   if(newunter)
    {
     *newunter = *unter;
    }
   return((LONG) newunter);
  }
 
 
 
/*************************************************************************
 *************************************************************************
 *************************************************************************

Function: deshookunter()
 Deletes an entry of support list.

Return: VOID

Author: Rüdiger Dreier

History:
 01.10.1993: Initial version

 *************************************************************************
 *************************************************************************
 *************************************************************************/
 
 __far __saveds __asm VOID deshookunter(register __a0 struct Hook *hook,
                                        register __a1 struct NodeUnter *unter,
                                        register __a2 APTR mem)
  {
   if(unter) FreeVec(unter);
  }
 
 
 
/*************************************************************************
 *************************************************************************
 *************************************************************************

Function: cmphookunter()
 Compares two entries of support list. They are compared by date.

Return: LONG

Author: Rüdiger Dreier

History:
 01.10.1993: Initial version

 *************************************************************************
 *************************************************************************
 *************************************************************************/
 
 __far __saveds __asm LONG cmphookunter(register __a0 struct Hook *hook,
                                        register __a1 struct NodeUnter *unter,
                                        register __a2 struct NodeUnter *unter2)
  {
   if(unter->Days <  unter2->Days) return(-1);
   if(unter->Days == unter2->Days) return(0);
   if(unter->Days >  unter2->Days) return(1);
  }
 
 
 
 
/*************************************************************************
 *************************************************************************
 *************************************************************************

Function: disphookunter()
 Display hook function for support list.

Return: VOID

Author: Rüdiger Dreier

History:
 01.10.1993: Initial version

 *************************************************************************
 *************************************************************************
 *************************************************************************/
 
 __far __saveds __asm VOID disphookunter(register __a0 struct Hook *hook,
                                         register __a1 struct NodeUnter *unter,
                                         register __a2 char **array)
  {
   *array++ = unter->Datum;
   *array++ = unter->DispTitel;
   *array++ = unter->DispRem;
   *array   = unter->Preisstring;
  }
