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