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. 1558f0484fSRodney W. Grimes.\" 3. All advertising materials mentioning features or use of this software 1658f0484fSRodney W. Grimes.\" must display the following acknowledgement: 1758f0484fSRodney W. Grimes.\" This product includes software developed by the University of 1858f0484fSRodney W. Grimes.\" California, Berkeley and its contributors. 1958f0484fSRodney W. Grimes.\" 4. Neither the name of the University nor the names of its contributors 2058f0484fSRodney W. Grimes.\" may be used to endorse or promote products derived from this software 2158f0484fSRodney W. Grimes.\" without specific prior written permission. 2258f0484fSRodney W. Grimes.\" 2358f0484fSRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2458f0484fSRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2558f0484fSRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2658f0484fSRodney W. Grimes.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2758f0484fSRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2858f0484fSRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2958f0484fSRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3058f0484fSRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3158f0484fSRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3258f0484fSRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3358f0484fSRodney W. Grimes.\" SUCH DAMAGE. 3458f0484fSRodney W. Grimes.\" 350014b4c0SPeter Wemm.\" @(#)getcap.3 8.4 (Berkeley) 5/13/94 367f3dea24SPeter Wemm.\" $FreeBSD$ 3758f0484fSRodney W. Grimes.\" 38681e5e7aSSteve Price.Dd May 13, 1994 3958f0484fSRodney W. Grimes.Dt GETCAP 3 4058f0484fSRodney W. Grimes.Os 4158f0484fSRodney W. Grimes.Sh NAME 4258f0484fSRodney W. Grimes.Nm cgetent , 4358f0484fSRodney W. Grimes.Nm cgetset , 4458f0484fSRodney W. Grimes.Nm cgetmatch , 4558f0484fSRodney W. Grimes.Nm cgetcap , 4658f0484fSRodney W. Grimes.Nm cgetnum , 4758f0484fSRodney W. Grimes.Nm cgetstr , 4858f0484fSRodney W. Grimes.Nm cgetustr , 4958f0484fSRodney W. Grimes.Nm cgetfirst , 5058f0484fSRodney W. Grimes.Nm cgetnext , 5158f0484fSRodney W. Grimes.Nm cgetclose 5258f0484fSRodney W. Grimes.Nd capability database access routines 5325bb73e0SAlexey Zelkin.Sh LIBRARY 5425bb73e0SAlexey Zelkin.Lb libc 5558f0484fSRodney W. Grimes.Sh SYNOPSIS 5632eef9aeSRuslan Ermilov.In stdlib.h 5758f0484fSRodney W. Grimes.Ft int 5858f0484fSRodney W. Grimes.Fn cgetent "char **buf" "char **db_array" "char *name" 5958f0484fSRodney W. Grimes.Ft int 6058f0484fSRodney W. Grimes.Fn cgetset "char *ent" 6158f0484fSRodney W. Grimes.Ft int 6258f0484fSRodney W. Grimes.Fn cgetmatch "char *buf" "char *name" 6358f0484fSRodney W. Grimes.Ft char * 6409589ca8SBruce Evans.Fn cgetcap "char *buf" "char *cap" "int type" 6558f0484fSRodney W. Grimes.Ft int 6658f0484fSRodney W. Grimes.Fn cgetnum "char *buf" "char *cap" "long *num" 6758f0484fSRodney W. Grimes.Ft int 6858f0484fSRodney W. Grimes.Fn cgetstr "char *buf" "char *cap" "char **str" 6958f0484fSRodney W. Grimes.Ft int 7058f0484fSRodney W. Grimes.Fn cgetustr "char *buf" "char *cap" "char **str" 7158f0484fSRodney W. Grimes.Ft int 7258f0484fSRodney W. Grimes.Fn cgetfirst "char **buf" "char **db_array" 7358f0484fSRodney W. Grimes.Ft int 7458f0484fSRodney W. Grimes.Fn cgetnext "char **buf" "char **db_array" 7558f0484fSRodney W. Grimes.Ft int 7658f0484fSRodney W. Grimes.Fn cgetclose "void" 7758f0484fSRodney W. Grimes.Sh DESCRIPTION 78beb64fb5SMike PritchardThe 79beb64fb5SMike Pritchard.Fn cgetent 80beb64fb5SMike Pritchardfunction extracts the capability 8158f0484fSRodney W. Grimes.Fa name 8258f0484fSRodney W. Grimesfrom the database specified by the 8358f0484fSRodney W. Grimes.Dv NULL 8458f0484fSRodney W. Grimesterminated file array 8558f0484fSRodney W. Grimes.Fa db_array 8658f0484fSRodney W. Grimesand returns a pointer to a 87d0353b83SRuslan Ermilov.Xr malloc 3 Ns \&'d 8858f0484fSRodney W. Grimescopy of it in 8958f0484fSRodney W. Grimes.Fa buf . 90bf5a138eSMike PritchardThe 91bf5a138eSMike Pritchard.Fn cgetent 92bf5a138eSMike Pritchardfunction will first look for files ending in 93d0353b83SRuslan Ermilov.Pa .db 9458f0484fSRodney W. Grimes(see 9558f0484fSRodney W. Grimes.Xr cap_mkdb 1 ) 9658f0484fSRodney W. Grimesbefore accessing the ASCII file. 972efeeba5SRuslan ErmilovThe 982efeeba5SRuslan Ermilov.Fa buf 992efeeba5SRuslan Ermilovargument 10058f0484fSRodney W. Grimesmust be retained through all subsequent calls to 10158f0484fSRodney W. Grimes.Fn cgetmatch , 10258f0484fSRodney W. Grimes.Fn cgetcap , 10358f0484fSRodney W. Grimes.Fn cgetnum , 10458f0484fSRodney W. Grimes.Fn cgetstr , 10558f0484fSRodney W. Grimesand 10658f0484fSRodney W. Grimes.Fn cgetustr , 10758f0484fSRodney W. Grimesbut may then be 108374fc79dSWolfram Schneider.Xr free 3 Ns \&'d . 10958f0484fSRodney W. GrimesOn success 0 is returned, 1 if the returned 11058f0484fSRodney W. Grimesrecord contains an unresolved 111b92cc9b8SRuslan Ermilov.Ic tc 11258f0484fSRodney W. Grimesexpansion, 1130227791bSRuslan Ermilov\-1 if the requested record could not be found, 1140227791bSRuslan Ermilov\-2 if a system error was encountered (could not open/read a file, etc.) also 11558f0484fSRodney W. Grimessetting 11658f0484fSRodney W. Grimes.Va errno , 11758f0484fSRodney W. Grimesand \-3 if a potential reference loop is detected (see 11858f0484fSRodney W. Grimes.Ic tc= 11958f0484fSRodney W. Grimescomments below). 12058f0484fSRodney W. Grimes.Pp 121bf5a138eSMike PritchardThe 122bf5a138eSMike Pritchard.Fn cgetset 123bf5a138eSMike Pritchardfunction enables the addition of a character buffer containing a single capability 12458f0484fSRodney W. Grimesrecord entry 12558f0484fSRodney W. Grimesto the capability database. 12658f0484fSRodney W. GrimesConceptually, the entry is added as the first ``file'' in the database, and 12758f0484fSRodney W. Grimesis therefore searched first on the call to 128bf5a138eSMike Pritchard.Fn cgetent . 12958f0484fSRodney W. GrimesThe entry is passed in 13058f0484fSRodney W. Grimes.Fa ent . 13158f0484fSRodney W. GrimesIf 13258f0484fSRodney W. Grimes.Fa ent 13358f0484fSRodney W. Grimesis 13458f0484fSRodney W. Grimes.Dv NULL , 13558f0484fSRodney W. Grimesthe current entry is removed from the database. 136bf5a138eSMike PritchardA call to 137bf5a138eSMike Pritchard.Fn cgetset 1381a0a9345SRuslan Ermilovmust precede the database traversal. 1391a0a9345SRuslan ErmilovIt must be called before the 140bf5a138eSMike Pritchard.Fn cgetent 1411a0a9345SRuslan Ermilovcall. 1421a0a9345SRuslan ErmilovIf a sequential access is being performed (see below), it must be called 143f9eeb822SDima Dorfmanbefore the first sequential access call 144f9eeb822SDima Dorfman.Fn ( cgetfirst 14558f0484fSRodney W. Grimesor 146f9eeb822SDima Dorfman.Fn cgetnext ) , 147f9eeb822SDima Dorfmanor be directly preceded by a 148bf5a138eSMike Pritchard.Fn cgetclose 14958f0484fSRodney W. Grimescall. 15058f0484fSRodney W. GrimesOn success 0 is returned and \-1 on failure. 15158f0484fSRodney W. Grimes.Pp 152bf5a138eSMike PritchardThe 153bf5a138eSMike Pritchard.Fn cgetmatch 154bf5a138eSMike Pritchardfunction will return 0 if 15558f0484fSRodney W. Grimes.Fa name 15658f0484fSRodney W. Grimesis one of the names of the capability record 15758f0484fSRodney W. Grimes.Fa buf , 15858f0484fSRodney W. Grimes\-1 if 15958f0484fSRodney W. Grimesnot. 16058f0484fSRodney W. Grimes.Pp 161bf5a138eSMike PritchardThe 162bf5a138eSMike Pritchard.Fn cgetcap 163bf5a138eSMike Pritchardfunction searches the capability record 16458f0484fSRodney W. Grimes.Fa buf 16558f0484fSRodney W. Grimesfor the capability 16658f0484fSRodney W. Grimes.Fa cap 16758f0484fSRodney W. Grimeswith type 16858f0484fSRodney W. Grimes.Fa type . 16958f0484fSRodney W. GrimesA 17058f0484fSRodney W. Grimes.Fa type 1711a0a9345SRuslan Ermilovis specified using any single character. 1721a0a9345SRuslan ErmilovIf a colon (`:') is used, an 17358f0484fSRodney W. Grimesuntyped capability will be searched for (see below for explanation of 1741a0a9345SRuslan Ermilovtypes). 1751a0a9345SRuslan ErmilovA pointer to the value of 17658f0484fSRodney W. Grimes.Fa cap 17758f0484fSRodney W. Grimesin 17858f0484fSRodney W. Grimes.Fa buf 17958f0484fSRodney W. Grimesis returned on success, 18058f0484fSRodney W. Grimes.Dv NULL 1810227791bSRuslan Ermilovif the requested capability could not be 1821a0a9345SRuslan Ermilovfound. 1831a0a9345SRuslan ErmilovThe end of the capability value is signaled by a `:' or 18458f0484fSRodney W. Grimes.Tn ASCII 18558f0484fSRodney W. Grimes.Dv NUL 18658f0484fSRodney W. Grimes(see below for capability database syntax). 18758f0484fSRodney W. Grimes.Pp 188bf5a138eSMike PritchardThe 189bf5a138eSMike Pritchard.Fn cgetnum 190bf5a138eSMike Pritchardfunction retrieves the value of the numeric capability 19158f0484fSRodney W. Grimes.Fa cap 19258f0484fSRodney W. Grimesfrom the capability record pointed to by 19358f0484fSRodney W. Grimes.Fa buf . 19458f0484fSRodney W. GrimesThe numeric value is returned in the 19558f0484fSRodney W. Grimes.Ft long 19658f0484fSRodney W. Grimespointed to by 19758f0484fSRodney W. Grimes.Fa num . 1980227791bSRuslan Ermilov0 is returned on success, \-1 if the requested numeric capability could not 19958f0484fSRodney W. Grimesbe found. 20058f0484fSRodney W. Grimes.Pp 201bf5a138eSMike PritchardThe 202bf5a138eSMike Pritchard.Fn cgetstr 203bf5a138eSMike Pritchardfunction retrieves the value of the string capability 20458f0484fSRodney W. Grimes.Fa cap 20558f0484fSRodney W. Grimesfrom the capability record pointed to by 20658f0484fSRodney W. Grimes.Fa buf . 20758f0484fSRodney W. GrimesA pointer to a decoded, 20858f0484fSRodney W. Grimes.Dv NUL 20958f0484fSRodney W. Grimesterminated, 210d0353b83SRuslan Ermilov.Xr malloc 3 Ns \&'d 21158f0484fSRodney W. Grimescopy of the string is returned in the 21258f0484fSRodney W. Grimes.Ft char * 21358f0484fSRodney W. Grimespointed to by 21458f0484fSRodney W. Grimes.Fa str . 21558f0484fSRodney W. GrimesThe number of characters in the decoded string not including the trailing 21658f0484fSRodney W. Grimes.Dv NUL 2170227791bSRuslan Ermilovis returned on success, \-1 if the requested string capability could not 21858f0484fSRodney W. Grimesbe found, \-2 if a system error was encountered (storage allocation 21958f0484fSRodney W. Grimesfailure). 22058f0484fSRodney W. Grimes.Pp 221bf5a138eSMike PritchardThe 222bf5a138eSMike Pritchard.Fn cgetustr 223bf5a138eSMike Pritchardfunction is identical to 224bf5a138eSMike Pritchard.Fn cgetstr 22558f0484fSRodney W. Grimesexcept that it does not expand special characters, but rather returns each 22658f0484fSRodney W. Grimescharacter of the capability string literally. 22758f0484fSRodney W. Grimes.Pp 228bf5a138eSMike PritchardThe 229bf5a138eSMike Pritchard.Fn cgetfirst 230bf5a138eSMike Pritchardand 231bf5a138eSMike Pritchard.Fn cgetnext 232bf5a138eSMike Pritchardfunctions comprise a function group that provides for sequential 23358f0484fSRodney W. Grimesaccess of the 23458f0484fSRodney W. Grimes.Dv NULL 23558f0484fSRodney W. Grimespointer terminated array of file names, 23658f0484fSRodney W. Grimes.Fa db_array . 237bf5a138eSMike PritchardThe 238bf5a138eSMike Pritchard.Fn cgetfirst 239bf5a138eSMike Pritchardfunction returns the first record in the database and resets the access 24058f0484fSRodney W. Grimesto the first record. 241bf5a138eSMike PritchardThe 242bf5a138eSMike Pritchard.Fn cgetnext 243bf5a138eSMike Pritchardfunction returns the next record in the database with respect to the 24458f0484fSRodney W. Grimesrecord returned by the previous 245bf5a138eSMike Pritchard.Fn cgetfirst 24658f0484fSRodney W. Grimesor 247bf5a138eSMike Pritchard.Fn cgetnext 2481a0a9345SRuslan Ermilovcall. 2491a0a9345SRuslan ErmilovIf there is no such previous call, the first record in the database is 25058f0484fSRodney W. Grimesreturned. 25158f0484fSRodney W. GrimesEach record is returned in a 252d0353b83SRuslan Ermilov.Xr malloc 3 Ns \&'d 25358f0484fSRodney W. Grimescopy pointed to by 25458f0484fSRodney W. Grimes.Fa buf . 25558f0484fSRodney W. Grimes.Ic Tc 25658f0484fSRodney W. Grimesexpansion is done (see 25758f0484fSRodney W. Grimes.Ic tc= 25858f0484fSRodney W. Grimescomments below). 25958f0484fSRodney W. GrimesUpon completion of the database 0 is returned, 1 is returned upon successful 2600227791bSRuslan Ermilovreturn of record with possibly more remaining (we have not reached the end of 26158f0484fSRodney W. Grimesthe database yet), 2 is returned if the record contains an unresolved 262b92cc9b8SRuslan Ermilov.Ic tc 263d64ada50SJens Schweikhardtexpansion, \-1 is returned if a system error occurred, and \-2 26458f0484fSRodney W. Grimesis returned if a potential reference loop is detected (see 26558f0484fSRodney W. Grimes.Ic tc= 26658f0484fSRodney W. Grimescomments below). 26758f0484fSRodney W. GrimesUpon completion of database (0 return) the database is closed. 26858f0484fSRodney W. Grimes.Pp 269bf5a138eSMike PritchardThe 270bf5a138eSMike Pritchard.Fn cgetclose 271bf5a138eSMike Pritchardfunction closes the sequential access and frees any memory and file descriptors 2721a0a9345SRuslan Ermilovbeing used. 2731a0a9345SRuslan ErmilovNote that it does not erase the buffer pushed by a call to 274bf5a138eSMike Pritchard.Fn cgetset . 27558f0484fSRodney W. Grimes.Sh CAPABILITY DATABASE SYNTAX 27658f0484fSRodney W. GrimesCapability databases are normally 27758f0484fSRodney W. Grimes.Tn ASCII 27858f0484fSRodney W. Grimesand may be edited with standard 2791a0a9345SRuslan Ermilovtext editors. 2801a0a9345SRuslan ErmilovBlank lines and lines beginning with a `#' are comments 2811a0a9345SRuslan Ermilovand are ignored. 2821a0a9345SRuslan ErmilovLines ending with a `\|\e' indicate that the next line 28358f0484fSRodney W. Grimesis a continuation of the current line; the `\|\e' and following newline 2841a0a9345SRuslan Ermilovare ignored. 2851a0a9345SRuslan ErmilovLong lines are usually continued onto several physical 28658f0484fSRodney W. Grimeslines by ending each line except the last with a `\|\e'. 28758f0484fSRodney W. Grimes.Pp 28858f0484fSRodney W. GrimesCapability databases consist of a series of records, one per logical 2891a0a9345SRuslan Ermilovline. 2901a0a9345SRuslan ErmilovEach record contains a variable number of `:'-separated fields 2911a0a9345SRuslan Ermilov(capabilities). 2921a0a9345SRuslan ErmilovEmpty fields consisting entirely of white space 29358f0484fSRodney W. Grimescharacters (spaces and tabs) are ignored. 29458f0484fSRodney W. Grimes.Pp 29558f0484fSRodney W. GrimesThe first capability of each record specifies its names, separated by `|' 2961a0a9345SRuslan Ermilovcharacters. 2971a0a9345SRuslan ErmilovThese names are used to reference records in the database. 29858f0484fSRodney W. GrimesBy convention, the last name is usually a comment and is not intended as 2991a0a9345SRuslan Ermilova lookup tag. 3001a0a9345SRuslan ErmilovFor example, the 30158f0484fSRodney W. Grimes.Em vt100 30258f0484fSRodney W. Grimesrecord from the 303b92cc9b8SRuslan Ermilov.Xr termcap 5 30458f0484fSRodney W. Grimesdatabase begins: 30558f0484fSRodney W. Grimes.Pp 30658f0484fSRodney W. Grimes.Dl "d0\||\|vt100\||\|vt100-am\||\|vt100am\||\|dec vt100:" 30758f0484fSRodney W. Grimes.Pp 30858f0484fSRodney W. Grimesgiving four names that can be used to access the record. 30958f0484fSRodney W. Grimes.Pp 31058f0484fSRodney W. GrimesThe remaining non-empty capabilities describe a set of (name, value) 31112985df3SDima Dorfmanbindings, consisting of a names optionally followed by a typed value: 31258f0484fSRodney W. Grimes.Bl -column "nameTvalue" 31358f0484fSRodney W. Grimes.It name Ta "typeless [boolean] capability" 31458f0484fSRodney W. Grimes.Em name No "is present [true]" 31558f0484fSRodney W. Grimes.It name Ns Em \&T Ns value Ta capability 31658f0484fSRodney W. Grimes.Pq Em name , \&T 31758f0484fSRodney W. Grimeshas value 31858f0484fSRodney W. Grimes.Em value 31958f0484fSRodney W. Grimes.It name@ Ta "no capability" Em name No exists 32058f0484fSRodney W. Grimes.It name Ns Em T Ns \&@ Ta capability 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.Pp 41758f0484fSRodney W. Grimes.Bd -unfilled -offset indent 41858f0484fSRodney W. Grimesfile1: 41958f0484fSRodney W. Grimes new\||\|new_record\||\|a modification of "old":\e 42058f0484fSRodney W. Grimes :fript=bar:who-cares@:tc=old:blah:tc=extensions: 42158f0484fSRodney W. Grimesfile2: 42258f0484fSRodney W. Grimes old\||\|old_record\||\|an old database record:\e 42358f0484fSRodney W. Grimes :fript=foo:who-cares:glork#200: 42458f0484fSRodney W. Grimes.Ed 42558f0484fSRodney W. Grimes.Pp 42658f0484fSRodney W. GrimesThe records are extracted by calling 427bf5a138eSMike Pritchard.Fn cgetent 42858f0484fSRodney W. Grimeswith file1 preceding file2. 42958f0484fSRodney W. GrimesIn the capability record new in file1, fript=bar overrides the definition 43058f0484fSRodney W. Grimesof fript=foo interpolated from the capability record old in file2, 43158f0484fSRodney W. Grimeswho-cares@ prevents the definition of any who-cares definitions in old 43258f0484fSRodney W. Grimesfrom being seen, glork#200 is inherited from old, and blah and anything 43358f0484fSRodney W. Grimesdefined by the record extensions is added to those definitions in old. 43458f0484fSRodney W. GrimesNote that the position of the fript=bar and who-cares@ definitions before 4351a0a9345SRuslan Ermilovtc=old is important here. 4361a0a9345SRuslan ErmilovIf they were after, the definitions in old 43758f0484fSRodney W. Grimeswould take precedence. 43858f0484fSRodney W. Grimes.Sh CGETNUM AND CGETSTR SYNTAX AND SEMANTICS 43958f0484fSRodney W. GrimesTwo types are predefined by 440bf5a138eSMike Pritchard.Fn cgetnum 44158f0484fSRodney W. Grimesand 442bf5a138eSMike Pritchard.Fn cgetstr : 44358f0484fSRodney W. Grimes.Bl -column "nameXnumber" 44458f0484fSRodney W. Grimes.Sm off 44558f0484fSRodney W. Grimes.It Em name No \&# Em number Ta numeric 446d0353b83SRuslan Ermilov.Sm on 44758f0484fSRodney W. Grimescapability 44858f0484fSRodney W. Grimes.Em name 44958f0484fSRodney W. Grimeshas value 45058f0484fSRodney W. Grimes.Em number 451d0353b83SRuslan Ermilov.Sm off 45258f0484fSRodney W. Grimes.It Em name No = Em string Ta "string capability" 453d0353b83SRuslan Ermilov.Sm on 45458f0484fSRodney W. Grimes.Em name 45558f0484fSRodney W. Grimeshas value 45658f0484fSRodney W. Grimes.Em string 457d0353b83SRuslan Ermilov.Sm off 45858f0484fSRodney W. Grimes.It Em name No \&#@ Ta "the numeric capability" 45942635956SRuslan Ermilov.Sm on 460d0353b83SRuslan Ermilov.Em name 461d0353b83SRuslan Ermilovdoes not exist 462d0353b83SRuslan Ermilov.Sm off 463d0353b83SRuslan Ermilov.It Em name No \&=@ Ta "the string capability" 464d0353b83SRuslan Ermilov.Sm on 465d0353b83SRuslan Ermilov.Em name 466d0353b83SRuslan Ermilovdoes not exist 46758f0484fSRodney W. Grimes.El 46858f0484fSRodney W. Grimes.Pp 46958f0484fSRodney W. GrimesNumeric capability values may be given in one of three numeric bases. 47058f0484fSRodney W. GrimesIf the number starts with either 47158f0484fSRodney W. Grimes.Ql 0x 47258f0484fSRodney W. Grimesor 47358f0484fSRodney W. Grimes.Ql 0X 47458f0484fSRodney W. Grimesit is interpreted as a hexadecimal number (both upper and lower case a-f 47558f0484fSRodney W. Grimesmay be used to denote the extended hexadecimal digits). 47658f0484fSRodney W. GrimesOtherwise, if the number starts with a 47758f0484fSRodney W. Grimes.Ql 0 47858f0484fSRodney W. Grimesit is interpreted as an octal number. 47958f0484fSRodney W. GrimesOtherwise the number is interpreted as a decimal number. 48058f0484fSRodney W. Grimes.Pp 4811a0a9345SRuslan ErmilovString capability values may contain any character. 4821a0a9345SRuslan ErmilovNon-printable 48358f0484fSRodney W. Grimes.Dv ASCII 48458f0484fSRodney W. Grimescodes, new lines, and colons may be conveniently represented by the use 48558f0484fSRodney W. Grimesof escape sequences: 48658f0484fSRodney W. Grimes.Bl -column "\e\|X,X\e\|X" "(ASCII octal nnn)" 48721ac7f5fSMike Pritchard^X ('X' & 037) control-X 48858f0484fSRodney W. Grimes\e\|b, \e\|B (ASCII 010) backspace 48958f0484fSRodney W. Grimes\e\|t, \e\|T (ASCII 011) tab 49058f0484fSRodney W. Grimes\e\|n, \e\|N (ASCII 012) line feed (newline) 49158f0484fSRodney W. Grimes\e\|f, \e\|F (ASCII 014) form feed 49258f0484fSRodney W. Grimes\e\|r, \e\|R (ASCII 015) carriage return 49358f0484fSRodney W. Grimes\e\|e, \e\|E (ASCII 027) escape 49458f0484fSRodney W. Grimes\e\|c, \e\|C (:) colon 49558f0484fSRodney W. Grimes\e\|\e (\e\|) back slash 49658f0484fSRodney W. Grimes\e\|^ (^) caret 49721ac7f5fSMike Pritchard\e\|nnn (ASCII octal nnn) 49858f0484fSRodney W. Grimes.El 49958f0484fSRodney W. Grimes.Pp 50058f0484fSRodney W. GrimesA `\|\e' may be followed by up to three octal digits directly specifies 5011a0a9345SRuslan Ermilovthe numeric code for a character. 5021a0a9345SRuslan ErmilovThe use of 50358f0484fSRodney W. Grimes.Tn ASCII 50458f0484fSRodney W. Grimes.Dv NUL Ns s , 50558f0484fSRodney W. Grimeswhile easily 50658f0484fSRodney W. Grimesencoded, causes all sorts of problems and must be used with care since 50758f0484fSRodney W. Grimes.Dv NUL Ns s 50858f0484fSRodney W. Grimesare typically used to denote the end of strings; many applications 50958f0484fSRodney W. Grimesuse `\e\|200' to represent a 51058f0484fSRodney W. Grimes.Dv NUL . 51158f0484fSRodney W. Grimes.Sh DIAGNOSTICS 512beb64fb5SMike PritchardThe 513beb64fb5SMike Pritchard.Fn cgetent , 514bf5a138eSMike Pritchard.Fn cgetset , 515bf5a138eSMike Pritchard.Fn cgetmatch , 516bf5a138eSMike Pritchard.Fn cgetnum , 517bf5a138eSMike Pritchard.Fn cgetstr , 518bf5a138eSMike Pritchard.Fn cgetustr , 519bf5a138eSMike Pritchard.Fn cgetfirst , 52058f0484fSRodney W. Grimesand 521bf5a138eSMike Pritchard.Fn cgetnext 522beb64fb5SMike Pritchardfunctions 52358f0484fSRodney W. Grimesreturn a value greater than or equal to 0 on success and a value less 52458f0484fSRodney W. Grimesthan 0 on failure. 525bf5a138eSMike PritchardThe 526bf5a138eSMike Pritchard.Fn cgetcap 527bf5a138eSMike Pritchardfunction returns a character pointer on success and a 52858f0484fSRodney W. Grimes.Dv NULL 52958f0484fSRodney W. Grimeson failure. 53058f0484fSRodney W. Grimes.Pp 531bf5a138eSMike PritchardThe 532bf5a138eSMike Pritchard.Fn cgetent , 53358f0484fSRodney W. Grimesand 534bf5a138eSMike Pritchard.Fn cgetseq 535bf5a138eSMike Pritchardfunctions may fail and set 53658f0484fSRodney W. Grimes.Va errno 53758f0484fSRodney W. Grimesfor any of the errors specified for the library functions: 538b07158f7SChris Costello.Xr fopen 3 , 539b07158f7SChris Costello.Xr fclose 3 , 54058f0484fSRodney W. Grimes.Xr open 2 , 54158f0484fSRodney W. Grimesand 54258f0484fSRodney W. Grimes.Xr close 2 . 54358f0484fSRodney W. Grimes.Pp 544bf5a138eSMike PritchardThe 545bf5a138eSMike Pritchard.Fn cgetent , 546bf5a138eSMike Pritchard.Fn cgetset , 547bf5a138eSMike Pritchard.Fn cgetstr , 54858f0484fSRodney W. Grimesand 549bf5a138eSMike Pritchard.Fn cgetustr 550beb64fb5SMike Pritchardfunctions 55158f0484fSRodney W. Grimesmay fail and set 55258f0484fSRodney W. Grimes.Va errno 55358f0484fSRodney W. Grimesas follows: 55458f0484fSRodney W. Grimes.Bl -tag -width Er 55558f0484fSRodney W. Grimes.It Bq Er ENOMEM 55658f0484fSRodney W. GrimesNo memory to allocate. 55758f0484fSRodney W. Grimes.El 55858f0484fSRodney W. Grimes.Sh SEE ALSO 55958f0484fSRodney W. Grimes.Xr cap_mkdb 1 , 56058f0484fSRodney W. Grimes.Xr malloc 3 56158f0484fSRodney W. Grimes.Sh BUGS 5620227791bSRuslan ErmilovColons (`:') cannot be used in names, types, or values. 56358f0484fSRodney W. Grimes.Pp 56458f0484fSRodney W. GrimesThere are no checks for 56542635956SRuslan Ermilov.Ic tc Ns = Ns Ic name 56658f0484fSRodney W. Grimesloops in 567bf5a138eSMike Pritchard.Fn cgetent . 56858f0484fSRodney W. Grimes.Pp 56958f0484fSRodney W. GrimesThe buffer added to the database by a call to 570bf5a138eSMike Pritchard.Fn cgetset 57158f0484fSRodney W. Grimesis not unique to the database but is rather prepended to any database used. 572