1 |
/* Mail processing routines for GNATS. |
/* Mail processing routines for GNATS. |
2 |
Copyright (C) 2000 Free Software Foundation, Inc. |
Copyright (C) 2000, 2002 Free Software Foundation, Inc. |
3 |
Contributed by Bob Manson (manson@juniper.net). |
Contributed by Bob Manson (manson@juniper.net). |
4 |
|
|
5 |
This file is part of GNU GNATS. |
This file is part of GNU GNATS. |
179 |
getOneAddress (const char **addrPtr) |
getOneAddress (const char **addrPtr) |
180 |
{ |
{ |
181 |
const char *addr = *addrPtr; |
const char *addr = *addrPtr; |
182 |
const char *addrStart = addr; |
const char *addrStart, *addrEnd; |
183 |
char *res; |
char *res; |
184 |
|
|
185 |
|
if (addrPtr == NULL || *addrPtr == NULL) |
186 |
|
{ |
187 |
|
return NULL; |
188 |
|
} |
189 |
|
|
190 |
|
/* skip over leading white space */ |
191 |
|
while (*addr && isspace(*addr)) |
192 |
|
{ |
193 |
|
addr++; |
194 |
|
} |
195 |
|
addrStart = addr; |
196 |
|
|
197 |
while (*addr != ',' && *addr != '\0') |
while (*addr != ',' && *addr != '\0') |
198 |
{ |
{ |
199 |
char nextc = '\0'; |
char nextc = '\0'; |
223 |
} |
} |
224 |
addr++; |
addr++; |
225 |
} |
} |
226 |
res = xstrndup (addrStart, addr - addrStart); |
addrEnd = addr; |
227 |
|
|
228 |
if (*addr != '\0') |
/* ignore any ending white space */ |
229 |
|
while (addr >= addrStart && isspace(*(addr-sizeof(*addr)))) |
230 |
{ |
{ |
231 |
addr++; |
addr--; |
|
} |
|
|
else |
|
|
{ |
|
|
addr = NULL; |
|
232 |
} |
} |
233 |
*addrPtr = addr; |
|
234 |
|
res = xstrndup (addrStart, addr - addrStart); |
235 |
|
|
236 |
|
*addrPtr = (*addrEnd == '\0') ? NULL : addrEnd+1; |
237 |
return res; |
return res; |
238 |
} |
} |
239 |
|
|
246 |
|
|
247 |
while (c != NULL) |
while (c != NULL) |
248 |
{ |
{ |
249 |
|
char *respaddr; |
250 |
char *addr = getOneAddress (&c); |
char *addr = getOneAddress (&c); |
251 |
char *respaddr = get_one_responsible_addr (database, full, strict, addr); |
if (addr == NULL || *addr == NULL) |
252 |
|
{ |
253 |
|
break; |
254 |
|
} |
255 |
|
respaddr = get_one_responsible_addr (database, full, strict, addr); |
256 |
|
|
257 |
if (respaddr != NULL) |
if (respaddr != NULL) |
258 |
{ |
{ |
259 |
if (res != NULL) |
if (res != NULL) |
260 |
{ |
{ |
261 |
append_string (&res, ", "); |
append_string (&res, ","); |
262 |
} |
} |
263 |
append_string (&res, respaddr); |
append_string (&res, respaddr); |
264 |
free (respaddr); |
free (respaddr); |