Blame man/getnetconfig.3t

Packit 00408a
.\" @(#)getnetconfig.3n 1.28 93/06/02 SMI; from SVr4
Packit 00408a
.\" Copyright 1989 AT&T
Packit 00408a
.Dd April 22, 2000
Packit 00408a
.Dt GETNETCONFIG 3
Packit 00408a
.Os
Packit 00408a
.Sh NAME
Packit 00408a
.Nm getnetconfig ,
Packit 00408a
.Nm setnetconfig ,
Packit 00408a
.Nm endnetconfig ,
Packit 00408a
.Nm getnetconfigent ,
Packit 00408a
.Nm freenetconfigent ,
Packit 00408a
.Nm nc_perror ,
Packit 00408a
.Nm nc_sperror
Packit 00408a
.Nd get network configuration database entry
Packit 00408a
.Sh SYNOPSIS
Packit 00408a
.In netconfig.h
Packit 00408a
.Ft "struct netconfig *"
Packit 00408a
.Fn getnetconfig "void *handlep"
Packit 00408a
.Ft "void *"
Packit 00408a
.Fn setnetconfig "void"
Packit 00408a
.Ft int
Packit 00408a
.Fn endnetconfig "void *handlep"
Packit 00408a
.Ft "struct netconfig *"
Packit 00408a
.Fn getnetconfigent "const char *netid"
Packit 00408a
.Ft void
Packit 00408a
.Fn freenetconfigent "struct netconfig *netconfigp"
Packit 00408a
.Ft void
Packit 00408a
.Fn nc_perror "const char *msg"
Packit 00408a
.Ft "char *"
Packit 00408a
.Fn nc_sperror "void"
Packit 00408a
.Sh DESCRIPTION
Packit 00408a
The library routines described on this page
Packit 00408a
provide the application access to
Packit 00408a
the system network configuration database,
Packit 00408a
.Pa /etc/netconfig .
Packit 00408a
The
Packit 00408a
.Fn getnetconfig
Packit 00408a
function
Packit 00408a
returns a pointer to the
Packit 00408a
current entry in the
Packit 00408a
netconfig
Packit 00408a
database, formatted as a
Packit 00408a
.Ft "struct netconfig" .
Packit 00408a
Successive calls will return successive netconfig
Packit 00408a
entries in the netconfig database.
Packit 00408a
The
Packit 00408a
.Fn getnetconfig
Packit 00408a
function
Packit 00408a
can be used to search the entire netconfig
Packit 00408a
file.
Packit 00408a
The
Packit 00408a
.Fn getnetconfig
Packit 00408a
function
Packit 00408a
returns
Packit 00408a
.Dv NULL
Packit 00408a
at the end of the file.
Packit 00408a
The
Packit 00408a
.Fa handlep
Packit 00408a
argument
Packit 00408a
is the handle obtained through
Packit 00408a
.Fn setnetconfig .
Packit 00408a
.Pp
Packit 00408a
A call to
Packit 00408a
.Fn setnetconfig
Packit 00408a
has the effect of
Packit 00408a
.Dq binding
Packit 00408a
to or
Packit 00408a
.Dq rewinding
Packit 00408a
the netconfig database.
Packit 00408a
The
Packit 00408a
.Fn setnetconfig
Packit 00408a
function
Packit 00408a
must be called before the first call to
Packit 00408a
.Fn getnetconfig
Packit 00408a
and may be called at any other time.
Packit 00408a
The
Packit 00408a
.Fn setnetconfig
Packit 00408a
function
Packit 00408a
need not be called before a call to
Packit 00408a
.Fn getnetconfigent .
Packit 00408a
The
Packit 00408a
.Fn setnetconfig
Packit 00408a
function
Packit 00408a
returns a unique handle to be used by
Packit 00408a
.Fn getnetconfig .
Packit 00408a
.Pp
Packit 00408a
The
Packit 00408a
.Fn endnetconfig
Packit 00408a
function
Packit 00408a
should be called when processing is complete to release resources for reuse.
Packit 00408a
The
Packit 00408a
.Fa handlep
Packit 00408a
argument
Packit 00408a
is the handle obtained through
Packit 00408a
.Fn setnetconfig .
Packit 00408a
Programmers should be aware, however, that the last call to
Packit 00408a
.Fn endnetconfig
Packit 00408a
frees all memory allocated by
Packit 00408a
.Fn getnetconfig
Packit 00408a
for the
Packit 00408a
.Ft "struct netconfig"
Packit 00408a
data structure.
Packit 00408a
The
Packit 00408a
.Fn endnetconfig
Packit 00408a
function
Packit 00408a
may not be called before
Packit 00408a
.Fn setnetconfig .
Packit 00408a
.Pp
Packit 00408a
The
Packit 00408a
.Fn getnetconfigent
Packit 00408a
function
Packit 00408a
returns a pointer
Packit 00408a
to the netconfig structure corresponding
Packit 00408a
to
Packit 00408a
.Fa netid .
Packit 00408a
It returns
Packit 00408a
.Dv NULL
Packit 00408a
if
Packit 00408a
.Fa netid
Packit 00408a
is invalid
Packit 00408a
(that is, does not name an entry in the netconfig database).
Packit 00408a
.Pp
Packit 00408a
The
Packit 00408a
.Fn freenetconfigent
Packit 00408a
function
Packit 00408a
frees the netconfig structure pointed to by
Packit 00408a
.Fa netconfigp
Packit 00408a
(previously returned by
Packit 00408a
.Fn getnetconfigent ) .
Packit 00408a
.Pp
Packit 00408a
The
Packit 00408a
.Fn nc_perror
Packit 00408a
function
Packit 00408a
prints a message to the standard error indicating why any of the
Packit 00408a
above routines failed.
Packit 00408a
The message is prepended with the string
Packit 00408a
.Fa msg
Packit 00408a
and a colon.
Packit 00408a
A newline character is appended at the end of the message.
Packit 00408a
.Pp
Packit 00408a
The
Packit 00408a
.Fn nc_sperror
Packit 00408a
function
Packit 00408a
is similar to
Packit 00408a
.Fn nc_perror
Packit 00408a
but instead of sending the message
Packit 00408a
to the standard error, will return a pointer to a string that
Packit 00408a
contains the error message.
Packit 00408a
.Pp
Packit 00408a
The
Packit 00408a
.Fn nc_perror
Packit 00408a
and
Packit 00408a
.Fn nc_sperror
Packit 00408a
functions
Packit 00408a
can also be used with the
Packit 00408a
.Ev NETPATH
Packit 00408a
access routines defined in
Packit 00408a
.Xr getnetpath 3 .
Packit 00408a
.Sh RETURN VALUES
Packit 00408a
The
Packit 00408a
.Fn setnetconfig
Packit 00408a
function
Packit 00408a
returns a unique handle to be used by
Packit 00408a
.Fn getnetconfig .
Packit 00408a
In the case of an error,
Packit 00408a
.Fn setnetconfig
Packit 00408a
returns
Packit 00408a
.Dv NULL
Packit 00408a
and
Packit 00408a
.Fn nc_perror
Packit 00408a
or
Packit 00408a
.Fn nc_sperror
Packit 00408a
can be used to print the reason for failure.
Packit 00408a
.Pp
Packit 00408a
The
Packit 00408a
.Fn getnetconfig
Packit 00408a
function
Packit 00408a
returns a pointer to the current entry in the netconfig
Packit 00408a
database, formatted as a
Packit 00408a
.Ft "struct netconfig" .
Packit 00408a
The
Packit 00408a
.Fn getnetconfig
Packit 00408a
function
Packit 00408a
returns
Packit 00408a
.Dv NULL
Packit 00408a
at the end of the file, or upon failure.
Packit 00408a
.Pp
Packit 00408a
The
Packit 00408a
.Fn endnetconfig
Packit 00408a
function
Packit 00408a
returns 0 on success and \-1 on failure
Packit 00408a
(for example, if
Packit 00408a
.Fn setnetconfig
Packit 00408a
was not called previously).
Packit 00408a
.Pp
Packit 00408a
On success,
Packit 00408a
.Fn getnetconfigent
Packit 00408a
returns a pointer to the
Packit 00408a
.Ft "struct netconfig"
Packit 00408a
structure corresponding to
Packit 00408a
.Fa netid ;
Packit 00408a
otherwise it returns
Packit 00408a
.Dv NULL .
Packit 00408a
.Pp
Packit 00408a
The
Packit 00408a
.Fn nc_sperror
Packit 00408a
function
Packit 00408a
returns a pointer to a buffer which contains the error message string.
Packit 00408a
This buffer is overwritten on each call.
Packit 00408a
In multithreaded applications, this buffer is
Packit 00408a
implemented as thread-specific data.
Packit 00408a
.Sh FILES
Packit 00408a
.Bl -tag -width /etc/netconfig -compact
Packit 00408a
.It Pa /etc/netconfig
Packit 00408a
.El
Packit 00408a
.Sh AVAILABILITY
Packit 00408a
These functions are part of libtirpc.
Packit 00408a
.Sh SEE ALSO
Packit 00408a
.Xr getnetpath 3 ,
Packit 00408a
.Xr netconfig 5