2000-06-03 03:11:05 +04:00
|
|
|
.\" @(#)getnetconfig.3n 1.28 93/06/02 SMI; from SVr4
|
2003-04-16 17:34:34 +04:00
|
|
|
.\" $NetBSD: getnetconfig.3,v 1.7 2003/04/16 13:34:43 wiz Exp $
|
2000-06-03 03:11:05 +04:00
|
|
|
.\" Copyright 1989 AT&T
|
|
|
|
.Dd April 22, 2000
|
|
|
|
.Dt GETNETCONFIG 3
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm getnetconfig ,
|
|
|
|
.Nm setnetconfig ,
|
|
|
|
.Nm endnetconfig ,
|
|
|
|
.Nm getnetconfigent ,
|
|
|
|
.Nm freenetconfigent ,
|
|
|
|
.Nm nc_perror ,
|
|
|
|
.Nm nc_sperror
|
|
|
|
.Nd get network configuration database entry
|
|
|
|
.Sh LIBRARY
|
|
|
|
.Lb libc
|
|
|
|
.Sh SYNOPSIS
|
2003-04-16 17:34:34 +04:00
|
|
|
.In netconfig.h
|
2000-06-03 03:11:05 +04:00
|
|
|
.Ft struct netconfig *
|
|
|
|
.Fn getnetconfig "void *handlep"
|
|
|
|
.Ft void *
|
|
|
|
.Fn setnetconfig "void"
|
|
|
|
.Ft int
|
|
|
|
.Fn endnetconfig "void *handlep"
|
|
|
|
.Ft struct netconfig *
|
|
|
|
.Fn getnetconfigent "const char *netid"
|
|
|
|
.Ft void
|
|
|
|
.Fn freenetconfigent "struct netconfig *netconfigp"
|
|
|
|
.Ft void
|
|
|
|
.Fn nc_perror "const char *msg"
|
|
|
|
.Ft char *
|
|
|
|
.Fn nc_sperror "void"
|
|
|
|
.Sh DESCRIPTION
|
2001-04-09 16:18:48 +04:00
|
|
|
The library routines described on this page
|
2000-06-03 03:11:05 +04:00
|
|
|
provide the application access to
|
2001-04-09 16:18:48 +04:00
|
|
|
the system network configuration database,
|
2000-06-03 03:11:05 +04:00
|
|
|
.Pa /etc/netconfig .
|
2002-12-07 15:21:45 +03:00
|
|
|
.Bd -literal
|
|
|
|
struct netconfig {
|
|
|
|
char *nc_netid; /* Network ID */
|
|
|
|
unsigned long nc_semantics; /* Semantics */
|
|
|
|
unsigned long nc_flag; /* Flags */
|
|
|
|
char *nc_protofmly; /* Protocol family */
|
|
|
|
char *nc_proto; /* Protocol name */
|
|
|
|
char *nc_device; /* Network device pathname */
|
|
|
|
unsigned long nc_nlookups; /* Number of directory lookup libs */
|
|
|
|
char **nc_lookups; /* Names of the libraries */
|
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
.Pp
|
2000-06-03 03:11:05 +04:00
|
|
|
.Fn getnetconfig
|
|
|
|
returns a pointer to the
|
2001-04-09 16:18:48 +04:00
|
|
|
current entry in the
|
2002-12-07 15:21:45 +03:00
|
|
|
.Pa netconfig
|
|
|
|
database, formatted as a struct netconfig.
|
2000-06-03 03:11:05 +04:00
|
|
|
Successive calls will return successive netconfig
|
|
|
|
entries in the netconfig database.
|
|
|
|
.Fn getnetconfig
|
|
|
|
can be used to search the entire netconfig
|
|
|
|
file.
|
|
|
|
.Fn getnetconfig
|
2001-04-09 16:18:48 +04:00
|
|
|
returns
|
2000-06-03 03:11:05 +04:00
|
|
|
.Dv NULL
|
2001-04-09 16:18:48 +04:00
|
|
|
at the end of the file.
|
2002-12-07 15:21:45 +03:00
|
|
|
.Fa handlep
|
2000-06-03 03:11:05 +04:00
|
|
|
is the handle obtained through
|
|
|
|
.Fn setnetconfig .
|
|
|
|
.Pp
|
|
|
|
A call to
|
|
|
|
.Fn setnetconfig
|
|
|
|
has the effect of ``binding'' to or
|
|
|
|
``rewinding'' the netconfig database.
|
|
|
|
.Fn setnetconfig
|
|
|
|
must be called before the first call to
|
|
|
|
.Fn getnetconfig
|
|
|
|
and may be called at any other time.
|
|
|
|
.Fn setnetconfig
|
2001-04-09 16:18:48 +04:00
|
|
|
need not be called before a call to
|
2000-06-03 03:11:05 +04:00
|
|
|
.Fn getnetconfigent .
|
|
|
|
.Fn setnetconfig
|
|
|
|
returns a unique handle to be used by
|
|
|
|
.Fn getnetconfig .
|
|
|
|
.Pp
|
|
|
|
.Fn endnetconfig
|
|
|
|
should be called when processing is complete to release resources for reuse.
|
|
|
|
.Fa handlep
|
|
|
|
is the handle obtained through
|
|
|
|
.Fn setnetconfig .
|
|
|
|
Programmers should be aware, however, that the last call to
|
|
|
|
.Fn endnetconfig
|
|
|
|
frees all memory allocated by
|
|
|
|
.Fn getnetconfig
|
|
|
|
for the
|
|
|
|
struct netconfig data structure.
|
|
|
|
.Fn endnetconfig
|
|
|
|
may not be called before
|
|
|
|
.Fn setnetconfig .
|
|
|
|
.Pp
|
|
|
|
.Fn getnetconfigent
|
|
|
|
returns a pointer
|
|
|
|
to the netconfig structure corresponding
|
2001-04-09 16:18:48 +04:00
|
|
|
to
|
2000-06-03 03:11:05 +04:00
|
|
|
.Fa netid .
|
2001-04-09 16:18:48 +04:00
|
|
|
It returns
|
2000-06-03 03:11:05 +04:00
|
|
|
.Dv NULL
|
|
|
|
if
|
|
|
|
.Fa netid
|
|
|
|
is invalid
|
|
|
|
(that is, does not name an entry in the netconfig database).
|
|
|
|
.Pp
|
|
|
|
.Fn freenetconfigent
|
2001-04-09 16:18:48 +04:00
|
|
|
frees the netconfig structure pointed to by
|
2000-06-03 03:11:05 +04:00
|
|
|
.Fa netconfigp
|
|
|
|
(previously returned by
|
2001-04-09 16:18:48 +04:00
|
|
|
.Fn getnetconfigent ) .
|
2000-06-03 03:11:05 +04:00
|
|
|
.Pp
|
|
|
|
.Fn nc_perror
|
|
|
|
prints a message to the standard error indicating why any of the
|
|
|
|
above routines failed.
|
|
|
|
The message is prepended with the string
|
|
|
|
.Fa msg
|
|
|
|
and a colon.
|
|
|
|
A newline character is appended at the end of the message.
|
|
|
|
.Pp
|
|
|
|
.Fn nc_sperror
|
2001-04-09 16:18:48 +04:00
|
|
|
is similar to
|
2000-06-03 03:11:05 +04:00
|
|
|
.Fn nc_perror
|
|
|
|
but instead of sending the message
|
|
|
|
to the standard error, will return a pointer to a string that
|
|
|
|
contains the error message.
|
|
|
|
.Pp
|
|
|
|
.Fn nc_perror
|
|
|
|
and
|
|
|
|
.Fn nc_sperror
|
|
|
|
can also be used with the
|
2002-12-07 15:21:45 +03:00
|
|
|
.Va NETPATH
|
2000-06-03 03:11:05 +04:00
|
|
|
access routines defined in
|
|
|
|
.Xr getnetpath 3 .
|
|
|
|
.Sh RETURN VALUES
|
|
|
|
.Fn setnetconfig
|
|
|
|
returns a unique handle to be used by
|
|
|
|
.Fn getnetconfig .
|
2001-04-09 16:18:48 +04:00
|
|
|
In the case of an error,
|
2000-06-03 03:11:05 +04:00
|
|
|
.Fn setnetconfig
|
2001-04-09 16:18:48 +04:00
|
|
|
returns NULL and
|
2000-06-03 03:11:05 +04:00
|
|
|
.Fn nc_perror
|
|
|
|
or
|
|
|
|
.Fn nc_sperror
|
|
|
|
can be used to print the reason for failure.
|
|
|
|
.Pp
|
|
|
|
.Fn getnetconfig
|
|
|
|
returns a pointer to the current entry in the netconfig
|
|
|
|
database, formatted as a struct netconfig.
|
|
|
|
.Fn getnetconfig
|
|
|
|
returns NULL
|
2001-04-09 16:18:48 +04:00
|
|
|
at the end of the file, or upon failure.
|
2000-06-03 03:11:05 +04:00
|
|
|
.Pp
|
|
|
|
.Fn endnetconfig
|
|
|
|
returns 0 on success and -1 on failure
|
|
|
|
(for example, if
|
|
|
|
.Fn setnetconfig
|
|
|
|
was not called previously).
|
|
|
|
.Pp
|
2001-04-09 16:18:48 +04:00
|
|
|
On success,
|
2002-12-18 22:34:53 +03:00
|
|
|
.Fn getnetconfigent
|
2001-04-09 16:18:48 +04:00
|
|
|
returns a pointer to the
|
2002-12-07 15:21:45 +03:00
|
|
|
.Li struct netconfig
|
2000-06-03 03:11:05 +04:00
|
|
|
structure corresponding to
|
2002-12-07 15:21:45 +03:00
|
|
|
.Ar netid ;
|
|
|
|
otherwise it returns
|
|
|
|
.Dv NULL .
|
2000-06-03 03:11:05 +04:00
|
|
|
.Pp
|
|
|
|
.Fn nc_sperror
|
|
|
|
returns a pointer to a buffer which contains the error message string.
|
2001-04-09 16:18:48 +04:00
|
|
|
This buffer is overwritten on each call.
|
2000-06-03 03:11:05 +04:00
|
|
|
In multithreaded applications, this buffer is
|
|
|
|
implemented as thread-specific data.
|
|
|
|
.Sh FILES
|
|
|
|
.Pa /etc/netconfig
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr getnetpath 3 ,
|
2001-04-09 16:18:48 +04:00
|
|
|
.Xr netconfig 5
|