home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #3 / amigamamagazinepolishissue1998.iso / bazy / carcosts / source / hook.c < prev    next >
C/C++ Source or Header  |  1996-11-02  |  8KB  |  258 lines

  1. #include "Demo.h"
  2. #include "Daten.h"  
  3. #include <exec/memory.h>
  4.  
  5. /*************************************************************************
  6.  *************************************************************************
  7.  *************************************************************************
  8.  
  9. Function: conhooktreib()
  10.  Constructs an entry for fuel list.
  11.  
  12. Return: LONG
  13.  
  14. Author: Rüdiger Dreier
  15.  
  16. History:
  17.  01.10.1993: Initial version
  18.  
  19.  *************************************************************************
  20.  *************************************************************************
  21.  *************************************************************************/
  22.  
  23.  __far __saveds __asm LONG conhooktreib(register __a0 struct Hook *hook,
  24.                                         register __a1 struct NodeTreib *treib,
  25.                                         register __a2 APTR mem)
  26.   {
  27.    struct NodeTreib *newtreib;
  28.    
  29.    newtreib = AllocVec(sizeof(struct NodeTreib),
  30.                        MEMF_CLEAR|MEMF_PUBLIC);
  31.    
  32.    if(newtreib)
  33.     {
  34.      *newtreib = *treib;
  35.     }
  36.    return((LONG) newtreib);
  37.   }
  38.  
  39.  
  40.  
  41.  
  42. /*************************************************************************
  43.  *************************************************************************
  44.  *************************************************************************
  45.  
  46. Function: deshooktreib()
  47.  Deletes an entry of fuel list.
  48.  
  49. Return: VOID
  50.  
  51. Author: Rüdiger Dreier
  52.  
  53. History:
  54.  01.10.1993: Initial version
  55.  
  56.  *************************************************************************
  57.  *************************************************************************
  58.  *************************************************************************/
  59.  
  60.  __far __saveds __asm VOID deshooktreib(register __a0 struct Hook *hook,
  61.                                         register __a1 struct NodeTreib *treib,
  62.                                         register __a2 APTR mem)
  63.   {
  64.    if(treib) FreeVec(treib);
  65.   }
  66.  
  67.  
  68.  
  69. /*************************************************************************
  70.  *************************************************************************
  71.  *************************************************************************
  72.  
  73. Function: cmphooktreib()
  74.  Compares two entries of fuel list. Entries are compared by date.
  75.  
  76. Return: VOID
  77.  
  78. Author: Rüdiger Dreier
  79.  
  80. History:
  81.  01.10.1993: Initial version
  82.  03.12.1993: Two entries for one date are sorted by kilometers
  83.  
  84.  *************************************************************************
  85.  *************************************************************************
  86.  *************************************************************************/
  87.  
  88.  __far __saveds __asm LONG cmphooktreib(register __a0 struct Hook *hook,
  89.                                         register __a1 struct NodeTreib *treib,
  90.                                         register __a2 struct NodeTreib *treib2)
  91.   {
  92.    if(treib->Days <  treib2->Days) return(-1L);
  93.    if(treib->Days == treib2->Days) 
  94.     {
  95.      if(treib->kmStand < treib2->kmStand) return(-1L);
  96.      if(treib->kmStand > treib2->kmStand) return(1L);
  97.      return(0L);
  98.     }
  99.    if(treib->Days >  treib2->Days) return(1L);
  100.   }
  101.  
  102.  
  103.  
  104.  
  105. /*************************************************************************
  106.  *************************************************************************
  107.  *************************************************************************
  108.  
  109. Function: disphooktreib()
  110.  Display hook function for fuel list
  111.  
  112. Return: VOID
  113.  
  114. Author: Rüdiger Dreier
  115.  
  116. History:
  117.  01.10.1993: Initial version
  118.  
  119.  *************************************************************************
  120.  *************************************************************************
  121.  *************************************************************************/
  122.  
  123.  __far __saveds __asm VOID disphooktreib(register __a0 struct Hook *hook,
  124.                                          register __a1 struct NodeTreib *treib,
  125.                                          register __a2 char **array)
  126.   {
  127.    *array++ = treib->Datum;
  128.    *array++ = treib->kmstring;
  129.    *array++ = treib->Preisstring;
  130.    *array++ = treib->Literstring;
  131.    *array++ = treib->deltakmstring;
  132.    *array   = treib->Verbrauchstring;
  133.   }
  134.  
  135.  
  136.  
  137.  
  138. /*************************************************************************
  139.  *************************************************************************
  140.  *************************************************************************
  141.  
  142. Function: conhookunter()
  143.  Constructs an entry for support list.
  144.  
  145. Return: LONG
  146.  
  147. Author: Rüdiger Dreier
  148.  
  149. History:
  150.  01.10.1993: Initial version
  151.  
  152.  *************************************************************************
  153.  *************************************************************************
  154.  *************************************************************************/
  155.  
  156.  __far __saveds __asm LONG conhookunter(register __a0 struct Hook *hook,
  157.                                         register __a1 struct NodeUnter *unter,
  158.                                         register __a2 APTR mem)
  159.   {
  160.    struct NodeUnter *newunter;
  161.    
  162.    newunter = AllocVec(sizeof(struct NodeUnter),
  163.                        MEMF_CLEAR|MEMF_PUBLIC);
  164.    
  165.    if(newunter)
  166.     {
  167.      *newunter = *unter;
  168.     }
  169.    return((LONG) newunter);
  170.   }
  171.  
  172.  
  173.  
  174. /*************************************************************************
  175.  *************************************************************************
  176.  *************************************************************************
  177.  
  178. Function: deshookunter()
  179.  Deletes an entry of support list.
  180.  
  181. Return: VOID
  182.  
  183. Author: Rüdiger Dreier
  184.  
  185. History:
  186.  01.10.1993: Initial version
  187.  
  188.  *************************************************************************
  189.  *************************************************************************
  190.  *************************************************************************/
  191.  
  192.  __far __saveds __asm VOID deshookunter(register __a0 struct Hook *hook,
  193.                                         register __a1 struct NodeUnter *unter,
  194.                                         register __a2 APTR mem)
  195.   {
  196.    if(unter) FreeVec(unter);
  197.   }
  198.  
  199.  
  200.  
  201. /*************************************************************************
  202.  *************************************************************************
  203.  *************************************************************************
  204.  
  205. Function: cmphookunter()
  206.  Compares two entries of support list. They are compared by date.
  207.  
  208. Return: LONG
  209.  
  210. Author: Rüdiger Dreier
  211.  
  212. History:
  213.  01.10.1993: Initial version
  214.  
  215.  *************************************************************************
  216.  *************************************************************************
  217.  *************************************************************************/
  218.  
  219.  __far __saveds __asm LONG cmphookunter(register __a0 struct Hook *hook,
  220.                                         register __a1 struct NodeUnter *unter,
  221.                                         register __a2 struct NodeUnter *unter2)
  222.   {
  223.    if(unter->Days <  unter2->Days) return(-1);
  224.    if(unter->Days == unter2->Days) return(0);
  225.    if(unter->Days >  unter2->Days) return(1);
  226.   }
  227.  
  228.  
  229.  
  230.  
  231. /*************************************************************************
  232.  *************************************************************************
  233.  *************************************************************************
  234.  
  235. Function: disphookunter()
  236.  Display hook function for support list.
  237.  
  238. Return: VOID
  239.  
  240. Author: Rüdiger Dreier
  241.  
  242. History:
  243.  01.10.1993: Initial version
  244.  
  245.  *************************************************************************
  246.  *************************************************************************
  247.  *************************************************************************/
  248.  
  249.  __far __saveds __asm VOID disphookunter(register __a0 struct Hook *hook,
  250.                                          register __a1 struct NodeUnter *unter,
  251.                                          register __a2 char **array)
  252.   {
  253.    *array++ = unter->Datum;
  254.    *array++ = unter->DispTitel;
  255.    *array++ = unter->DispRem;
  256.    *array   = unter->Preisstring;
  257.   }
  258.