#ifndef MPLIB1_BPO_LIST #define MPLIB1_BPO_LIST /* ******************************************************************************* * Copyright (c) 1996 Martin Poole * ******************************************************************************* ** ** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! ** ** Any changes to be made to this file should first be checked with ** mplib1 source control for library integrity. ** ** mplib1 source control can be reached at mplib1@quatermass.co.uk ** * * $Source$ * $Author$ * $Date$ * $Revision$ * Purpose : * ******************************************************************************* * * Change History * * $Log$ * ******************************************************************************* */ #ident "$Header$" #ifdef CXREF #include #include #endif #ifndef MPLIB1_CONFIG #include #endif #ifndef MPLIB1_BPO_LOCK #include #endif /* ------------------------------------------------------------------ defines ------------------------------------------------------------------ */ #ifndef BIT #define BIT(n) (1<<(n)) #endif /* ------------------------------------------------------------------ structures ------------------------------------------------------------------ */ #ifdef STRICT #define BPO_NODE_TYPE bpo_Node_s #define BPO_LIST_TYPE bpo_List_s #else #define BPO_NODE_TYPE bpo_Node #define BPO_LIST_TYPE bpo_List #endif struct BPO_NODE_TYPE { off_t lno_me; off_t lno_Succ; off_t lno_Pred; off_t lno_Name; off_t lno_Item; off_t lno_List; int lno_Flags; }; struct BPO_LIST_TYPE { off_t lno_me; struct BPO_NODE_TYPE lno_Head; struct BPO_NODE_TYPE lno_Tail; int lno_Flags; int lno_count; unsigned long lno_serial_nbr; #ifndef LN_IGNORECASE #define LN_IGNORECASE BIT(0) #endif struct bpo_pid_lock lno_Pid_Lock; }; typedef struct BPO_NODE_TYPE bpo_Node_t; typedef struct BPO_LIST_TYPE bpo_List_t; /* The following two typedefs are now deprecated and may be removed in a later release of library */ #ifndef STRICT typedef struct BPO_NODE_TYPE bpo_Node; /* deprecated */ typedef struct BPO_LIST_TYPE bpo_List; /* deprecated */ #endif #define BPO_NODE_SIZE sizeof(bpo_Node_t) #define BPO_LIST_SIZE sizeof(bpo_List_t) #define BPO_REMOVE_NODES BIT(0) #define BPO_FREE_NODES BIT(1) #define BPO_FREE_ITEMS BIT(2) #define BPO_FREE_NAMES BIT(3) typedef void (*bpo_Walk_List_t) ( void *, void * ); typedef int (*bpo_Walk_List2_t) ( void *, void * ); typedef int (*bpo_Walk_List_N_t) ( bpo_Node_t *, void * ); typedef int (*bpo_Work_List_t) ( bpo_List_t *, void * ); typedef int (*bpo_Work_List2_t) ( bpo_List_t *, void *, void * ); typedef int (* bpo_sort_i_t)(const void *, const void *); typedef int (*p_func_t)(FILE *,const char *,...); /* ------------------------------------------------------------------ function definitions ------------------------------------------------------------------ */ extern bpo_Node_t * bpo_Init_Node( bpo_Node_t *node, const char *name, void *item ); extern bpo_List_t * bpo_Init_List( bpo_List_t *list, int flags ); extern bpo_Node_t * bpo_Remove_Node( bpo_Node_t *node1 ); extern bpo_Node_t * bpo_Remove_Head( bpo_List_t *list ); extern bpo_Node_t * bpo_Remove_Tail( bpo_List_t *list ); extern bpo_Node_t * bpo_Add_Node_After( bpo_Node_t *node1, bpo_Node_t *node2 ); extern bpo_Node_t * bpo_Add_Node_Before( bpo_Node_t *node1, bpo_Node_t *node2 ); extern bpo_Node_t * bpo_Add_Head( bpo_List_t *list, bpo_Node_t *node ); extern bpo_Node_t * bpo_Add_Tail( bpo_List_t *list, bpo_Node_t *node ); extern void * bpo_Find_Item_By_Name( bpo_List_t *list, const char *name ); extern void * bpo_Find_Next_Item_By_Name( bpo_Node_t *node, const char *name ); extern bpo_Node_t * bpo_Find_Node_By_Item( bpo_List_t *list, void *item ); extern void * bpo_Find_Item_From_Node( bpo_Node_t *node ); extern void * bpo_Remove_Head_Item( bpo_List_t *list ); extern void * bpo_Remove_Tail_Item( bpo_List_t *list ); extern void bpo_Walk_List( bpo_List_t *l_ptr, bpo_Walk_List_t disp, void *param ); extern int bpo_Walk_List2( bpo_List_t *l_ptr, bpo_Walk_List2_t disp, void *param ); extern int bpo_Walk_List_N( bpo_List_t *l_ptr, bpo_Walk_List_N_t disp, void *param ); extern int bpo_Work_List( bpo_List_t *list, bpo_Work_List_t work, void *param ); extern int bpo_Work_List2( bpo_List_t *list, bpo_Work_List2_t work, void *param1, void *param2 ); extern int bpo_May_Work_List( bpo_List_t *list, unsigned long *last_ser_nbr, bpo_Work_List_t work, void *param ); extern int bpo_May_Work_List2( bpo_List_t *list, unsigned long *last_ser_nbr, bpo_Work_List2_t work, void *param1, void *param2 ); extern unsigned long bpo_Touch_List( bpo_List_t *list ); extern int bpo_Any_In_List( bpo_List_t *list ); extern int bpo_Transfer_Lists( bpo_List_t *fl_ptr, bpo_List_t *tl_ptr ); extern int bpo_free_list_contents( bpo_List_t *blp ); extern void bpo_Free_Node( bpo_Node_t *bnp, int flags ); extern void bpo_Free_List( bpo_List_t *blp, int flags ); /* The following four functions are especially for the SODB initialisation code The object is being created and is not yet in the list of shared objects and so the base cannot be looked up and must be passed in explicitly Also, the Add_ functions assume that the nodes being added are new & clean */ extern bpo_Node_t * bpo_Init_Node_Raw( bpo_Node_t *node, const void *base, const char *name, const void *item ); extern bpo_List_t * bpo_Init_List_Raw( bpo_List_t *list, const void *base, int flags ); extern bpo_Node_t * bpo_Add_Head_Raw( bpo_List_t *list, const void *base, bpo_Node_t *node ); extern bpo_Node_t * bpo_Add_Tail_Raw( bpo_List_t *list, const void *base, bpo_Node_t *node ); /* And a couple of sort functions. */ extern int bpo_sort_i( bpo_List_t *sort_list, bpo_sort_i_t compar ); extern int bpo_sort_n( bpo_List_t *sort_list ); /* And for the suspicious */ extern int bpo_Validate_List( bpo_List_t *rlp ); extern int bpo_List_Chk( bpo_List_t *rlp, p_func_t p_func, FILE *fh ); extern int node_list_header( p_func_t p_func, FILE *fh ); extern int node_list_details( void *base, bpo_Node_t *bnp, p_func_t p_func, FILE *fh ); #endif /* -- End of File -- */