4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 #pragma ident "%Z%%M% %I% %E% SMI"
34 add_recip, madd_recip - add recipients to recipient list
37 int add_recip(reciplist *plist, char *name, int checkdups)
38 void madd_recip(reciplist *plist, char *name, int checkdups)
41 add_recip() adds the name to the recipient linked list.
42 If checkdups is set, it first checks to make certain that
43 the name is not in the list.
45 madd_recips() is given a list of names separated by white
46 space. Each name is split off and passed to add_recips.
52 add_recip(reciplist
*plist
, char *name
, int checkdups
)
55 static char pn
[] = "add_recip";
56 recip
*r
= &plist
->recip_list
;
58 if ((name
== (char *)NULL
) || (*name
== '\0')) {
59 Tout(pn
, "translation to NULL name ignored\n");
64 while (*p
&& !isspace(*p
)) {
68 Tout(pn
, "'%s' not added due to imbedded spaces\n", name
);
72 if (checkdups
== TRUE
) {
73 while (r
->next
!= (struct recip
*)NULL
) {
75 if (strcmp(r
->name
, name
) == 0) {
76 Tout(pn
, "duplicate recipient '%s' not added to list\n",
83 if ((p
= malloc (sizeof(struct recip
))) == (char *)NULL
) {
84 errmsg(E_MEM
,"first malloc failed in add_recip()");
87 plist
->last_recip
->next
= (struct recip
*)p
;
88 r
= plist
->last_recip
= plist
->last_recip
->next
;
89 if ((r
->name
= malloc (strlen(name
)+1)) == (char *)NULL
) {
90 errmsg(E_MEM
,"second malloc failed in add_recip()");
93 strcpy (r
->name
, name
);
94 r
->next
= (struct recip
*)NULL
;
95 Tout(pn
, "'%s' added to recipient list\n", name
);
101 madd_recip(reciplist
*plist
, char *namelist
, int checkdups
)
104 for (name
= strtok(namelist
, " \t"); name
; name
= strtok((char*)0, " \t"))
105 add_recip(plist
, name
, checkdups
);