8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / mail / add_recip.c
blob13fb8519b3224609ff0495b55bfcb6096c26e833
1 /*
2 * CDDL HEADER START
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
7 * with the License.
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]
20 * CDDL HEADER END
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"
33 NAME
34 add_recip, madd_recip - add recipients to recipient list
36 SYNOPSIS
37 int add_recip(reciplist *plist, char *name, int checkdups)
38 void madd_recip(reciplist *plist, char *name, int checkdups)
40 DESCRIPTION
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.
49 #include "mail.h"
51 int
52 add_recip(reciplist *plist, char *name, int checkdups)
54 char *p;
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");
60 return(0);
63 p = name;
64 while (*p && !isspace(*p)) {
65 p++;
67 if (*p != '\0') {
68 Tout(pn, "'%s' not added due to imbedded spaces\n", name);
69 return(0);
72 if (checkdups == TRUE) {
73 while (r->next != (struct recip *)NULL) {
74 r = r->next;
75 if (strcmp(r->name, name) == 0) {
76 Tout(pn, "duplicate recipient '%s' not added to list\n",
77 name);
78 return(0);
83 if ((p = malloc (sizeof(struct recip))) == (char *)NULL) {
84 errmsg(E_MEM,"first malloc failed in add_recip()");
85 done(1);
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()");
91 done(1);
93 strcpy (r->name, name);
94 r->next = (struct recip *)NULL;
95 Tout(pn, "'%s' added to recipient list\n", name);
97 return(1);
100 void
101 madd_recip(reciplist *plist, char *namelist, int checkdups)
103 char *name;
104 for (name = strtok(namelist, " \t"); name; name = strtok((char*)0, " \t"))
105 add_recip(plist, name, checkdups);