2 .\" Copyright 1989 AT&T Copyright (c) 1997, Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH GETNETCONFIG 3NSL "Dec 30, 1996"
8 getnetconfig, setnetconfig, endnetconfig, getnetconfigent, freenetconfigent,
9 nc_perror, nc_sperror \- get network configuration database entry
13 #include <netconfig.h>
18 \fBstruct netconfig *\fR\fBgetnetconfig\fR(\fBvoid *\fR\fIhandlep\fR);
23 \fBvoid *\fR\fBsetnetconfig\fR(\fBvoid\fR);
28 \fBint\fR \fBendnetconfig\fR(\fBvoid *\fR\fIhandlep\fR);
33 \fBstruct netconfig *\fR\fBgetnetconfigent\fR(\fBconst char *\fR\fInetid\fR);
38 \fBvoid\fR \fBfreenetconfigent\fR(\fBstruct netconfig *\fR\fInetconfigp\fR);
43 \fBvoid\fR \fBnc_perror\fR(\fBconst char *\fR\fImsg\fR);
48 \fBchar *\fR\fBnc_sperror\fR(\fBvoid\fR);
54 The library routines described on this page are part of the Network Selection
55 component. They provide the application access to the system network
56 configuration database, \fB/etc/netconfig\fR. In addition to the routines for
57 accessing the \fBnetconfig\fR database, Network Selection includes the
58 environment variable \fBNETPATH\fR (see \fBenviron\fR(5)) and the
59 \fBNETPATH\fR access routines described in \fBgetnetpath\fR(3NSL).
62 \fBgetnetconfig()\fR returns a pointer to the current entry in the
63 \fBnetconfig\fR database, formatted as a \fBstruct netconfig\fR. Successive
64 calls will return successive \fBnetconfig\fR entries in the \fBnetconfig\fR
65 database. \fBgetnetconfig()\fR can be used to search the entire
66 \fBnetconfig\fR file. \fBgetnetconfig()\fR returns \fBNULL\fR at the end of
67 the file. \fIhandlep\fR is the handle obtained through \fBsetnetconfig()\fR.
70 A call to \fBsetnetconfig()\fR has the effect of ``binding'' to or
71 ``rewinding'' the \fBnetconfig\fR database. \fBsetnetconfig()\fR must be called
72 before the first call to \fBgetnetconfig()\fR and may be called at any other
73 time. \fBsetnetconfig()\fR need \fInot\fR be called before a call to
74 \fBgetnetconfigent()\fR. \fBsetnetconfig()\fR returns a unique handle to be
75 used by \fBgetnetconfig()\fR.
78 \fBendnetconfig()\fR should be called when processing is complete to release
79 resources for reuse. \fIhandlep\fR is the handle obtained through
80 \fBsetnetconfig()\fR. Programmers should be aware, however, that the last call
81 to \fBendnetconfig()\fR frees all memory allocated by \fBgetnetconfig()\fR for
82 the \fBstruct netconfig\fR data structure. \fBendnetconfig()\fR may not be
83 called before \fBsetnetconfig()\fR.
86 \fBgetnetconfigent()\fR returns a pointer to the \fBstruct netconfig\fR
87 structure corresponding to \fInetid\fR. It returns \fBNULL\fR if \fInetid\fR
88 is invalid (that is, does not name an entry in the \fBnetconfig\fR database).
91 \fBfreenetconfigent()\fR frees the netconfig structure pointed to by
92 \fInetconfigp\fR (previously returned by \fBgetnetconfigent()\fR).
95 \fBnc_perror()\fR prints a message to the standard error indicating why any of
96 the above routines failed. The message is prepended with the string \fImsg\fR
97 and a colon. A \fBNEWLINE\fR is appended at the end of the message.
100 \fBnc_sperror()\fR is similar to \fBnc_perror()\fR but instead of sending the
101 message to the standard error, will return a pointer to a string that contains
105 \fBnc_perror()\fR and \fBnc_sperror()\fR can also be used with the
106 \fBNETPATH\fR access routines defined in \fBgetnetpath\fR(3NSL).
110 \fBsetnetconfig()\fR returns a unique handle to be used by
111 \fBgetnetconfig()\fR. In the case of an error, \fBsetnetconfig()\fR returns
112 \fBNULL\fR and \fBnc_perror()\fR or \fBnc_sperror()\fR can be used to print
113 the reason for failure.
116 \fBgetnetconfig()\fR returns a pointer to the current entry in the
117 \fBnetconfig()\fR database, formatted as a \fBstruct netconfig\fR.
118 \fBgetnetconfig()\fR returns \fBNULL\fR at the end of the file, or upon
122 \fBendnetconfig()\fR returns \fB0\fR on success and \fB\(mi1\fR on failure (for
123 example, if \fBsetnetconfig()\fR was not called previously).
126 On success, \fBgetnetconfigent()\fR returns a pointer to the \fBstruct\fR
127 \fBnetconfig\fR structure corresponding to \fInetid\fR; otherwise it returns
131 \fBnc_sperror()\fR returns a pointer to a buffer which contains the error
132 message string. This buffer is overwritten on each call. In multithreaded
133 applications, this buffer is implemented as thread-specific data.
137 See \fBattributes\fR(5) for descriptions of the following attributes:
145 ATTRIBUTE TYPE ATTRIBUTE VALUE
153 \fBgetnetpath\fR(3NSL), \fBnetconfig\fR(4), \fBattributes\fR(5),