xref: /freebsd/lib/libc/gen/getcap.3 (revision dc36d6f9bb1753f3808552f3afd30eda9a7b206a)
158f0484fSRodney W. Grimes.\" Copyright (c) 1992, 1993
258f0484fSRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
358f0484fSRodney W. Grimes.\"
458f0484fSRodney W. Grimes.\" This code is derived from software contributed to Berkeley by
558f0484fSRodney W. Grimes.\" Casey Leedom of Lawrence Livermore National Laboratory.
658f0484fSRodney W. Grimes.\"
758f0484fSRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
858f0484fSRodney W. Grimes.\" modification, are permitted provided that the following conditions
958f0484fSRodney W. Grimes.\" are met:
1058f0484fSRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
1158f0484fSRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
1258f0484fSRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
1358f0484fSRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
1458f0484fSRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
15*fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors
1658f0484fSRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
1758f0484fSRodney W. Grimes.\"    without specific prior written permission.
1858f0484fSRodney W. Grimes.\"
1958f0484fSRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2058f0484fSRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2158f0484fSRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2258f0484fSRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2358f0484fSRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2458f0484fSRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2558f0484fSRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2658f0484fSRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2758f0484fSRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2858f0484fSRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2958f0484fSRodney W. Grimes.\" SUCH DAMAGE.
3058f0484fSRodney W. Grimes.\"
31b0faeb2dSRuslan Ermilov.Dd March 22, 2002
3258f0484fSRodney W. Grimes.Dt GETCAP 3
3358f0484fSRodney W. Grimes.Os
3458f0484fSRodney W. Grimes.Sh NAME
3558f0484fSRodney W. Grimes.Nm cgetent ,
3658f0484fSRodney W. Grimes.Nm cgetset ,
3758f0484fSRodney W. Grimes.Nm cgetmatch ,
3858f0484fSRodney W. Grimes.Nm cgetcap ,
3958f0484fSRodney W. Grimes.Nm cgetnum ,
4058f0484fSRodney W. Grimes.Nm cgetstr ,
4158f0484fSRodney W. Grimes.Nm cgetustr ,
4258f0484fSRodney W. Grimes.Nm cgetfirst ,
4358f0484fSRodney W. Grimes.Nm cgetnext ,
4458f0484fSRodney W. Grimes.Nm cgetclose
4558f0484fSRodney W. Grimes.Nd capability database access routines
4625bb73e0SAlexey Zelkin.Sh LIBRARY
4725bb73e0SAlexey Zelkin.Lb libc
4858f0484fSRodney W. Grimes.Sh SYNOPSIS
4932eef9aeSRuslan Ermilov.In stdlib.h
5058f0484fSRodney W. Grimes.Ft int
51b0faeb2dSRuslan Ermilov.Fn cgetent "char **buf" "char **db_array" "const char *name"
5258f0484fSRodney W. Grimes.Ft int
53b0faeb2dSRuslan Ermilov.Fn cgetset "const char *ent"
5458f0484fSRodney W. Grimes.Ft int
55b0faeb2dSRuslan Ermilov.Fn cgetmatch "const char *buf" "const char *name"
5658f0484fSRodney W. Grimes.Ft char *
57b0faeb2dSRuslan Ermilov.Fn cgetcap "char *buf" "const char *cap" "int type"
5858f0484fSRodney W. Grimes.Ft int
59b0faeb2dSRuslan Ermilov.Fn cgetnum "char *buf" "const char *cap" "long *num"
6058f0484fSRodney W. Grimes.Ft int
61b0faeb2dSRuslan Ermilov.Fn cgetstr "char *buf" "const char *cap" "char **str"
6258f0484fSRodney W. Grimes.Ft int
63b0faeb2dSRuslan Ermilov.Fn cgetustr "char *buf" "const char *cap" "char **str"
6458f0484fSRodney W. Grimes.Ft int
6558f0484fSRodney W. Grimes.Fn cgetfirst "char **buf" "char **db_array"
6658f0484fSRodney W. Grimes.Ft int
6758f0484fSRodney W. Grimes.Fn cgetnext "char **buf" "char **db_array"
6858f0484fSRodney W. Grimes.Ft int
6958f0484fSRodney W. Grimes.Fn cgetclose "void"
7058f0484fSRodney W. Grimes.Sh DESCRIPTION
71beb64fb5SMike PritchardThe
72beb64fb5SMike Pritchard.Fn cgetent
73beb64fb5SMike Pritchardfunction extracts the capability
7458f0484fSRodney W. Grimes.Fa name
7558f0484fSRodney W. Grimesfrom the database specified by the
7658f0484fSRodney W. Grimes.Dv NULL
7758f0484fSRodney W. Grimesterminated file array
7858f0484fSRodney W. Grimes.Fa db_array
7958f0484fSRodney W. Grimesand returns a pointer to a
80d0353b83SRuslan Ermilov.Xr malloc 3 Ns \&'d
8158f0484fSRodney W. Grimescopy of it in
8258f0484fSRodney W. Grimes.Fa buf .
83bf5a138eSMike PritchardThe
84bf5a138eSMike Pritchard.Fn cgetent
85bf5a138eSMike Pritchardfunction will first look for files ending in
86d0353b83SRuslan Ermilov.Pa .db
8758f0484fSRodney W. Grimes(see
8858f0484fSRodney W. Grimes.Xr cap_mkdb 1 )
8958f0484fSRodney W. Grimesbefore accessing the ASCII file.
902efeeba5SRuslan ErmilovThe
912efeeba5SRuslan Ermilov.Fa buf
922efeeba5SRuslan Ermilovargument
9358f0484fSRodney W. Grimesmust be retained through all subsequent calls to
9458f0484fSRodney W. Grimes.Fn cgetmatch ,
9558f0484fSRodney W. Grimes.Fn cgetcap ,
9658f0484fSRodney W. Grimes.Fn cgetnum ,
9758f0484fSRodney W. Grimes.Fn cgetstr ,
9858f0484fSRodney W. Grimesand
9958f0484fSRodney W. Grimes.Fn cgetustr ,
10058f0484fSRodney W. Grimesbut may then be
101374fc79dSWolfram Schneider.Xr free 3 Ns \&'d .
10258f0484fSRodney W. GrimesOn success 0 is returned, 1 if the returned
10358f0484fSRodney W. Grimesrecord contains an unresolved
104b92cc9b8SRuslan Ermilov.Ic tc
10558f0484fSRodney W. Grimesexpansion,
1060227791bSRuslan Ermilov\-1 if the requested record could not be found,
1070227791bSRuslan Ermilov\-2 if a system error was encountered (could not open/read a file, etc.) also
10858f0484fSRodney W. Grimessetting
10958f0484fSRodney W. Grimes.Va errno ,
11058f0484fSRodney W. Grimesand \-3 if a potential reference loop is detected (see
11158f0484fSRodney W. Grimes.Ic tc=
11258f0484fSRodney W. Grimescomments below).
11358f0484fSRodney W. Grimes.Pp
114bf5a138eSMike PritchardThe
115bf5a138eSMike Pritchard.Fn cgetset
116bf5a138eSMike Pritchardfunction enables the addition of a character buffer containing a single capability
11758f0484fSRodney W. Grimesrecord entry
11858f0484fSRodney W. Grimesto the capability database.
11958f0484fSRodney W. GrimesConceptually, the entry is added as the first ``file'' in the database, and
12058f0484fSRodney W. Grimesis therefore searched first on the call to
121bf5a138eSMike Pritchard.Fn cgetent .
12258f0484fSRodney W. GrimesThe entry is passed in
12358f0484fSRodney W. Grimes.Fa ent .
12458f0484fSRodney W. GrimesIf
12558f0484fSRodney W. Grimes.Fa ent
12658f0484fSRodney W. Grimesis
12758f0484fSRodney W. Grimes.Dv NULL ,
12858f0484fSRodney W. Grimesthe current entry is removed from the database.
129bf5a138eSMike PritchardA call to
130bf5a138eSMike Pritchard.Fn cgetset
1311a0a9345SRuslan Ermilovmust precede the database traversal.
1321a0a9345SRuslan ErmilovIt must be called before the
133bf5a138eSMike Pritchard.Fn cgetent
1341a0a9345SRuslan Ermilovcall.
1351a0a9345SRuslan ErmilovIf a sequential access is being performed (see below), it must be called
136f9eeb822SDima Dorfmanbefore the first sequential access call
1370aee91e1SChristian Brueffer.Po Fn cgetfirst
13858f0484fSRodney W. Grimesor
1390aee91e1SChristian Brueffer.Fn cgetnext
1400aee91e1SChristian Brueffer.Pc ,
141f9eeb822SDima Dorfmanor be directly preceded by a
142bf5a138eSMike Pritchard.Fn cgetclose
14358f0484fSRodney W. Grimescall.
14458f0484fSRodney W. GrimesOn success 0 is returned and \-1 on failure.
14558f0484fSRodney W. Grimes.Pp
146bf5a138eSMike PritchardThe
147bf5a138eSMike Pritchard.Fn cgetmatch
148bf5a138eSMike Pritchardfunction will return 0 if
14958f0484fSRodney W. Grimes.Fa name
15058f0484fSRodney W. Grimesis one of the names of the capability record
15158f0484fSRodney W. Grimes.Fa buf ,
15258f0484fSRodney W. Grimes\-1 if
15358f0484fSRodney W. Grimesnot.
15458f0484fSRodney W. Grimes.Pp
155bf5a138eSMike PritchardThe
156bf5a138eSMike Pritchard.Fn cgetcap
157bf5a138eSMike Pritchardfunction searches the capability record
15858f0484fSRodney W. Grimes.Fa buf
15958f0484fSRodney W. Grimesfor the capability
16058f0484fSRodney W. Grimes.Fa cap
16158f0484fSRodney W. Grimeswith type
16258f0484fSRodney W. Grimes.Fa type .
16358f0484fSRodney W. GrimesA
16458f0484fSRodney W. Grimes.Fa type
1651a0a9345SRuslan Ermilovis specified using any single character.
1661a0a9345SRuslan ErmilovIf a colon (`:') is used, an
16758f0484fSRodney W. Grimesuntyped capability will be searched for (see below for explanation of
1681a0a9345SRuslan Ermilovtypes).
1691a0a9345SRuslan ErmilovA pointer to the value of
17058f0484fSRodney W. Grimes.Fa cap
17158f0484fSRodney W. Grimesin
17258f0484fSRodney W. Grimes.Fa buf
17358f0484fSRodney W. Grimesis returned on success,
17458f0484fSRodney W. Grimes.Dv NULL
1750227791bSRuslan Ermilovif the requested capability could not be
1761a0a9345SRuslan Ermilovfound.
1771a0a9345SRuslan ErmilovThe end of the capability value is signaled by a `:' or
17858f0484fSRodney W. Grimes.Tn ASCII
17958f0484fSRodney W. Grimes.Dv NUL
18058f0484fSRodney W. Grimes(see below for capability database syntax).
18158f0484fSRodney W. Grimes.Pp
182bf5a138eSMike PritchardThe
183bf5a138eSMike Pritchard.Fn cgetnum
184bf5a138eSMike Pritchardfunction retrieves the value of the numeric capability
18558f0484fSRodney W. Grimes.Fa cap
18658f0484fSRodney W. Grimesfrom the capability record pointed to by
18758f0484fSRodney W. Grimes.Fa buf .
18858f0484fSRodney W. GrimesThe numeric value is returned in the
18958f0484fSRodney W. Grimes.Ft long
19058f0484fSRodney W. Grimespointed to by
19158f0484fSRodney W. Grimes.Fa num .
1920227791bSRuslan Ermilov0 is returned on success, \-1 if the requested numeric capability could not
19358f0484fSRodney W. Grimesbe found.
19458f0484fSRodney W. Grimes.Pp
195bf5a138eSMike PritchardThe
196bf5a138eSMike Pritchard.Fn cgetstr
197bf5a138eSMike Pritchardfunction retrieves the value of the string capability
19858f0484fSRodney W. Grimes.Fa cap
19958f0484fSRodney W. Grimesfrom the capability record pointed to by
20058f0484fSRodney W. Grimes.Fa buf .
20158f0484fSRodney W. GrimesA pointer to a decoded,
20258f0484fSRodney W. Grimes.Dv NUL
20358f0484fSRodney W. Grimesterminated,
204d0353b83SRuslan Ermilov.Xr malloc 3 Ns \&'d
20558f0484fSRodney W. Grimescopy of the string is returned in the
20658f0484fSRodney W. Grimes.Ft char *
20758f0484fSRodney W. Grimespointed to by
20858f0484fSRodney W. Grimes.Fa str .
20958f0484fSRodney W. GrimesThe number of characters in the decoded string not including the trailing
21058f0484fSRodney W. Grimes.Dv NUL
2110227791bSRuslan Ermilovis returned on success, \-1 if the requested string capability could not
21258f0484fSRodney W. Grimesbe found, \-2 if a system error was encountered (storage allocation
21358f0484fSRodney W. Grimesfailure).
21458f0484fSRodney W. Grimes.Pp
215bf5a138eSMike PritchardThe
216bf5a138eSMike Pritchard.Fn cgetustr
217bf5a138eSMike Pritchardfunction is identical to
218bf5a138eSMike Pritchard.Fn cgetstr
21958f0484fSRodney W. Grimesexcept that it does not expand special characters, but rather returns each
22058f0484fSRodney W. Grimescharacter of the capability string literally.
22158f0484fSRodney W. Grimes.Pp
222bf5a138eSMike PritchardThe
223bf5a138eSMike Pritchard.Fn cgetfirst
224bf5a138eSMike Pritchardand
225bf5a138eSMike Pritchard.Fn cgetnext
226bf5a138eSMike Pritchardfunctions comprise a function group that provides for sequential
22758f0484fSRodney W. Grimesaccess of the
22858f0484fSRodney W. Grimes.Dv NULL
22958f0484fSRodney W. Grimespointer terminated array of file names,
23058f0484fSRodney W. Grimes.Fa db_array .
231bf5a138eSMike PritchardThe
232bf5a138eSMike Pritchard.Fn cgetfirst
233bf5a138eSMike Pritchardfunction returns the first record in the database and resets the access
23458f0484fSRodney W. Grimesto the first record.
235bf5a138eSMike PritchardThe
236bf5a138eSMike Pritchard.Fn cgetnext
237bf5a138eSMike Pritchardfunction returns the next record in the database with respect to the
23858f0484fSRodney W. Grimesrecord returned by the previous
239bf5a138eSMike Pritchard.Fn cgetfirst
24058f0484fSRodney W. Grimesor
241bf5a138eSMike Pritchard.Fn cgetnext
2421a0a9345SRuslan Ermilovcall.
2431a0a9345SRuslan ErmilovIf there is no such previous call, the first record in the database is
24458f0484fSRodney W. Grimesreturned.
24558f0484fSRodney W. GrimesEach record is returned in a
246d0353b83SRuslan Ermilov.Xr malloc 3 Ns \&'d
24758f0484fSRodney W. Grimescopy pointed to by
24858f0484fSRodney W. Grimes.Fa buf .
24958f0484fSRodney W. Grimes.Ic Tc
25058f0484fSRodney W. Grimesexpansion is done (see
25158f0484fSRodney W. Grimes.Ic tc=
25258f0484fSRodney W. Grimescomments below).
25358f0484fSRodney W. GrimesUpon completion of the database 0 is returned, 1 is returned upon successful
2540227791bSRuslan Ermilovreturn of record with possibly more remaining (we have not reached the end of
25558f0484fSRodney W. Grimesthe database yet), 2 is returned if the record contains an unresolved
256b92cc9b8SRuslan Ermilov.Ic tc
257d64ada50SJens Schweikhardtexpansion, \-1 is returned if a system error occurred, and \-2
25858f0484fSRodney W. Grimesis returned if a potential reference loop is detected (see
25958f0484fSRodney W. Grimes.Ic tc=
26058f0484fSRodney W. Grimescomments below).
26158f0484fSRodney W. GrimesUpon completion of database (0 return) the database is closed.
26258f0484fSRodney W. Grimes.Pp
263bf5a138eSMike PritchardThe
264bf5a138eSMike Pritchard.Fn cgetclose
265bf5a138eSMike Pritchardfunction closes the sequential access and frees any memory and file descriptors
2661a0a9345SRuslan Ermilovbeing used.
2671a0a9345SRuslan ErmilovNote that it does not erase the buffer pushed by a call to
268bf5a138eSMike Pritchard.Fn cgetset .
26958f0484fSRodney W. Grimes.Sh CAPABILITY DATABASE SYNTAX
27058f0484fSRodney W. GrimesCapability databases are normally
27158f0484fSRodney W. Grimes.Tn ASCII
27258f0484fSRodney W. Grimesand may be edited with standard
2731a0a9345SRuslan Ermilovtext editors.
2741a0a9345SRuslan ErmilovBlank lines and lines beginning with a `#' are comments
2751a0a9345SRuslan Ermilovand are ignored.
2761a0a9345SRuslan ErmilovLines ending with a `\|\e' indicate that the next line
27758f0484fSRodney W. Grimesis a continuation of the current line; the `\|\e' and following newline
2781a0a9345SRuslan Ermilovare ignored.
2791a0a9345SRuslan ErmilovLong lines are usually continued onto several physical
28058f0484fSRodney W. Grimeslines by ending each line except the last with a `\|\e'.
28158f0484fSRodney W. Grimes.Pp
28258f0484fSRodney W. GrimesCapability databases consist of a series of records, one per logical
2831a0a9345SRuslan Ermilovline.
2841a0a9345SRuslan ErmilovEach record contains a variable number of `:'-separated fields
2851a0a9345SRuslan Ermilov(capabilities).
2861a0a9345SRuslan ErmilovEmpty fields consisting entirely of white space
28758f0484fSRodney W. Grimescharacters (spaces and tabs) are ignored.
28858f0484fSRodney W. Grimes.Pp
28958f0484fSRodney W. GrimesThe first capability of each record specifies its names, separated by `|'
2901a0a9345SRuslan Ermilovcharacters.
2911a0a9345SRuslan ErmilovThese names are used to reference records in the database.
29258f0484fSRodney W. GrimesBy convention, the last name is usually a comment and is not intended as
2931a0a9345SRuslan Ermilova lookup tag.
2941a0a9345SRuslan ErmilovFor example, the
29558f0484fSRodney W. Grimes.Em vt100
29658f0484fSRodney W. Grimesrecord from the
297b92cc9b8SRuslan Ermilov.Xr termcap 5
29858f0484fSRodney W. Grimesdatabase begins:
29958f0484fSRodney W. Grimes.Pp
30058f0484fSRodney W. Grimes.Dl "d0\||\|vt100\||\|vt100-am\||\|vt100am\||\|dec vt100:"
30158f0484fSRodney W. Grimes.Pp
30258f0484fSRodney W. Grimesgiving four names that can be used to access the record.
30358f0484fSRodney W. Grimes.Pp
30458f0484fSRodney W. GrimesThe remaining non-empty capabilities describe a set of (name, value)
30512985df3SDima Dorfmanbindings, consisting of a names optionally followed by a typed value:
306a6dcdf3bSUlrich Spörlein.Pp
307a6dcdf3bSUlrich Spörlein.Bl -tag -width "nameTvalue" -compact
308a6dcdf3bSUlrich Spörlein.It name
309a6dcdf3bSUlrich Spörleintypeless [boolean] capability
31058f0484fSRodney W. Grimes.Em name No "is present [true]"
311a6dcdf3bSUlrich Spörlein.It name Ns Em \&T Ns value
312a6dcdf3bSUlrich Spörleincapability
31358f0484fSRodney W. Grimes.Pq Em name , \&T
31458f0484fSRodney W. Grimeshas value
31558f0484fSRodney W. Grimes.Em value
316a6dcdf3bSUlrich Spörlein.It name@
317a6dcdf3bSUlrich Spörleinno capability
318a6dcdf3bSUlrich Spörlein.Em name No exists
319a6dcdf3bSUlrich Spörlein.It name Ns Em T Ns \&@
320a6dcdf3bSUlrich Spörleincapability
32158f0484fSRodney W. Grimes.Pq Em name , T
32258f0484fSRodney W. Grimesdoes not exist
32358f0484fSRodney W. Grimes.El
32458f0484fSRodney W. Grimes.Pp
3251a0a9345SRuslan ErmilovNames consist of one or more characters.
3261a0a9345SRuslan ErmilovNames may contain any character
32736a142c4SRuslan Ermilovexcept `:', but it is usually best to restrict them to the printable
32830950a21SRuslan Ermilovcharacters and avoid use of graphics like `#', `=', `%', `@', etc.
32930950a21SRuslan ErmilovTypes
33058f0484fSRodney W. Grimesare single characters used to separate capability names from their
3311a0a9345SRuslan Ermilovassociated typed values.
3321a0a9345SRuslan ErmilovTypes may be any character except a `:'.
3331a0a9345SRuslan ErmilovTypically, graphics like `#', `=', `%', etc.\& are used.
3341a0a9345SRuslan ErmilovValues may be any
33558f0484fSRodney W. Grimesnumber of characters and may contain any character except `:'.
33658f0484fSRodney W. Grimes.Sh CAPABILITY DATABASE SEMANTICS
3371a0a9345SRuslan ErmilovCapability records describe a set of (name, value) bindings.
3381a0a9345SRuslan ErmilovNames may
3391a0a9345SRuslan Ermilovhave multiple values bound to them.
3401a0a9345SRuslan ErmilovDifferent values for a name are
34158f0484fSRodney W. Grimesdistinguished by their
34258f0484fSRodney W. Grimes.Fa types .
343bf5a138eSMike PritchardThe
344bf5a138eSMike Pritchard.Fn cgetcap
345bf5a138eSMike Pritchardfunction will return a pointer to a value of a name given the capability
346bf5a138eSMike Pritchardname and the type of the value.
34758f0484fSRodney W. Grimes.Pp
34858f0484fSRodney W. GrimesThe types `#' and `=' are conventionally used to denote numeric and
3491a0a9345SRuslan Ermilovstring typed values, but no restriction on those types is enforced.
3501a0a9345SRuslan ErmilovThe
35158f0484fSRodney W. Grimesfunctions
352bf5a138eSMike Pritchard.Fn cgetnum
35358f0484fSRodney W. Grimesand
354bf5a138eSMike Pritchard.Fn cgetstr
35558f0484fSRodney W. Grimescan be used to implement the traditional syntax and semantics of `#'
35658f0484fSRodney W. Grimesand `='.
35758f0484fSRodney W. GrimesTypeless capabilities are typically used to denote boolean objects with
35858f0484fSRodney W. Grimespresence or absence indicating truth and false values respectively.
35958f0484fSRodney W. GrimesThis interpretation is conveniently represented by:
36058f0484fSRodney W. Grimes.Pp
36158f0484fSRodney W. Grimes.Dl "(getcap(buf, name, ':') != NULL)"
36258f0484fSRodney W. Grimes.Pp
36358f0484fSRodney W. GrimesA special capability,
36458f0484fSRodney W. Grimes.Ic tc= name ,
36558f0484fSRodney W. Grimesis used to indicate that the record specified by
36658f0484fSRodney W. Grimes.Fa name
36758f0484fSRodney W. Grimesshould be substituted for the
36858f0484fSRodney W. Grimes.Ic tc
36958f0484fSRodney W. Grimescapability.
37058f0484fSRodney W. Grimes.Ic Tc
37158f0484fSRodney W. Grimescapabilities may interpolate records which also contain
37258f0484fSRodney W. Grimes.Ic tc
37358f0484fSRodney W. Grimescapabilities and more than one
37458f0484fSRodney W. Grimes.Ic tc
3751a0a9345SRuslan Ermilovcapability may be used in a record.
3761a0a9345SRuslan ErmilovA
37758f0484fSRodney W. Grimes.Ic tc
37858f0484fSRodney W. Grimesexpansion scope (i.e., where the argument is searched for) contains the
37958f0484fSRodney W. Grimesfile in which the
38058f0484fSRodney W. Grimes.Ic tc
38158f0484fSRodney W. Grimesis declared and all subsequent files in the file array.
38258f0484fSRodney W. Grimes.Pp
38358f0484fSRodney W. GrimesWhen a database is searched for a capability record, the first matching
3841a0a9345SRuslan Ermilovrecord in the search is returned.
3851a0a9345SRuslan ErmilovWhen a record is scanned for a
38658f0484fSRodney W. Grimescapability, the first matching capability is returned; the capability
38758f0484fSRodney W. Grimes.Ic :nameT@:
38858f0484fSRodney W. Grimeswill hide any following definition of a value of type
38958f0484fSRodney W. Grimes.Em T
39058f0484fSRodney W. Grimesfor
39158f0484fSRodney W. Grimes.Fa name ;
39258f0484fSRodney W. Grimesand the capability
39358f0484fSRodney W. Grimes.Ic :name@:
39458f0484fSRodney W. Grimeswill prevent any following values of
39558f0484fSRodney W. Grimes.Fa name
39658f0484fSRodney W. Grimesfrom being seen.
39758f0484fSRodney W. Grimes.Pp
39858f0484fSRodney W. GrimesThese features combined with
39958f0484fSRodney W. Grimes.Ic tc
40058f0484fSRodney W. Grimescapabilities can be used to generate variations of other databases and
40158f0484fSRodney W. Grimesrecords by either adding new capabilities, overriding definitions with new
40258f0484fSRodney W. Grimesdefinitions, or hiding following definitions via `@' capabilities.
40358f0484fSRodney W. Grimes.Sh EXAMPLES
40458f0484fSRodney W. Grimes.Bd -unfilled -offset indent
40558f0484fSRodney W. Grimesexample\||\|an example of binding multiple values to names:\e
40658f0484fSRodney W. Grimes	:foo%bar:foo^blah:foo@:\e
40758f0484fSRodney W. Grimes	:abc%xyz:abc^frap:abc$@:\e
40858f0484fSRodney W. Grimes	:tc=more:
40958f0484fSRodney W. Grimes.Ed
41058f0484fSRodney W. Grimes.Pp
41158f0484fSRodney W. GrimesThe capability foo has two values bound to it (bar of type `%' and blah of
4121a0a9345SRuslan Ermilovtype `^') and any other value bindings are hidden.
4131a0a9345SRuslan ErmilovThe capability abc
41458f0484fSRodney W. Grimesalso has two values bound but only a value of type `$' is prevented from
41558f0484fSRodney W. Grimesbeing defined in the capability record more.
41658f0484fSRodney W. Grimes.Bd -unfilled -offset indent
41758f0484fSRodney W. Grimesfile1:
41858f0484fSRodney W. Grimes 	new\||\|new_record\||\|a modification of "old":\e
41958f0484fSRodney W. Grimes		:fript=bar:who-cares@:tc=old:blah:tc=extensions:
42058f0484fSRodney W. Grimesfile2:
42158f0484fSRodney W. Grimes	old\||\|old_record\||\|an old database record:\e
42258f0484fSRodney W. Grimes		:fript=foo:who-cares:glork#200:
42358f0484fSRodney W. Grimes.Ed
42458f0484fSRodney W. Grimes.Pp
42558f0484fSRodney W. GrimesThe records are extracted by calling
426bf5a138eSMike Pritchard.Fn cgetent
42758f0484fSRodney W. Grimeswith file1 preceding file2.
42858f0484fSRodney W. GrimesIn the capability record new in file1, fript=bar overrides the definition
42958f0484fSRodney W. Grimesof fript=foo interpolated from the capability record old in file2,
43058f0484fSRodney W. Grimeswho-cares@ prevents the definition of any who-cares definitions in old
43158f0484fSRodney W. Grimesfrom being seen, glork#200 is inherited from old, and blah and anything
43258f0484fSRodney W. Grimesdefined by the record extensions is added to those definitions in old.
43358f0484fSRodney W. GrimesNote that the position of the fript=bar and who-cares@ definitions before
4341a0a9345SRuslan Ermilovtc=old is important here.
4351a0a9345SRuslan ErmilovIf they were after, the definitions in old
43658f0484fSRodney W. Grimeswould take precedence.
43758f0484fSRodney W. Grimes.Sh CGETNUM AND CGETSTR SYNTAX AND SEMANTICS
43858f0484fSRodney W. GrimesTwo types are predefined by
439bf5a138eSMike Pritchard.Fn cgetnum
44058f0484fSRodney W. Grimesand
441bf5a138eSMike Pritchard.Fn cgetstr :
442a6dcdf3bSUlrich Spörlein.Pp
443a6dcdf3bSUlrich Spörlein.Bl -tag -width "nameXnumber" -compact
444a6dcdf3bSUlrich Spörlein.It Em name Ns \&# Ns Em number
445a6dcdf3bSUlrich Spörleinnumeric capability
44658f0484fSRodney W. Grimes.Em name
44758f0484fSRodney W. Grimeshas value
44858f0484fSRodney W. Grimes.Em number
449a6dcdf3bSUlrich Spörlein.It Em name Ns = Ns Em string
450a6dcdf3bSUlrich Spörleinstring capability
45158f0484fSRodney W. Grimes.Em name
45258f0484fSRodney W. Grimeshas value
45358f0484fSRodney W. Grimes.Em string
454a6dcdf3bSUlrich Spörlein.It Em name Ns \&#@
455a6dcdf3bSUlrich Spörleinthe numeric capability
456d0353b83SRuslan Ermilov.Em name
457d0353b83SRuslan Ermilovdoes not exist
458a6dcdf3bSUlrich Spörlein.It Em name Ns \&=@
459a6dcdf3bSUlrich Spörleinthe string capability
460d0353b83SRuslan Ermilov.Em name
461d0353b83SRuslan Ermilovdoes not exist
46258f0484fSRodney W. Grimes.El
46358f0484fSRodney W. Grimes.Pp
46458f0484fSRodney W. GrimesNumeric capability values may be given in one of three numeric bases.
46558f0484fSRodney W. GrimesIf the number starts with either
46658f0484fSRodney W. Grimes.Ql 0x
46758f0484fSRodney W. Grimesor
46858f0484fSRodney W. Grimes.Ql 0X
46958f0484fSRodney W. Grimesit is interpreted as a hexadecimal number (both upper and lower case a-f
47058f0484fSRodney W. Grimesmay be used to denote the extended hexadecimal digits).
47158f0484fSRodney W. GrimesOtherwise, if the number starts with a
47258f0484fSRodney W. Grimes.Ql 0
47358f0484fSRodney W. Grimesit is interpreted as an octal number.
47458f0484fSRodney W. GrimesOtherwise the number is interpreted as a decimal number.
47558f0484fSRodney W. Grimes.Pp
4761a0a9345SRuslan ErmilovString capability values may contain any character.
4771a0a9345SRuslan ErmilovNon-printable
47858f0484fSRodney W. Grimes.Dv ASCII
47958f0484fSRodney W. Grimescodes, new lines, and colons may be conveniently represented by the use
48058f0484fSRodney W. Grimesof escape sequences:
48158f0484fSRodney W. Grimes.Bl -column "\e\|X,X\e\|X" "(ASCII octal nnn)"
48221ac7f5fSMike Pritchard^X	('X' & 037)	control-X
48358f0484fSRodney W. Grimes\e\|b, \e\|B	(ASCII 010)	backspace
48458f0484fSRodney W. Grimes\e\|t, \e\|T	(ASCII 011)	tab
48558f0484fSRodney W. Grimes\e\|n, \e\|N	(ASCII 012)	line feed (newline)
48658f0484fSRodney W. Grimes\e\|f, \e\|F	(ASCII 014)	form feed
48758f0484fSRodney W. Grimes\e\|r, \e\|R	(ASCII 015)	carriage return
48858f0484fSRodney W. Grimes\e\|e, \e\|E	(ASCII 027)	escape
48958f0484fSRodney W. Grimes\e\|c, \e\|C	(:)	colon
49058f0484fSRodney W. Grimes\e\|\e	(\e\|)	back slash
49158f0484fSRodney W. Grimes\e\|^	(^)	caret
49221ac7f5fSMike Pritchard\e\|nnn	(ASCII octal nnn)
49358f0484fSRodney W. Grimes.El
49458f0484fSRodney W. Grimes.Pp
49558f0484fSRodney W. GrimesA `\|\e' may be followed by up to three octal digits directly specifies
4961a0a9345SRuslan Ermilovthe numeric code for a character.
4971a0a9345SRuslan ErmilovThe use of
49858f0484fSRodney W. Grimes.Tn ASCII
49958f0484fSRodney W. Grimes.Dv NUL Ns s ,
50058f0484fSRodney W. Grimeswhile easily
50158f0484fSRodney W. Grimesencoded, causes all sorts of problems and must be used with care since
50258f0484fSRodney W. Grimes.Dv NUL Ns s
50358f0484fSRodney W. Grimesare typically used to denote the end of strings; many applications
50458f0484fSRodney W. Grimesuse `\e\|200' to represent a
50558f0484fSRodney W. Grimes.Dv NUL .
50658f0484fSRodney W. Grimes.Sh DIAGNOSTICS
507beb64fb5SMike PritchardThe
508beb64fb5SMike Pritchard.Fn cgetent ,
509bf5a138eSMike Pritchard.Fn cgetset ,
510bf5a138eSMike Pritchard.Fn cgetmatch ,
511bf5a138eSMike Pritchard.Fn cgetnum ,
512bf5a138eSMike Pritchard.Fn cgetstr ,
513bf5a138eSMike Pritchard.Fn cgetustr ,
514bf5a138eSMike Pritchard.Fn cgetfirst ,
51558f0484fSRodney W. Grimesand
516bf5a138eSMike Pritchard.Fn cgetnext
517beb64fb5SMike Pritchardfunctions
51858f0484fSRodney W. Grimesreturn a value greater than or equal to 0 on success and a value less
51958f0484fSRodney W. Grimesthan 0 on failure.
520bf5a138eSMike PritchardThe
521bf5a138eSMike Pritchard.Fn cgetcap
522bf5a138eSMike Pritchardfunction returns a character pointer on success and a
52358f0484fSRodney W. Grimes.Dv NULL
52458f0484fSRodney W. Grimeson failure.
52558f0484fSRodney W. Grimes.Pp
526bf5a138eSMike PritchardThe
527bf5a138eSMike Pritchard.Fn cgetent ,
52858f0484fSRodney W. Grimesand
529af48594dSMaxim Konovalov.Fn cgetset
530bf5a138eSMike Pritchardfunctions may fail and set
53158f0484fSRodney W. Grimes.Va errno
53258f0484fSRodney W. Grimesfor any of the errors specified for the library functions:
533b07158f7SChris Costello.Xr fopen 3 ,
534b07158f7SChris Costello.Xr fclose 3 ,
53558f0484fSRodney W. Grimes.Xr open 2 ,
53658f0484fSRodney W. Grimesand
53758f0484fSRodney W. Grimes.Xr close 2 .
53858f0484fSRodney W. Grimes.Pp
539bf5a138eSMike PritchardThe
540bf5a138eSMike Pritchard.Fn cgetent ,
541bf5a138eSMike Pritchard.Fn cgetset ,
542bf5a138eSMike Pritchard.Fn cgetstr ,
54358f0484fSRodney W. Grimesand
544bf5a138eSMike Pritchard.Fn cgetustr
545beb64fb5SMike Pritchardfunctions
54658f0484fSRodney W. Grimesmay fail and set
54758f0484fSRodney W. Grimes.Va errno
54858f0484fSRodney W. Grimesas follows:
54958f0484fSRodney W. Grimes.Bl -tag -width Er
55058f0484fSRodney W. Grimes.It Bq Er ENOMEM
55158f0484fSRodney W. GrimesNo memory to allocate.
55258f0484fSRodney W. Grimes.El
55358f0484fSRodney W. Grimes.Sh SEE ALSO
55458f0484fSRodney W. Grimes.Xr cap_mkdb 1 ,
55558f0484fSRodney W. Grimes.Xr malloc 3
55658f0484fSRodney W. Grimes.Sh BUGS
5570227791bSRuslan ErmilovColons (`:') cannot be used in names, types, or values.
55858f0484fSRodney W. Grimes.Pp
55958f0484fSRodney W. GrimesThere are no checks for
56042635956SRuslan Ermilov.Ic tc Ns = Ns Ic name
56158f0484fSRodney W. Grimesloops in
562bf5a138eSMike Pritchard.Fn cgetent .
56358f0484fSRodney W. Grimes.Pp
56458f0484fSRodney W. GrimesThe buffer added to the database by a call to
565bf5a138eSMike Pritchard.Fn cgetset
56658f0484fSRodney W. Grimesis not unique to the database but is rather prepended to any database used.
567