home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 074.lha / Exec / ListInts.c < prev    next >
C/C++ Source or Header  |  1986-11-20  |  2KB  |  126 lines

  1. /*
  2.  *    ListInts.c
  3.  *
  4.  *    This program produces a list of interrupt handlers on it's standard
  5.  *    output.
  6.  *
  7.  *    Program        Date        Action
  8.  *    D. Thomas    25 April 1987    v1.0 Initial Coding.
  9.  *
  10.  */
  11.  
  12. #include "exec/execbase.h"
  13. #include "exec/memory.h"
  14. #include "functions.h"
  15.  
  16. extern struct ExecBase *SysBase;    /* Exec's base ptr */
  17.  
  18. main ()
  19.  
  20. {
  21.  
  22.   register struct Interrupt *t;       /* ptr to int list */
  23.   register struct List       head;    /* for my copy of the int list */
  24.  
  25.   NewList (&head);
  26.  
  27.   Disable ();
  28.  
  29.   if (getlist (&SysBase->IntrList, &head))
  30.     cleanup (&head);
  31.  
  32.   Enable ();
  33.  
  34.   puts ("Prty Code Vec Data Vec Name");
  35.  
  36.   while (t = (struct Interrupt *) RemHead (&head)) {
  37.  
  38.     printf ("%4d %8lx %8lx %s\n",
  39.       t->is_Code, t->is_Data,
  40.       (t->is_Node.ln_Name ? t->is_Node.ln_Name : "<unset>"));
  41.     
  42.     if (t->is_Node.ln_Name)
  43.       FreeMem (t->is_Node.ln_Name, (long) strlen (t->is_Node.ln_Name) + 1);
  44.     FreeMem (t, (long) sizeof *t);
  45.  
  46.   }
  47.  
  48.   exit (0);
  49.  
  50. }
  51.  
  52. freelist (l)
  53.  
  54. struct List *l;
  55.  
  56. {
  57.  
  58.   struct Interrupt *t;
  59.  
  60.   while (t = (struct Interrupt *) RemHead (l)) {
  61.     if (t->is_Node.ln_Name)
  62.       FreeMem (t->is_Node.ln_Name, (long) strlen (t->is_Node.ln_Name) + 1);
  63.     FreeMem (t, (long) sizeof *t);
  64.   }
  65.  
  66. }
  67.  
  68. cleanup (l)
  69.  
  70. struct List *l;
  71.  
  72. {
  73.  
  74.   Enable ();
  75.   freelist (l);
  76.   puts ("Out of Memory!");
  77.   exit (0);
  78.  
  79. }
  80.  
  81. getlist (tl, l)
  82.  
  83. struct List *tl;
  84. struct List *l;
  85.  
  86. {
  87.  
  88.   register struct Interrupt *t;
  89.  
  90.   for (t = (struct Interrupt *) tl->lh_Head;
  91.        t->is_Node.ln_Succ;
  92.        t = (struct Interrupt *) t->is_Node.ln_Succ)
  93.     if (onenode (t, l))
  94.       return TRUE;
  95.  
  96.   return FALSE;
  97.  
  98. }
  99.  
  100. onenode (t, l)
  101.  
  102. struct Interrupt *t;
  103. struct List      *l;
  104.  
  105. {
  106.  
  107.   register struct Interrupt *tc;
  108.  
  109.   if (!(tc = (struct Interrupt *) AllocMem ((long) sizeof *t, MEMF_CLEAR)))
  110.       return TRUE;
  111.   *tc = *t;
  112.  
  113.   if (t->is_Node.ln_Name) {
  114.     if (!(tc->is_Node.ln_Name = (char *) AllocMem ((long) strlen (t->is_Node.ln_Name) + 1, 0L))) {
  115.       FreeMem (tc, (long) sizeof *tc);
  116.       return TRUE;
  117.     }
  118.     strcpy (tc->is_Node.ln_Name, t->is_Node.ln_Name);
  119.   }
  120.  
  121.   AddTail (l, tc);
  122.  
  123.   return FALSE;
  124.  
  125. }
  126.