#ifndef MPLIB1_DL_LRU #define MPLIB1_DL_LRU /* ******************************************************************************* * 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: /home/cvs/cvsroot/onelan/onelan/src/mplib1/mplib1/dl_lru.h,v $ * $Author: mpoole $ * $Date: 2002/10/07 09:37:44 $ * $Revision: 1.2 $ * Purpose : External function definitions for Caching code * ******************************************************************************* * * Change History * * $Log: dl_lru.h,v $ * Revision 1.2 2002/10/07 09:37:44 mpoole * Initial checkin of mplib1-3.1.0 * * Revision 1.1 2002/10/07 09:37:00 mpoole * Initial checkin of mplib1-3.1.0 * * ******************************************************************************* */ #ident "$Header: /home/cvs/cvsroot/onelan/onelan/src/mplib1/mplib1/dl_lru.h,v 1.2 2002/10/07 09:37:44 mpoole Exp $" #ifdef CXREF #include #endif /* ------------------------------------------------------------------ defines ------------------------------------------------------------------ */ #ifndef BIT #define BIT(n) (1<<(n)) #endif /* Values to use when calling Cache_Init. If in doubt, use CACHE_USE_DEFAULT Any other value should set only one bit per mask group */ #define CACHE_USE_DEFAULT 0 #define CACHE_CACHE_ON BIT(0) #define CACHE_STAT_ONLY BIT(1) #define CACHE_IGNORE_CASE BIT(2) #define CACHE_CHECK_CASE BIT(3) #define CACHE_PRE_ALLOCATE BIT(4) #define CACHE_DEMAND_ALLOC BIT(5) #define CACHE_MISS_IGNORE BIT(6) #define CACHE_MISS_CACHE BIT(7) #define CACHE_INSERT_MANY BIT(8) #define CACHE_INSERT_SINGLE BIT(9) #define CACHE_FLUSHABLE BIT(10) #define CACHE_NO_FLUSH BIT(11) #define CACHE_DEFAULTS (CACHE_CACHE_ON | CACHE_IGNORE_CASE | CACHE_DEMAND_ALLOC | CACHE_MISS_IGNORE | CACHE_FLUSHABLE) #define CACHE_MODE_MASK (CACHE_CACHE_ON | CACHE_STAT_ONLY) #define CACHE_CASE_MASK (CACHE_IGNORE_CASE | CACHE_CHECK_CASE) #define CACHE_ALLOC_MASK (CACHE_PRE_ALLOCATE | CACHE_DEMAND_ALLOC) #define CACHE_MISS_MASK (CACHE_MISS_IGNORE | CACHE_MISS_CACHE) #define CACHE_INSERT_MASK (CACHE_INSERT_MANY | CACHE_INSERT_SINGLE) #define CACHE_FLUSH_MASK (CACHE_FLUSHABLE | CACHE_NO_FLUSH) #define CACHE_RANGE_DEFAULTS (CACHE_CACHE_ON | CACHE_DEMAND_ALLOC | CACHE_MISS_IGNORE | CACHE_INSERT_SINGLE | CACHE_FLUSHABLE) /* Find_Cache_Item return values These are specifically arranged in numerical ascending order to allow for sanity checks, or simple coding */ #define CACHE_COMPLETE_MISS -1 #define CACHE_MISSED 0 #define CACHE_FOUND_ITEM 1 #define CACHE_FOUND_MANY 2 /* search rule comparison methods */ #define SEARCH_EQ 0 #define SEARCH_GE 1 /* >= */ #define SEARCH_GT 2 /* > */ #define SEARCH_LE 3 /* <= */ #define SEARCH_LT 4 /* < */ #define SEARCH_NE 5 /* != */ #define NUM_SEARCH_COMPS 6 #define CACHE_ONE_OF_ONE ((char *)2) #define CACHE_ONE_OF_MANY ((char *)1) #define CACHE_END_OF_MANY (NULL) /* ------------------------------------------------------------------ structures ------------------------------------------------------------------ */ struct search_rule { char *field_name; int comparison_method; }; /* ------------------------------------------------------------------ function definitions ------------------------------------------------------------------ */ extern int Cache_Init( int default_flags ); extern int Create_Cache_List( const char *list_name, int max_items, int list_flags, size_t key_size, const char *format_str, const char *field_names ); extern int Create_Range_Cache( const char *list_name, int max_items, int list_flags, struct search_rule *srulep, const char *format_str, const char *field_names ); extern int Find_Cache_Item( const char *list_name, const void *list_key, const char *field_list, ... ); extern int Add_Cache_Item( const char *list_name, const void *list_key, ... ); extern int Cache_Complete_Miss( const char *list_name, const void *list_key ); extern int Cache_Stats( FILE *fp, const char *list_name, int contents ); extern int Cache_Flush( const char *list_name ); #endif /* -- End of File -- */