1 /* $NetBSD: dict_cache.h,v 1.3 2026/05/09 18:49:22 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 extern int dict_cache_error(DICT_CACHE *); 37 38 #define DICT_CACHE_FLAG_VERBOSE (1<<0) /* verbose operation */ 39 #define DICT_CACHE_FLAG_STATISTICS (1<<1) /* log cache statistics */ 40 41 /* Legacy API: type-unchecked argument, internal use. */ 42 #define DICT_CACHE_CTL_END 0 /* list terminator */ 43 #define DICT_CACHE_CTL_FLAGS 1 /* see above */ 44 #define DICT_CACHE_CTL_INTERVAL 2 /* cleanup interval */ 45 #define DICT_CACHE_CTL_VALIDATOR 3 /* call-back validator */ 46 #define DICT_CACHE_CTL_CONTEXT 4 /* call-back context */ 47 48 /* Safer API: type-checked arguments, external use. */ 49 #define CA_DICT_CACHE_CTL_END DICT_CACHE_CTL_END 50 #define CA_DICT_CACHE_CTL_FLAGS(v) DICT_CACHE_CTL_FLAGS, CHECK_VAL(DICT_CACHE, int, (v)) 51 #define CA_DICT_CACHE_CTL_INTERVAL(v) DICT_CACHE_CTL_INTERVAL, CHECK_VAL(DICT_CACHE, int, (v)) 52 #define CA_DICT_CACHE_CTL_VALIDATOR(v) DICT_CACHE_CTL_VALIDATOR, CHECK_VAL(DICT_CACHE, DICT_CACHE_VALIDATOR_FN, (v)) 53 #define CA_DICT_CACHE_CTL_CONTEXT(v) DICT_CACHE_CTL_CONTEXT, CHECK_PTR(DICT_CACHE, void, (v)) 54 55 CHECK_VAL_HELPER_DCL(DICT_CACHE, int); 56 CHECK_VAL_HELPER_DCL(DICT_CACHE, DICT_CACHE_VALIDATOR_FN); 57 CHECK_PTR_HELPER_DCL(DICT_CACHE, void); 58 59 /* LICENSE 60 /* .ad 61 /* .fi 62 /* The Secure Mailer license must be distributed with this software. 63 /* AUTHOR(S) 64 /* Wietse Venema 65 /* IBM T.J. Watson Research 66 /* P.O. Box 704 67 /* Yorktown Heights, NY 10598, USA 68 /*--*/ 69 70 #endif 71