1GETNETCONFIG(3) BSD Library Functions Manual GETNETCONFIG(3)
2
4 getnetconfig, setnetconfig, endnetconfig, getnetconfigent,
5 freenetconfigent, nc_perror, nc_sperror — get network configuration data‐
6 base entry
7
9 #include <netconfig.h>
10
11 struct netconfig *
12 getnetconfig(void *handlep);
13
14 void *
15 setnetconfig(void);
16
17 int
18 endnetconfig(void *handlep);
19
20 struct netconfig *
21 getnetconfigent(const char *netid);
22
23 void
24 freenetconfigent(struct netconfig *netconfigp);
25
26 void
27 nc_perror(const char *msg);
28
29 char *
30 nc_sperror(void);
31
33 The library routines described on this page provide the application
34 access to the system network configuration database, /etc/netconfig. The
35 getnetconfig() function returns a pointer to the current entry in the
36 netconfig database, formatted as a struct netconfig. Successive calls
37 will return successive netconfig entries in the netconfig database. The
38 getnetconfig() function can be used to search the entire netconfig file.
39 The getnetconfig() function returns NULL at the end of the file. The
40 handlep argument is the handle obtained through setnetconfig().
41
42 A call to setnetconfig() has the effect of “binding” to or “rewinding”
43 the netconfig database. The setnetconfig() function must be called
44 before the first call to getnetconfig() and may be called at any other
45 time. The setnetconfig() function need not be called before a call to
46 getnetconfigent(). The setnetconfig() function returns a unique handle
47 to be used by getnetconfig().
48
49 The endnetconfig() function should be called when processing is complete
50 to release resources for reuse. The handlep argument is the handle
51 obtained through setnetconfig(). Programmers should be aware, however,
52 that the last call to endnetconfig() frees all memory allocated by
53 getnetconfig() for the struct netconfig data structure. The
54 endnetconfig() function may not be called before setnetconfig().
55
56 The getnetconfigent() function returns a pointer to the netconfig struc‐
57 ture corresponding to netid. It returns NULL if netid is invalid (that
58 is, does not name an entry in the netconfig database).
59
60 The freenetconfigent() function frees the netconfig structure pointed to
61 by netconfigp (previously returned by getnetconfigent()).
62
63 The nc_perror() function prints a message to the standard error indicat‐
64 ing why any of the above routines failed. The message is prepended with
65 the string msg and a colon. A newline character is appended at the end
66 of the message.
67
68 The nc_sperror() function is similar to nc_perror() but instead of send‐
69 ing the message to the standard error, will return a pointer to a string
70 that contains the error message.
71
72 The nc_perror() and nc_sperror() functions can also be used with the
73 NETPATH access routines defined in getnetpath(3).
74
76 The setnetconfig() function returns a unique handle to be used by
77 getnetconfig(). In the case of an error, setnetconfig() returns NULL and
78 nc_perror() or nc_sperror() can be used to print the reason for failure.
79
80 The getnetconfig() function returns a pointer to the current entry in the
81 netconfig database, formatted as a struct netconfig. The getnetconfig()
82 function returns NULL at the end of the file, or upon failure.
83
84 The endnetconfig() function returns 0 on success and -1 on failure (for
85 example, if setnetconfig() was not called previously).
86
87 On success, getnetconfigent() returns a pointer to the struct netconfig
88 structure corresponding to netid; otherwise it returns NULL.
89
90 The nc_sperror() function returns a pointer to a buffer which contains
91 the error message string. This buffer is overwritten on each call. In
92 multithreaded applications, this buffer is implemented as thread-specific
93 data.
94
96 /etc/netconfig
97
99 These functions are part of libtirpc.
100
102 getnetpath(3), netconfig(5)
103
104BSD April 22, 2000 BSD