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