8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / man / man3nsl / getnetconfig.3nsl
blob08355211e1917c050f0d027b872932532e51b4cf
1 '\" te
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"
7 .SH NAME
8 getnetconfig, setnetconfig, endnetconfig, getnetconfigent, freenetconfigent,
9 nc_perror, nc_sperror \- get network configuration database entry
10 .SH SYNOPSIS
11 .LP
12 .nf
13 #include <netconfig.h>
18 \fBstruct netconfig *\fR\fBgetnetconfig\fR(\fBvoid *\fR\fIhandlep\fR);
19 .fi
21 .LP
22 .nf
23 \fBvoid *\fR\fBsetnetconfig\fR(\fBvoid\fR);
24 .fi
26 .LP
27 .nf
28 \fBint\fR \fBendnetconfig\fR(\fBvoid *\fR\fIhandlep\fR);
29 .fi
31 .LP
32 .nf
33 \fBstruct netconfig *\fR\fBgetnetconfigent\fR(\fBconst char *\fR\fInetid\fR);
34 .fi
36 .LP
37 .nf
38 \fBvoid\fR \fBfreenetconfigent\fR(\fBstruct netconfig *\fR\fInetconfigp\fR);
39 .fi
41 .LP
42 .nf
43 \fBvoid\fR \fBnc_perror\fR(\fBconst char *\fR\fImsg\fR);
44 .fi
46 .LP
47 .nf
48 \fBchar *\fR\fBnc_sperror\fR(\fBvoid\fR);
49 .fi
51 .SH DESCRIPTION
52 .sp
53 .LP
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).
60 .sp
61 .LP
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.
68 .sp
69 .LP
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.
76 .sp
77 .LP
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.
84 .sp
85 .LP
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).
89 .sp
90 .LP
91 \fBfreenetconfigent()\fR frees the netconfig structure pointed to by
92 \fInetconfigp\fR (previously returned by \fBgetnetconfigent()\fR).
93 .sp
94 .LP
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.
98 .sp
99 .LP
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
102 the error message.
105 \fBnc_perror()\fR and \fBnc_sperror()\fR can also be used with the
106 \fBNETPATH\fR access routines defined in \fBgetnetpath\fR(3NSL).
107 .SH RETURN VALUES
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
119 failure.
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
128 \fBNULL.\fR
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.
134 .SH ATTRIBUTES
137 See \fBattributes\fR(5) for descriptions of the following attributes:
142 box;
143 c | c
144 l | l .
145 ATTRIBUTE TYPE  ATTRIBUTE VALUE
147 MT-Level        MT-Safe
150 .SH SEE ALSO
153 \fBgetnetpath\fR(3NSL), \fBnetconfig\fR(4), \fBattributes\fR(5),
154 \fBenviron\fR(5)