* Fix an error in compilation when Alpine is not built with S/MIME
[alpine.git] / pith / copyaddr.c
blob1c8a55652ccabc5632d4650f8ed11f79bdefc2a3
1 #if !defined(lint) && !defined(DOS)
2 static char rcsid[] = "$Id: copyaddr.c 761 2007-10-23 22:35:18Z hubert@u.washington.edu $";
3 #endif
5 /*
6 * ========================================================================
7 * Copyright 2006 University of Washington
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * ========================================================================
18 #include "../pith/headers.h"
19 #include "../pith/copyaddr.h"
23 * Copy the first address in list a and return it in allocated memory.
25 ADDRESS *
26 copyaddr(struct mail_address *a)
28 ADDRESS *new = NULL;
30 if(a){
31 new = mail_newaddr();
32 if(a->personal)
33 new->personal = cpystr(a->personal);
35 if(a->adl)
36 new->adl = cpystr(a->adl);
38 if(a->mailbox)
39 new->mailbox = cpystr(a->mailbox);
41 if(a->host)
42 new->host = cpystr(a->host);
44 new->next = NULL;
47 return(new);
52 * Copy the whole list a.
54 ADDRESS *
55 copyaddrlist(struct mail_address *a)
57 ADDRESS *new = NULL, *head = NULL, *current;
59 for(; a; a = a->next){
60 new = copyaddr(a);
61 if(!head)
62 head = current = new;
63 else{
64 current->next = new;
65 current = new;
69 return(head);