5
/* name to number table mapping
7
/* #include <name_code.h>
16
/* int name_code(table, flags, name)
21
/* const char *str_name_code(table, code)
25
/* This module does simple name<->number mapping. The process
26
/* is controlled by a table of (name, code) values.
27
/* The table is terminated with a null pointer and a code that
28
/* corresponds to "name not found".
30
/* name_code() looks up the code that corresponds with the name.
31
/* The lookup is case insensitive. The flags argument specifies
32
/* zero or more of the following:
33
/* .IP NAME_CODE_FLAG_STRICT_CASE
34
/* String lookups are case sensitive.
36
/* For convenience the constant NAME_CODE_FLAG_NONE requests
37
/* no special processing.
39
/* str_name_code() translates a number to its equivalend string.
41
/* When the search fails, the result is the "name not found" code
42
/* or the null pointer, respectively.
46
/* The Secure Mailer license must be distributed with this software.
49
/* IBM T.J. Watson Research
51
/* Yorktown Heights, NY 10598, USA
59
#ifdef STRCASECMP_IN_STRINGS_H
63
/* Utility library. */
65
#include <name_code.h>
67
/* name_code - look up code by name */
69
int name_code(NAME_CODE *table, int flags, const char *name)
72
int (*lookup) (const char *, const char *);
74
if (flags & NAME_CODE_FLAG_STRICT_CASE)
79
for (np = table; np->name; np++)
80
if (lookup(name, np->name) == 0)
85
/* str_name_code - look up name by code */
87
const char *str_name_code(NAME_CODE *table, int code)
91
for (np = table; np->name; np++)