1 .\" $NetBSD: cgetcap.3,v 1.8 2012/04/22 10:13:52 wiz Exp $
3 .\" Copyright (c) 1992, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" This code is derived from software contributed to Berkeley by
7 .\" Casey Leedom of Lawrence Livermore National Laboratory.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
17 .\" 3. Neither the name of the University nor the names of its contributors
18 .\" may be used to endorse or promote products derived from this software
19 .\" without specific prior written permission.
21 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 .\" @(#)getcap.3 8.4 (Berkeley) 5/13/94
50 .Nd capability database access routines
56 .Fn cgetent "char **buf" "const char * const *db_array" "const char *name"
58 .Fn cgetset "const char *ent"
60 .Fn cgetmatch "const char *buf" "const char *name"
62 .Fn cgetcap "char *buf" "const char *cap" "int type"
64 .Fn cgetnum "char *buf" "const char *cap" "long *num"
66 .Fn cgetstr "char *buf" "const char *cap" "char **str"
68 .Fn cgetustr "char *buf" "const char *cap" "char **str"
70 .Fn cgetfirst "char **buf" "const char * const *db_array"
72 .Fn cgetnext "char **buf" "const char * const *db_array"
76 .Fn csetexpandtc "int expandtc"
79 extracts the capability
81 from the database specified by the
85 and returns a pointer to a
90 will first look for files ending in
99 must be retained through all subsequent calls to
109 On success 0 is returned, 1 if the returned record contains an unresolved
111 expansion, \-1 if the requested record couldn't be found, \-2 if
112 a system error was encountered (couldn't open/read a file, etc.)
115 and \-3 if a potential reference loop is detected (see
120 enables the addition of a character buffer containing a single capability
121 record entry to the capability database.
122 Conceptually, the entry is added as the first
125 is therefore searched first on the call to
127 The entry is passed in
133 the current entry is removed from the database.
136 must precede the database traversal.
137 It must be called before the
140 If a sequential access is being performed (see below), it must be called
141 before the first sequential access call
147 or be directly preceded by a
150 On success 0 is returned and \-1 on failure.
155 is one of the names of the capability record
160 searches the capability record
168 is specified using any single character.
171 is used, an untyped capability will be searched
172 for (see below for explanation of types).
173 A pointer to the value of
177 is returned on success,
179 if the requested capability couldn't be found.
180 The end of the capability value is signaled by a
184 for a description of the capability syntax.
187 retrieves the value of the numeric capability
189 from the capability record pointed to by
191 The numeric value is returned in the
195 0 is returned on success,
196 \-1 if the requested numeric capability couldn't be found.
199 retrieves the value of the string capability
201 from the capability record pointed to by
203 A pointer to a decoded,
207 copy of the string is returned in the
211 The number of characters in the decoded string not including the trailing
213 is returned on success, \-1 if the requested string capability couldn't
214 be found, \-2 if a system error was encountered (storage allocation
220 except that it does not expand special characters, but rather returns each
221 character of the capability string literally.
225 comprise a function group that provides for sequential access of the
227 pointer terminated array of file names,
230 returns the first record in the database and resets the access
233 returns the next record in the database with respect to the
234 record returned by the previous
239 If there is no such previous call,
240 the first record in the database is returned.
241 Each record is returned in a
246 expansion is done (see
250 Upon completion of the database 0 is returned, 1 is returned upon successful
251 return of record with possibly more remaining (we haven't reached the end of
252 the database yet), 2 is returned if the record contains an unresolved
254 expansion, \-1 is returned if an system error occurred, and \-2
255 is returned if a potential reference loop is detected (see
258 Upon completion of database (0 return) the database is closed.
261 closes the sequential access and frees any memory and file descriptors
263 Note that it does not erase the buffer pushed by a call to
265 .Sh CAPABILITY DATABASE SEMANTICS
266 Capability records describe a set of (name, value) bindings.
267 Names may have multiple values bound to them.
268 Different values for a name are distinguished by their
271 will return a pointer to a value of a name given the capability name and
272 the type of the value.
278 are conventionally used to denote numeric and
279 string typed values, but no restriction on those types is enforced.
284 can be used to implement the traditional syntax and semantics of
288 Typeless capabilities are typically used to denote boolean objects with
289 presence or absence indicating truth and false values respectively.
290 This interpretation is conveniently represented by:
292 .Dl "(getcap(buf, name, ':') != NULL)"
294 A special capability,
296 is used to indicate that the record specified by
298 should be substituted for the
302 capabilities may interpolate records which also contain
304 capabilities and more than one
306 capability may be used in a record.
309 expansion scope (i.e. where the argument is searched for) contains the
312 is declared and all subsequent files in the file array.
315 can be used to control if
317 expansion is performed or not.
328 return a value greater than or equal to 0 on success and a value less
331 returns a character pointer on success and a
342 for any of the errors specified for the library functions:
359 No memory to allocate.
366 There are no checks for
371 The buffer added to the database by a call to
373 is not unique to the database but is rather prepended to any database used.