7 /* name to number table mapping
9 /* #include <name_code.h>
18 /* int name_code(table, flags, name)
19 /* const NAME_CODE *table;
23 /* const char *str_name_code(table, code)
24 /* const NAME_CODE *table;
27 /* This module does simple name<->number mapping. The process
28 /* is controlled by a table of (name, code) values.
29 /* The table is terminated with a null pointer and a code that
30 /* corresponds to "name not found".
32 /* name_code() looks up the code that corresponds with the name.
33 /* The lookup is case insensitive. The flags argument specifies
34 /* zero or more of the following:
35 /* .IP NAME_CODE_FLAG_STRICT_CASE
36 /* String lookups are case sensitive.
38 /* For convenience the constant NAME_CODE_FLAG_NONE requests
39 /* no special processing.
41 /* str_name_code() translates a number to its equivalent string.
43 /* When the search fails, the result is the "name not found" code
44 /* or the null pointer, respectively.
48 /* The Secure Mailer license must be distributed with this software.
51 /* IBM T.J. Watson Research
53 /* Yorktown Heights, NY 10598, USA
61 #ifdef STRCASECMP_IN_STRINGS_H
65 /* Utility library. */
67 #include <name_code.h>
69 /* name_code - look up code by name */
71 int name_code(const NAME_CODE
*table
, int flags
, const char *name
)
74 int (*lookup
) (const char *, const char *);
76 if (flags
& NAME_CODE_FLAG_STRICT_CASE
)
81 for (np
= table
; np
->name
; np
++)
82 if (lookup(name
, np
->name
) == 0)
87 /* str_name_code - look up name by code */
89 const char *str_name_code(const NAME_CODE
*table
, int code
)
93 for (np
= table
; np
->name
; np
++)