4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <sys/types.h>
36 * Utility functions shared by sharemgr and sharectl.
40 * add_opt(optlist, optarg, security?)
41 * Add a new parsed option to the option list provided.
42 * If the option is a security option, only add if we are
43 * processing security options.
46 add_opt(struct options
**optlistp
, char *optarg
, int unset
)
48 struct options
*newopt
, *tmp
, *optlist
;
53 newopt
= (struct options
*)malloc(sizeof (struct options
));
55 return (OPT_ADD_MEMORY
);
57 /* extract property/value pair */
60 optvalue
= strchr(optname
, '=');
61 if (optvalue
== NULL
) {
63 return (OPT_ADD_SYNTAX
);
65 *optvalue
++ = '\0'; /* separate the halves */
70 newopt
->optname
= optname
;
71 newopt
->optvalue
= optvalue
;
73 if (optlist
== NULL
) {
76 for (tmp
= optlist
; tmp
->next
!= NULL
;
79 * Check to see if this is a duplicate
80 * value. We want to replace the first
81 * instance with the second.
83 if (strcmp(tmp
->optname
, optname
) == 0) {
84 tmp
->optvalue
= optvalue
;