(mu_address_set_personal)
(mu_address_set_comments): New functions
Showing
2 changed files
with
55 additions
and
2 deletions
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2005 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2000, 2005, 2006 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Lesser General Public | 5 | modify it under the terms of the GNU Lesser General Public |
... | @@ -72,6 +72,13 @@ extern int mu_address_union (mu_address_t *a, mu_address_t b); | ... | @@ -72,6 +72,13 @@ extern int mu_address_union (mu_address_t *a, mu_address_t b); |
72 | 72 | ||
73 | extern size_t mu_address_format_string (mu_address_t addr, char *buf, size_t buflen); | 73 | extern size_t mu_address_format_string (mu_address_t addr, char *buf, size_t buflen); |
74 | 74 | ||
75 | /* The following setters are not entirely orthogonal to their _get_ | ||
76 | counterparts. Only personal and comments parts can be set */ | ||
77 | extern int mu_address_set_personal (mu_address_t addr, size_t no, | ||
78 | const char *buf); | ||
79 | extern int mu_address_set_comments (mu_address_t addr, size_t no, | ||
80 | const char *buf); | ||
81 | |||
75 | #ifdef __cplusplus | 82 | #ifdef __cplusplus |
76 | } | 83 | } |
77 | #endif | 84 | #endif | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001, 2005 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2000, 2001, 2005, 2006 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Lesser General Public | 5 | modify it under the terms of the GNU Lesser General Public |
... | @@ -233,6 +233,29 @@ mu_address_get_personal (mu_address_t addr, size_t no, char *buf, size_t len, | ... | @@ -233,6 +233,29 @@ mu_address_get_personal (mu_address_t addr, size_t no, char *buf, size_t len, |
233 | } | 233 | } |
234 | 234 | ||
235 | int | 235 | int |
236 | mu_address_set_personal (mu_address_t addr, size_t no, const char *buf) | ||
237 | { | ||
238 | char *s; | ||
239 | mu_address_t subaddr; | ||
240 | |||
241 | if (addr == NULL) | ||
242 | return EINVAL; | ||
243 | |||
244 | subaddr = _address_get_nth (addr, no); | ||
245 | if (!subaddr) | ||
246 | return MU_ERR_NOENT; | ||
247 | |||
248 | s = strdup (buf); | ||
249 | if (!s) | ||
250 | return errno; | ||
251 | |||
252 | free (subaddr->personal); | ||
253 | subaddr->personal = s; | ||
254 | |||
255 | return 0; | ||
256 | } | ||
257 | |||
258 | int | ||
236 | mu_address_get_comments (mu_address_t addr, size_t no, char *buf, size_t len, | 259 | mu_address_get_comments (mu_address_t addr, size_t no, char *buf, size_t len, |
237 | size_t * n) | 260 | size_t * n) |
238 | { | 261 | { |
... | @@ -253,6 +276,29 @@ mu_address_get_comments (mu_address_t addr, size_t no, char *buf, size_t len, | ... | @@ -253,6 +276,29 @@ mu_address_get_comments (mu_address_t addr, size_t no, char *buf, size_t len, |
253 | } | 276 | } |
254 | 277 | ||
255 | int | 278 | int |
279 | mu_address_set_comments (mu_address_t addr, size_t no, const char *buf) | ||
280 | { | ||
281 | char *s; | ||
282 | mu_address_t subaddr; | ||
283 | |||
284 | if (addr == NULL) | ||
285 | return EINVAL; | ||
286 | |||
287 | subaddr = _address_get_nth (addr, no); | ||
288 | if (!subaddr) | ||
289 | return MU_ERR_NOENT; | ||
290 | |||
291 | s = strdup (buf); | ||
292 | if (!s) | ||
293 | return errno; | ||
294 | |||
295 | free (subaddr->comments); | ||
296 | subaddr->comments = s; | ||
297 | |||
298 | return 0; | ||
299 | } | ||
300 | |||
301 | int | ||
256 | mu_address_get_email (mu_address_t addr, size_t no, char *buf, size_t len, | 302 | mu_address_get_email (mu_address_t addr, size_t no, char *buf, size_t len, |
257 | size_t * n) | 303 | size_t * n) |
258 | { | 304 | { | ... | ... |
-
Please register or sign in to post a comment