home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 4 / CDPD_IV.bin / networking / dnet / dnet2.3.2 / amiga / lib / gccstuff.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-29  |  2.5 KB  |  99 lines

  1. #include "lib.h"
  2.  
  3. #ifndef IFDEBUG
  4. #ifdef DEBUG
  5. #define IFDEBUG(foo) foo
  6. #else
  7. #define IFDEBUG(foo)
  8. #endif
  9. #endif /* !IFDEBUG */
  10.  
  11.  
  12. #if 0  /* I got this put into libamiga.a */
  13. /* NewList initializes an empty list 
  14. ** New, empty lists, have the List point
  15. */
  16. #include <exec/lists.h>
  17. void NewList(struct List * list)
  18. {
  19.     list->lh_Head = (NODE *)&list->lh_Tail;    /* First node in the list */
  20.     list->lh_Tail = NULL;            /* Always null? */
  21.     list->lh_TailPred = (NODE *)&list->lh_Head; /* Last node in the list */
  22.     list->lh_Type = NT_UNKNOWN;    /* some bogus type for the list */
  23.     list->l_pad  = 0;        /* not actually used except for alignment */
  24.     /* odd that the headers define it as l_pad instead of lh_Pad */
  25. }
  26. #endif
  27.  
  28. #include <signal.h>
  29.  
  30. /* DICE signal handling compatibility? */
  31. onbreak( void * proc() ){
  32.     signal(SIGTERM, proc);
  33. }
  34.  
  35. /* 
  36. ** move bytes of memory from area pointed to by foo to area pointed to by bar 
  37. ** should probably be done via a macro call instead...
  38. */
  39. void * BMov( void * src, void * dst, int bytes ){
  40.     /* memmove( dst, src, bytes); -- supports overlapping memory  */
  41.     CopyMem(src, dst, bytes);   /* Faster, doesn't support overlapping */
  42. }
  43.  
  44. /* return pointer to 'head' Node of list? 
  45. ** NULL if it's empty 
  46. **
  47. */
  48. struct Node * GetHead( struct List *ListPtr ){
  49.     struct Node *node_pointer = NULL;
  50.  
  51.     IFDEBUG(struct Node * node_pointer2   = NULL;)
  52.  
  53.     IFDEBUG(printf("GetHead() called ");)
  54.  
  55.     if(IsListEmpty(ListPtr)) {
  56.     IFDEBUG(printf("- empty list\n");)
  57.     return(NULL);
  58.     }
  59.  
  60. #ifdef DEBUG
  61.     /*
  62.     ** Here implemented in a rather amusing but crude manner:
  63.     ** remove it from the list with RemHead() and then put it back!
  64.     */
  65.     node_pointer2 = RemHead( ListPtr);
  66.     if(node_pointer2 != NULL)
  67.         AddHead( ListPtr, node_pointer2);
  68.     /* return(node_pointer2); */
  69. #endif /* DEBUG */
  70.  
  71.     /* more efficient method: */
  72.     if( ListPtr->lh_Head == ( NODE *) &ListPtr->lh_Tail){ 
  73.     /* check for empty list */
  74.     node_pointer = NULL;
  75.     }else{
  76.     node_pointer =  ListPtr->lh_Head;  /* head pointer */
  77.     }
  78.  
  79. #ifdef DEBUG
  80.     if(node_pointer2 != node_pointer){
  81.     printf(" generated odd result...  %x %x\n", 
  82.         node_pointer, node_pointer2);
  83.     }
  84.     IFDEBUG(else printf("ok result\n");)
  85. #endif /* DEBUG */
  86.  
  87.     return node_pointer;
  88. }
  89.  
  90. #ifndef GetSucc    
  91. /* should be defined as a macro in "dnet/dnet.h" */
  92.  
  93. /* return next node in the list */
  94. struct Node * GetSucc( struct Node * testnode){
  95.     if(testnode == NULL) return NULL;
  96.     return testnode->ln-Succ;
  97. }
  98. #endif 
  99.