home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / hacking / internet / desc03.sh / list.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-04  |  1.3 KB  |  47 lines

  1. /* list.h -    Definitions for list manipulation
  2.  *
  3.  * Copyright (c) 1991, 1992 Tim Cook.
  4.  * Non-profit distribution allowed.  See README for details.
  5.  *
  6.  * $Id: list.h,v 1.5 1992/12/02 03:54:10 tim Exp $
  7.  */
  8.  
  9. #ifndef _LIST_H_
  10. #define _LIST_H_
  11.  
  12. #include "config.h"
  13.  
  14. struct list {
  15.    VOID_PTR_PTR start ;        /* First element (NULL if empty) */
  16.    VOID_PTR_PTR end ;        /* Last element */
  17.    VOID_PTR_PTR s_start ;    /* Beginning of storage */
  18.    VOID_PTR_PTR s_end ;        /* Just past end of storage */
  19.    VOID_PTR_PTR data ;        /* List of pointers to blocks of storage to
  20.                    hold data pointed to by list items. */
  21.    } ;
  22.  
  23. #define list_init(l)    ((l)->start = (l)->data = (VOID_PTR_PTR) 0)
  24.  
  25. /*
  26.  * NOTE:  For list_elements to work, we must be able to cast
  27.  * VOID_PTR_PTR to "unsigned long" without losing anything.
  28.  */
  29.  
  30. #define list_elements(l) \
  31.        ((l)->start ? ((unsigned long) (l)->end - (unsigned long) \
  32.           (l)->start) / sizeof (VOID_PTR_PTR) : 0)
  33. #define list_element(l,n) \
  34.        ((l)->start ? (l)->start[n] : (VOID_PTR) 0)
  35. #define list_empty(l) \
  36.        ((l)->start == (VOID_PTR_PTR) 0)
  37.  
  38. #ifndef _LIST_C_
  39. extern VOID list_push () ;
  40. extern VOID_PTR list_pop () ;
  41. extern VOID_PTR list_shift () ;
  42. extern VOID list_sort () ;
  43. extern VOID list_free () ;
  44. #endif    /* _LIST_C_ */
  45.  
  46. #endif    /* _LIST_H_ */
  47.