Commit eec08a29 eec08a292c5db2d27665e063e19128cdaf0dc000 by Sergey Poznyakoff

(mh_alias_expand): New function

(scan_addrs): Expand aliases
1 parent a371783e
...@@ -43,31 +43,28 @@ addrcp (list_t *list, char *addr, int isbcc) ...@@ -43,31 +43,28 @@ addrcp (list_t *list, char *addr, int isbcc)
43 static int 43 static int
44 ismydomain (char *p) 44 ismydomain (char *p)
45 { 45 {
46 char *domain; 46 const char *domain;
47 if (!p) 47 if (!p)
48 return 1; 48 return 1;
49 mu_get_user_email_domain (&domain); 49 mu_get_user_email_domain (&domain);
50 return strcasecmp (domain, p + 1) == 0; 50 return strcasecmp (domain, p + 1) == 0;
51 } 51 }
52 52
53 static void 53 int
54 scan_addrs (char *str, int isbcc) 54 mh_alias_expand (char *str, address_t *paddr, int *incl)
55 { 55 {
56 address_t addr = NULL, exaddr = NULL;
57 size_t i, count;
58 size_t argc; 56 size_t argc;
59 char **argv; 57 char **argv;
58 size_t i;
60 char *buf; 59 char *buf;
61 int rc; 60 address_t exaddr = NULL;
62 61
63 if (!str)
64 return;
65 argcv_get (str, ",", NULL, &argc, &argv); 62 argcv_get (str, ",", NULL, &argc, &argv);
66 for (i = 0; i < argc;) 63 for (i = 0; i < argc;)
67 { 64 {
68 if (i + 1 == argc) 65 if (i + 1 == argc)
69 { 66 {
70 if (mh_alias_get_address (argv[i], &exaddr) == 0) 67 if (mh_alias_get_address (argv[i], &exaddr, incl) == 0)
71 { 68 {
72 free (argv[i]); 69 free (argv[i]);
73 memcpy (&argv[i], &argv[i+1], 70 memcpy (&argv[i], &argv[i+1],
...@@ -79,7 +76,7 @@ scan_addrs (char *str, int isbcc) ...@@ -79,7 +76,7 @@ scan_addrs (char *str, int isbcc)
79 } 76 }
80 else if (argv[i + 1][0] == ',') 77 else if (argv[i + 1][0] == ',')
81 { 78 {
82 if (mh_alias_get_address (argv[i], &exaddr) == 0) 79 if (mh_alias_get_address (argv[i], &exaddr, incl) == 0)
83 { 80 {
84 free (argv[i]); 81 free (argv[i]);
85 free (argv[i+1]); 82 free (argv[i+1]);
...@@ -105,16 +102,32 @@ scan_addrs (char *str, int isbcc) ...@@ -105,16 +102,32 @@ scan_addrs (char *str, int isbcc)
105 { 102 {
106 int status; 103 int status;
107 argcv_string (argc, argv, &buf); 104 argcv_string (argc, argv, &buf);
108 if (status = address_create (&addr, buf)) 105 if (status = address_create (paddr, buf))
109 mh_error (_("Bad address `%s': %s"), buf, mu_strerror (status)); 106 mh_error (_("Bad address `%s': %s"), buf, mu_strerror (status));
110 free (buf); 107 free (buf);
111 } 108 }
112 109
113 argcv_free (argc, argv); 110 argcv_free (argc, argv);
114 111
115 address_union (&addr, exaddr); 112 address_union (paddr, exaddr);
116 address_destroy (&exaddr); 113 address_destroy (&exaddr);
117 114 return 0;
115 }
116
117
118 static void
119 scan_addrs (char *str, int isbcc)
120 {
121 address_t addr = NULL;
122 size_t i, count;
123 char *buf;
124 int rc;
125
126 if (!str)
127 return;
128
129 mh_alias_expand (str, &addr, NULL);
130
118 if (addr == NULL || address_get_count (addr, &count)) 131 if (addr == NULL || address_get_count (addr, &count))
119 return; 132 return;
120 133
...@@ -130,7 +143,7 @@ scan_addrs (char *str, int isbcc) ...@@ -130,7 +143,7 @@ scan_addrs (char *str, int isbcc)
130 } 143 }
131 144
132 p = strchr (buf, '@'); 145 p = strchr (buf, '@');
133 146
134 if (ismydomain (p)) 147 if (ismydomain (p))
135 addrcp (&local_rcp, buf, isbcc); 148 addrcp (&local_rcp, buf, isbcc);
136 else 149 else
......