1getnetconfig(3NSL)   Networking Services Library Functions  getnetconfig(3NSL)
2
3
4

NAME

6       getnetconfig,  setnetconfig, endnetconfig, getnetconfigent, freenetcon‐
7       figent, nc_perror, nc_sperror  -  get  network  configuration  database
8       entry
9

SYNOPSIS

11       #include <netconfig.h>
12
13
14
15
16       struct netconfig *getnetconfig(void *handlep);
17
18
19       void *setnetconfig(void);
20
21
22       int endnetconfig(void *handlep);
23
24
25       struct netconfig *getnetconfigent(const char *netid);
26
27
28       void freenetconfigent(struct netconfig *netconfigp);
29
30
31       void nc_perror(const char *msg);
32
33
34       char *nc_sperror(void);
35
36

DESCRIPTION

38       The  library  routines  described on this page  are part of the Network
39       Selection component. They provide the application access to the  system
40       network  configuration  database,   /etc/netconfig.  In addition to the
41       routines for  accessing  the   netconfig  database,  Network  Selection
42       includes  the  environment  variable  NETPATH  (see environ(5)) and the
43       NETPATH access routines described in getnetpath(3NSL).
44
45
46       getnetconfig() returns a pointer to the current entry in the  netconfig
47       database, formatted as a struct netconfig. Successive calls will return
48       successive  netconfig entries in the netconfig database. getnetconfig()
49       can  be  used  to  search  the  entire   netconfig file. getnetconfig()
50       returns  NULL at the end of the file.  handlep is the  handle  obtained
51       through setnetconfig().
52
53
54       A  call to setnetconfig() has the effect of ``binding'' to or ``rewind‐
55       ing'' the netconfig database. setnetconfig() must be called before  the
56       first  call to getnetconfig() and may be called at any other time. set‐
57       netconfig() need not be called before  a  call  to   getnetconfigent().
58       setnetconfig() returns a unique handle to be used by getnetconfig().
59
60
61       endnetconfig()  should be called when processing is complete to release
62       resources for reuse. handlep is the handle obtained through  setnetcon‐
63       fig(). Programmers should be aware, however, that the last call to end‐
64       netconfig() frees all memory allocated by getnetconfig() for the struct
65       netconfig  data structure. endnetconfig() may not be called before set‐
66       netconfig().
67
68
69       getnetconfigent() returns a pointer to the struct  netconfig  structure
70       corresponding  to netid. It returns  NULL if netid is invalid (that is,
71       does not name an entry in the netconfig database).
72
73
74       freenetconfigent() frees the netconfig structure pointed to by  netcon‐
75       figp (previously returned by getnetconfigent()).
76
77
78       nc_perror()  prints  a message to the standard error indicating why any
79       of the above routines failed. The message is prepended with the  string
80       msg and a colon. A NEWLINE is appended at the end of the message.
81
82
83       nc_sperror() is similar to  nc_perror() but instead of sending the mes‐
84       sage to the standard error, will return a pointer to a string that con‐
85       tains the error message.
86
87
88       nc_perror()  and  nc_sperror() can also be used with the NETPATH access
89       routines defined in getnetpath(3NSL).
90

RETURN VALUES

92       setnetconfig() returns a unique handle to be used by getnetconfig(). In
93       the case of an error,  setnetconfig() returns  NULL and  nc_perror() or
94       nc_sperror() can be used to print the reason for failure.
95
96
97       getnetconfig() returns a pointer to the current entry  in  the  netcon‐
98       fig()  database,  formatted  as  a   struct  netconfig.  getnetconfig()
99       returns  NULL at the end of the file, or upon failure.
100
101
102       endnetconfig() returns 0 on success and −1 on failure (for example,  if
103       setnetconfig() was not called previously).
104
105
106       On success,  getnetconfigent() returns a pointer to the  struct netcon‐
107       fig structure corresponding to netid; otherwise it returns  NULL.
108
109
110       nc_sperror() returns a pointer to a buffer  which  contains  the  error
111       message  string.  This  buffer  is overwritten on each call.  In multi‐
112       threaded applications, this buffer is  implemented  as  thread-specific
113       data.
114

ATTRIBUTES

116       See attributes(5) for descriptions of the following attributes:
117
118
119
120
121       ┌─────────────────────────────┬─────────────────────────────┐
122       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
123       ├─────────────────────────────┼─────────────────────────────┤
124       │MT-Level                     │MT-Safe                      │
125       └─────────────────────────────┴─────────────────────────────┘
126

SEE ALSO

128       getnetpath(3NSL), netconfig(4), attributes(5), environ(5)
129
130
131
132SunOS 5.11                        30 Dec 1996               getnetconfig(3NSL)
Impressum