list.h 765 B

123456789101112131415161718192021222324252627
  1. #ifndef NORCSID
  2. #define RCS_LIST "$Header$"
  3. #endif
  4. struct ca_elem {
  5. struct ca_elem *ca_next; /* The link */
  6. char *ca_cont; /* The contents */
  7. } ;
  8. struct ca_list {
  9. struct ca_elem *ca_first; /* The head */
  10. struct ca_elem *ca_last; /* The tail */
  11. } ;
  12. typedef struct ca_list list_head ; /* The decl. for headers */
  13. typedef struct ca_elem list_elem ; /* The decl. for elements */
  14. /* Some operations */
  15. /* Access */
  16. #define l_first(header) (header).ca_first
  17. #define l_next(elem) (elem).ca_next
  18. #define l_content(elem) (elem).ca_cont
  19. /* To be used for scanning lists, ptr is the running variable */
  20. #define scanlist(elem,ptr) \
  21. for ( ptr= elem ; ptr; ptr= l_next(*ptr) )