1/* $NetBSD: mail_addr_form.c,v 1.2 2020/03/18 19:05:16 christos Exp $ */ 2 3/*++ 4/* NAME 5/* mail_addr_form 3 6/* SUMMARY 7/* mail address formats 8/* SYNOPSIS 9/* #include <mail_addr_form.h> 10/* 11/* int mail_addr_form_from_string(const char *addr_form_name) 12/* 13/* const char *mail_addr_form_to_string(int addr_form) 14/* DESCRIPTION 15/* mail_addr_form_from_string() converts a symbolic mail address 16/* form name ("internal", "external", "internal-first") into the 17/* corresponding internal code. The result is -1 if an unrecognized 18/* name was specified. 19/* 20/* mail_addr_form_to_string() converts from internal code 21/* to the corresponding symbolic name. The result is null if 22/* an unrecognized code was specified. 23/* LICENSE 24/* .ad 25/* .fi 26/* The Secure Mailer license must be distributed with this software. 27/* AUTHOR(S) 28/* Wietse Venema 29/* Google, Inc. 30/* 111 8th Avenue 31/* New York, NY 10011, USA 32/*--*/ 33 34 /* 35 * System library. 36 */ 37#include <sys_defs.h> 38 39 /* 40 * Utility library. 41 */ 42#include <name_code.h> 43 44 /* 45 * Global library. 46 */ 47#include <mail_addr_form.h> 48 49static const NAME_CODE addr_form_table[] = { 50 "external", MA_FORM_EXTERNAL, 51 "internal", MA_FORM_INTERNAL, 52 "external-first", MA_FORM_EXTERNAL_FIRST, 53 "internal-first", MA_FORM_INTERNAL_FIRST, 54 0, -1, 55}; 56 57/* mail_addr_form_from_string - symbolic mail address to internal form */ 58 59int mail_addr_form_from_string(const char *addr_form_name) 60{ 61 return (name_code(addr_form_table, NAME_CODE_FLAG_NONE, addr_form_name)); 62} 63 64const char *mail_addr_form_to_string(int addr_form) 65{ 66 return (str_name_code(addr_form_table, addr_form)); 67} 68