1/*++ 2/* NAME 3/* dict_static 3 4/* SUMMARY 5/* dictionary manager interface to static variables 6/* SYNOPSIS 7/* #include <dict_static.h> 8/* 9/* DICT *dict_static_open(name, name, dict_flags) 10/* const char *name; 11/* int dummy; 12/* int dict_flags; 13/* DESCRIPTION 14/* dict_static_open() implements a dummy dictionary that returns 15/* as lookup result the dictionary name, regardless of the lookup 16/* key value. 17/* SEE ALSO 18/* dict(3) generic dictionary manager 19/* LICENSE 20/* .ad 21/* .fi 22/* The Secure Mailer license must be distributed with this software. 23/* AUTHOR(S) 24/* jeffm 25/* ghostgun.com 26/*--*/ 27 28/* System library. */ 29 30#include "sys_defs.h" 31#include <stdio.h> /* sprintf() prototype */ 32#include <stdlib.h> 33#include <unistd.h> 34#include <string.h> 35 36/* Utility library. */ 37 38#include "mymalloc.h" 39#include "msg.h" 40#include "dict.h" 41#include "dict_static.h" 42 43/* dict_static_lookup - access static value*/ 44 45static const char *dict_static_lookup(DICT *dict, const char *unused_name) 46{ 47 DICT_ERR_VAL_RETURN(dict, DICT_ERR_NONE, dict->name); 48} 49 50/* dict_static_close - close static dictionary */ 51 52static void dict_static_close(DICT *dict) 53{ 54 dict_free(dict); 55} 56 57/* dict_static_open - make association with static variable */ 58 59DICT *dict_static_open(const char *name, int unused_flags, int dict_flags) 60{ 61 DICT *dict; 62 63 dict = dict_alloc(DICT_TYPE_STATIC, name, sizeof(*dict)); 64 dict->lookup = dict_static_lookup; 65 dict->close = dict_static_close; 66 dict->flags = dict_flags | DICT_FLAG_FIXED; 67 dict->owner.status = DICT_OWNER_TRUSTED; 68 return (DICT_DEBUG (dict)); 69} 70