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