xref: /netbsd-src/lib/libc/rpc/getnetconfig.3 (revision 472351e13db0de574eb46dc6a738ebfef119f0e3)
17df0ccbaSfvdl.\" 	@(#)getnetconfig.3n 1.28 93/06/02 SMI; from SVr4
2*472351e1Swiz.\"	$NetBSD: getnetconfig.3,v 1.7 2003/04/16 13:34:43 wiz Exp $
37df0ccbaSfvdl.\" Copyright 1989 AT&T
47df0ccbaSfvdl.Dd April 22, 2000
57df0ccbaSfvdl.Dt GETNETCONFIG 3
67df0ccbaSfvdl.Os
77df0ccbaSfvdl.Sh NAME
87df0ccbaSfvdl.Nm getnetconfig ,
97df0ccbaSfvdl.Nm setnetconfig ,
107df0ccbaSfvdl.Nm endnetconfig ,
117df0ccbaSfvdl.Nm getnetconfigent ,
127df0ccbaSfvdl.Nm freenetconfigent ,
137df0ccbaSfvdl.Nm nc_perror ,
147df0ccbaSfvdl.Nm nc_sperror
157df0ccbaSfvdl.Nd get network configuration database entry
167df0ccbaSfvdl.Sh LIBRARY
177df0ccbaSfvdl.Lb libc
187df0ccbaSfvdl.Sh SYNOPSIS
19*472351e1Swiz.In netconfig.h
207df0ccbaSfvdl.Ft struct netconfig *
217df0ccbaSfvdl.Fn getnetconfig "void *handlep"
227df0ccbaSfvdl.Ft void *
237df0ccbaSfvdl.Fn setnetconfig "void"
247df0ccbaSfvdl.Ft int
257df0ccbaSfvdl.Fn endnetconfig "void *handlep"
267df0ccbaSfvdl.Ft struct netconfig *
277df0ccbaSfvdl.Fn getnetconfigent "const char *netid"
287df0ccbaSfvdl.Ft void
297df0ccbaSfvdl.Fn freenetconfigent "struct netconfig *netconfigp"
307df0ccbaSfvdl.Ft void
317df0ccbaSfvdl.Fn nc_perror "const char *msg"
327df0ccbaSfvdl.Ft char *
337df0ccbaSfvdl.Fn nc_sperror "void"
347df0ccbaSfvdl.Sh DESCRIPTION
357df0ccbaSfvdlThe library routines described on this page
367df0ccbaSfvdlprovide the application access to
377df0ccbaSfvdlthe system network configuration database,
387df0ccbaSfvdl.Pa /etc/netconfig .
39015545ffSjdolecek.Bd -literal
40015545ffSjdolecekstruct netconfig {
41015545ffSjdolecek        char *nc_netid;              /* Network ID */
42015545ffSjdolecek        unsigned long nc_semantics;  /* Semantics */
43015545ffSjdolecek        unsigned long nc_flag;       /* Flags */
44015545ffSjdolecek        char *nc_protofmly;          /* Protocol family */
45015545ffSjdolecek        char *nc_proto;              /* Protocol name */
46015545ffSjdolecek        char *nc_device;             /* Network device pathname */
47015545ffSjdolecek        unsigned long nc_nlookups;   /* Number of directory lookup libs */
48015545ffSjdolecek        char **nc_lookups;           /* Names of the libraries */
49015545ffSjdolecek};
50015545ffSjdolecek.Ed
51015545ffSjdolecek.Pp
527df0ccbaSfvdl.Fn getnetconfig
537df0ccbaSfvdlreturns a pointer to the
547df0ccbaSfvdlcurrent entry in the
55015545ffSjdolecek.Pa netconfig
567df0ccbaSfvdldatabase, formatted as a struct netconfig.
577df0ccbaSfvdlSuccessive calls will return successive netconfig
587df0ccbaSfvdlentries in the netconfig database.
597df0ccbaSfvdl.Fn getnetconfig
607df0ccbaSfvdlcan be used to search the entire netconfig
617df0ccbaSfvdlfile.
627df0ccbaSfvdl.Fn getnetconfig
637df0ccbaSfvdlreturns
647df0ccbaSfvdl.Dv NULL
657df0ccbaSfvdlat the end of the file.
66015545ffSjdolecek.Fa handlep
677df0ccbaSfvdlis the handle obtained through
687df0ccbaSfvdl.Fn setnetconfig .
697df0ccbaSfvdl.Pp
707df0ccbaSfvdlA call to
717df0ccbaSfvdl.Fn setnetconfig
727df0ccbaSfvdlhas the effect of ``binding'' to or
737df0ccbaSfvdl``rewinding'' the netconfig database.
747df0ccbaSfvdl.Fn setnetconfig
757df0ccbaSfvdlmust be called before the first call to
767df0ccbaSfvdl.Fn getnetconfig
777df0ccbaSfvdland may be called at any other time.
787df0ccbaSfvdl.Fn setnetconfig
797df0ccbaSfvdlneed not be called before a call to
807df0ccbaSfvdl.Fn getnetconfigent .
817df0ccbaSfvdl.Fn setnetconfig
827df0ccbaSfvdlreturns a unique handle to be used by
837df0ccbaSfvdl.Fn getnetconfig .
847df0ccbaSfvdl.Pp
857df0ccbaSfvdl.Fn endnetconfig
867df0ccbaSfvdlshould be called when processing is complete to release resources for reuse.
877df0ccbaSfvdl.Fa handlep
887df0ccbaSfvdlis the handle obtained through
897df0ccbaSfvdl.Fn setnetconfig .
907df0ccbaSfvdlProgrammers should be aware, however, that the last call to
917df0ccbaSfvdl.Fn endnetconfig
927df0ccbaSfvdlfrees all memory allocated by
937df0ccbaSfvdl.Fn getnetconfig
947df0ccbaSfvdlfor the
957df0ccbaSfvdlstruct netconfig data structure.
967df0ccbaSfvdl.Fn endnetconfig
977df0ccbaSfvdlmay not be called before
987df0ccbaSfvdl.Fn setnetconfig .
997df0ccbaSfvdl.Pp
1007df0ccbaSfvdl.Fn getnetconfigent
1017df0ccbaSfvdlreturns a pointer
1027df0ccbaSfvdlto the netconfig structure corresponding
1037df0ccbaSfvdlto
1047df0ccbaSfvdl.Fa netid .
1057df0ccbaSfvdlIt returns
1067df0ccbaSfvdl.Dv NULL
1077df0ccbaSfvdlif
1087df0ccbaSfvdl.Fa netid
1097df0ccbaSfvdlis invalid
1107df0ccbaSfvdl(that is, does not name an entry in the netconfig database).
1117df0ccbaSfvdl.Pp
1127df0ccbaSfvdl.Fn freenetconfigent
1137df0ccbaSfvdlfrees the netconfig structure pointed to by
1147df0ccbaSfvdl.Fa netconfigp
1157df0ccbaSfvdl(previously returned by
1167df0ccbaSfvdl.Fn getnetconfigent ) .
1177df0ccbaSfvdl.Pp
1187df0ccbaSfvdl.Fn nc_perror
1197df0ccbaSfvdlprints a message to the standard error indicating why any of the
1207df0ccbaSfvdlabove routines failed.
1217df0ccbaSfvdlThe message is prepended with the string
1227df0ccbaSfvdl.Fa msg
1237df0ccbaSfvdland a colon.
1247df0ccbaSfvdlA newline character is appended at the end of the message.
1257df0ccbaSfvdl.Pp
1267df0ccbaSfvdl.Fn nc_sperror
1277df0ccbaSfvdlis similar to
1287df0ccbaSfvdl.Fn nc_perror
1297df0ccbaSfvdlbut instead of sending the message
1307df0ccbaSfvdlto the standard error, will return a pointer to a string that
1317df0ccbaSfvdlcontains the error message.
1327df0ccbaSfvdl.Pp
1337df0ccbaSfvdl.Fn nc_perror
1347df0ccbaSfvdland
1357df0ccbaSfvdl.Fn nc_sperror
1367df0ccbaSfvdlcan also be used with the
137015545ffSjdolecek.Va NETPATH
1387df0ccbaSfvdlaccess routines defined in
1397df0ccbaSfvdl.Xr getnetpath 3 .
1407df0ccbaSfvdl.Sh RETURN VALUES
1417df0ccbaSfvdl.Fn setnetconfig
1427df0ccbaSfvdlreturns a unique handle to be used by
1437df0ccbaSfvdl.Fn getnetconfig .
1447df0ccbaSfvdlIn the case of an error,
1457df0ccbaSfvdl.Fn setnetconfig
1467df0ccbaSfvdlreturns NULL and
1477df0ccbaSfvdl.Fn nc_perror
1487df0ccbaSfvdlor
1497df0ccbaSfvdl.Fn nc_sperror
1507df0ccbaSfvdlcan be used to print the reason for failure.
1517df0ccbaSfvdl.Pp
1527df0ccbaSfvdl.Fn getnetconfig
1537df0ccbaSfvdlreturns a pointer to the current entry in the netconfig
1547df0ccbaSfvdldatabase, formatted as a struct netconfig.
1557df0ccbaSfvdl.Fn getnetconfig
1567df0ccbaSfvdlreturns NULL
1577df0ccbaSfvdlat the end of the file, or upon failure.
1587df0ccbaSfvdl.Pp
1597df0ccbaSfvdl.Fn endnetconfig
1607df0ccbaSfvdlreturns 0 on success and -1 on failure
1617df0ccbaSfvdl(for example, if
1627df0ccbaSfvdl.Fn setnetconfig
1637df0ccbaSfvdlwas not called previously).
1647df0ccbaSfvdl.Pp
1657df0ccbaSfvdlOn success,
166667e9783Swiz.Fn getnetconfigent
1677df0ccbaSfvdlreturns a pointer to the
168015545ffSjdolecek.Li struct netconfig
1697df0ccbaSfvdlstructure corresponding to
170015545ffSjdolecek.Ar netid ;
171015545ffSjdolecekotherwise it returns
172015545ffSjdolecek.Dv NULL .
1737df0ccbaSfvdl.Pp
1747df0ccbaSfvdl.Fn nc_sperror
1757df0ccbaSfvdlreturns a pointer to a buffer which contains the error message string.
1767df0ccbaSfvdlThis buffer is overwritten on each call.
1777df0ccbaSfvdlIn multithreaded applications, this buffer is
1787df0ccbaSfvdlimplemented as thread-specific data.
1797df0ccbaSfvdl.Sh FILES
1807df0ccbaSfvdl.Pa /etc/netconfig
1817df0ccbaSfvdl.Sh SEE ALSO
1827df0ccbaSfvdl.Xr getnetpath 3 ,
1833bb356f0Swiz.Xr netconfig 5
184