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 2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 #include <netconfig.h>
40 netcfg_free_networkid_list(char **netlist
, int num_elements
)
42 fileutil_free_string_array(netlist
, num_elements
);
43 } /* netcfg_free_networkid_list */
46 netcfg_get_networkid_list(int *num_elements
, int *errp
)
48 struct netconfig
*nconf
;
50 char **return_list
= NULL
;
53 * setnetconfig must be called before getnetconfig in order to get the
56 if ((nc
= setnetconfig()) == (NCONF_HANDLE
*)NULL
) {
62 while (nconf
= getnetconfig(nc
)) {
66 * Put the elements in the array.
68 tmp_list
= realloc(return_list
,
69 (size_t)(((*num_elements
)+1) * sizeof (char *)));
70 if (tmp_list
== NULL
) {
72 netcfg_free_networkid_list(return_list
, *num_elements
);
74 (void) endnetconfig(nc
);
78 return_list
= tmp_list
;
80 return_list
[(*num_elements
)] = strdup(nconf
->nc_netid
);
81 if (return_list
[(*num_elements
)] == NULL
) {
83 netcfg_free_networkid_list(return_list
, *num_elements
);
85 (void) endnetconfig(nc
);
89 *num_elements
= *num_elements
+ 1;
92 (void) endnetconfig(nc
);
94 * Caller must free the space allocated to return_list by calling
95 * netcfg_free_networkid_list.
98 } /* netcfg_get_networkid_list */