home *** CD-ROM | disk | FTP | other *** search
- #ifndef LIST_ALREADY_INCLUDED
-
- #ifndef FIFO
- #define FIFO 0
- #define LIFO 1
- #endif
-
- /* use macros for list_size and list_get_nth if LIST_MACROS is defined */
- #define LIST_MACROS
-
- typedef int list_data_type;
-
- typedef struct list_descriptor
- {
- int listdiscipline;
- list_data_type **list;
- list_data_type **listlast;
- list_data_type **listhead;
- list_data_type **listtail;
- } LIST;
-
- extern list_data_type *list_delete_nth();
- extern LIST *list_open();
- extern void list_close();
- extern int list_empty();
- extern list_data_type **list_next();
- extern list_data_type **list_prev();
- extern int list_full();
- extern list_data_type **list_push();
- extern list_data_type *list_pop();
- extern list_data_type *list_top();
- extern list_data_type **list_enqueue();
- extern list_data_type *list_dequeue();
- extern int list_discipline();
- extern list_data_type **list_put();
- extern list_data_type **list_put_nth();
- extern list_data_type *list_get();
- extern int list_copy();
-
- #ifndef LIST_MACROS
- extern list_data_type *list_get_nth();
- extern int list_size();
- #else
-
- /* list_size:
- returns the number of elements in the list
- */
- #define list_size(_ld) \
- ( \
- /* if */ ( (_ld) == NULL ) ? \
- (0) : \
- /* else if */ ( ((_ld)->listhead > (_ld)->listtail) ? \
- ( ((_ld)->listlast - (_ld)->listhead) + \
- ((_ld)->listtail - (_ld)->list) + 1 ) : \
- /* else */ ((_ld)->listtail - (_ld)->listhead) ) \
- )
-
- /* list_get_nth:
- returns the nth element in the list (doesn't delete it)
- */
- #define list_get_nth(_ld,_n) \
- (\
- /* if */ ((_n) >= list_size(_ld)) ? \
- ( (list_data_type *) NULL) : \
- /* else if */ ( (1 + (_ld)->listhead + (_n) - (_ld)->listlast <= 0) ? \
- (*(1 + (_n) + (_ld)->listhead)) : \
- /* else */ (*((_ld)->list + (1 + (_n) + (_ld)->listhead - (_ld)->listlast) - 1)) )\
- )
- #endif
-
- #define LIST_ALREADY_INCLUDED
-
-
- #endif
-