1 /* $NetBSD: dict_cache.h,v 1.2 2017/02/14 01:16:49 christos Exp $ */ 2 3 #ifndef _DICT_CACHE_H_INCLUDED_ 4 #define _DICT_CACHE_H_INCLUDED_ 5 6 /*++ 7 /* NAME 8 /* dict_cache 3h 9 /* SUMMARY 10 /* External cache manager 11 /* SYNOPSIS 12 /* #include <dict_cache.h> 13 /* DESCRIPTION 14 /* .nf 15 16 /* 17 * Utility library. 18 */ 19 #include <dict.h> 20 #include <check_arg.h> 21 22 /* 23 * External interface. 24 */ 25 typedef struct DICT_CACHE DICT_CACHE; 26 typedef int (*DICT_CACHE_VALIDATOR_FN) (const char *, const char *, void *); 27 28 extern DICT_CACHE *dict_cache_open(const char *, int, int); 29 extern void dict_cache_close(DICT_CACHE *); 30 extern const char *dict_cache_lookup(DICT_CACHE *, const char *); 31 extern int dict_cache_update(DICT_CACHE *, const char *, const char *); 32 extern int dict_cache_delete(DICT_CACHE *, const char *); 33 extern int dict_cache_sequence(DICT_CACHE *, int, const char **, const char **); 34 extern void dict_cache_control(DICT_CACHE *,...); 35 extern const char *dict_cache_name(DICT_CACHE *); 36 37 #define DICT_CACHE_FLAG_VERBOSE (1<<0) /* verbose operation */ 38 #define DICT_CACHE_FLAG_STATISTICS (1<<1) /* log cache statistics */ 39 40 /* Legacy API: type-unchecked argument, internal use. */ 41 #define DICT_CACHE_CTL_END 0 /* list terminator */ 42 #define DICT_CACHE_CTL_FLAGS 1 /* see above */ 43 #define DICT_CACHE_CTL_INTERVAL 2 /* cleanup interval */ 44 #define DICT_CACHE_CTL_VALIDATOR 3 /* call-back validator */ 45 #define DICT_CACHE_CTL_CONTEXT 4 /* call-back context */ 46 47 /* Safer API: type-checked arguments, external use. */ 48 #define CA_DICT_CACHE_CTL_END DICT_CACHE_CTL_END 49 #define CA_DICT_CACHE_CTL_FLAGS(v) DICT_CACHE_CTL_FLAGS, CHECK_VAL(DICT_CACHE, int, (v)) 50 #define CA_DICT_CACHE_CTL_INTERVAL(v) DICT_CACHE_CTL_INTERVAL, CHECK_VAL(DICT_CACHE, int, (v)) 51 #define CA_DICT_CACHE_CTL_VALIDATOR(v) DICT_CACHE_CTL_VALIDATOR, CHECK_VAL(DICT_CACHE, DICT_CACHE_VALIDATOR_FN, (v)) 52 #define CA_DICT_CACHE_CTL_CONTEXT(v) DICT_CACHE_CTL_CONTEXT, CHECK_PTR(DICT_CACHE, void, (v)) 53 54 CHECK_VAL_HELPER_DCL(DICT_CACHE, int); 55 CHECK_VAL_HELPER_DCL(DICT_CACHE, DICT_CACHE_VALIDATOR_FN); 56 CHECK_PTR_HELPER_DCL(DICT_CACHE, void); 57 58 /* LICENSE 59 /* .ad 60 /* .fi 61 /* The Secure Mailer license must be distributed with this software. 62 /* AUTHOR(S) 63 /* Wietse Venema 64 /* IBM T.J. Watson Research 65 /* P.O. Box 704 66 /* Yorktown Heights, NY 10598, USA 67 /*--*/ 68 69 #endif 70