1994-05-27 05:00:24 +00:00
|
|
|
.\" Copyright (c) 1992, 1993
|
|
|
|
.\" The Regents of the University of California. All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" This code is derived from software contributed to Berkeley by
|
|
|
|
.\" Casey Leedom of Lawrence Livermore National Laboratory.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
|
|
.\" must display the following acknowledgement:
|
|
|
|
.\" This product includes software developed by the University of
|
|
|
|
.\" California, Berkeley and its contributors.
|
|
|
|
.\" 4. Neither the name of the University nor the names of its contributors
|
|
|
|
.\" may be used to endorse or promote products derived from this software
|
|
|
|
.\" without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
1997-03-11 11:47:52 +00:00
|
|
|
.\" @(#)getcap.3 8.4 (Berkeley) 5/13/94
|
1999-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
1994-05-27 05:00:24 +00:00
|
|
|
.\"
|
1997-06-23 04:03:49 +00:00
|
|
|
.Dd May 13, 1994
|
2000-10-30 13:23:19 +00:00
|
|
|
.Dt GETCAP 3
|
1994-05-27 05:00:24 +00:00
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm cgetent ,
|
|
|
|
.Nm cgetset ,
|
|
|
|
.Nm cgetmatch ,
|
|
|
|
.Nm cgetcap ,
|
|
|
|
.Nm cgetnum ,
|
|
|
|
.Nm cgetstr ,
|
|
|
|
.Nm cgetustr ,
|
|
|
|
.Nm cgetfirst ,
|
|
|
|
.Nm cgetnext ,
|
|
|
|
.Nm cgetclose
|
|
|
|
.Nd capability database access routines
|
2000-04-21 09:42:15 +00:00
|
|
|
.Sh LIBRARY
|
|
|
|
.Lb libc
|
1994-05-27 05:00:24 +00:00
|
|
|
.Sh SYNOPSIS
|
2001-10-01 16:09:29 +00:00
|
|
|
.In stdlib.h
|
1994-05-27 05:00:24 +00:00
|
|
|
.Ft int
|
|
|
|
.Fn cgetent "char **buf" "char **db_array" "char *name"
|
|
|
|
.Ft int
|
|
|
|
.Fn cgetset "char *ent"
|
|
|
|
.Ft int
|
|
|
|
.Fn cgetmatch "char *buf" "char *name"
|
|
|
|
.Ft char *
|
1997-03-19 00:52:58 +00:00
|
|
|
.Fn cgetcap "char *buf" "char *cap" "int type"
|
1994-05-27 05:00:24 +00:00
|
|
|
.Ft int
|
|
|
|
.Fn cgetnum "char *buf" "char *cap" "long *num"
|
|
|
|
.Ft int
|
|
|
|
.Fn cgetstr "char *buf" "char *cap" "char **str"
|
|
|
|
.Ft int
|
|
|
|
.Fn cgetustr "char *buf" "char *cap" "char **str"
|
|
|
|
.Ft int
|
|
|
|
.Fn cgetfirst "char **buf" "char **db_array"
|
|
|
|
.Ft int
|
|
|
|
.Fn cgetnext "char **buf" "char **db_array"
|
|
|
|
.Ft int
|
|
|
|
.Fn cgetclose "void"
|
|
|
|
.Sh DESCRIPTION
|
2000-10-28 18:37:37 +00:00
|
|
|
The
|
|
|
|
.Fn cgetent
|
|
|
|
function extracts the capability
|
1994-05-27 05:00:24 +00:00
|
|
|
.Fa name
|
|
|
|
from the database specified by the
|
|
|
|
.Dv NULL
|
|
|
|
terminated file array
|
|
|
|
.Fa db_array
|
|
|
|
and returns a pointer to a
|
2001-02-01 16:38:02 +00:00
|
|
|
.Xr malloc 3 Ns \&'d
|
1994-05-27 05:00:24 +00:00
|
|
|
copy of it in
|
2000-10-30 13:23:19 +00:00
|
|
|
.Fa buf .
|
1996-08-22 22:05:59 +00:00
|
|
|
The
|
|
|
|
.Fn cgetent
|
2000-10-30 13:23:19 +00:00
|
|
|
function will first look for files ending in
|
2001-02-01 16:38:02 +00:00
|
|
|
.Pa .db
|
1994-05-27 05:00:24 +00:00
|
|
|
(see
|
2000-10-30 13:23:19 +00:00
|
|
|
.Xr cap_mkdb 1 )
|
1994-05-27 05:00:24 +00:00
|
|
|
before accessing the ASCII file.
|
2002-12-19 09:40:28 +00:00
|
|
|
The
|
|
|
|
.Fa buf
|
|
|
|
argument
|
1994-05-27 05:00:24 +00:00
|
|
|
must be retained through all subsequent calls to
|
|
|
|
.Fn cgetmatch ,
|
|
|
|
.Fn cgetcap ,
|
|
|
|
.Fn cgetnum ,
|
|
|
|
.Fn cgetstr ,
|
|
|
|
and
|
|
|
|
.Fn cgetustr ,
|
|
|
|
but may then be
|
2001-02-01 16:38:02 +00:00
|
|
|
.Xr free 3 Ns \&'d .
|
1994-05-27 05:00:24 +00:00
|
|
|
On success 0 is returned, 1 if the returned
|
2000-10-30 13:23:19 +00:00
|
|
|
record contains an unresolved
|
2002-12-18 10:10:32 +00:00
|
|
|
.Ic tc
|
1994-05-27 05:00:24 +00:00
|
|
|
expansion,
|
2005-02-13 22:25:33 +00:00
|
|
|
\-1 if the requested record could not be found,
|
|
|
|
\-2 if a system error was encountered (could not open/read a file, etc.) also
|
1994-05-27 05:00:24 +00:00
|
|
|
setting
|
2000-10-30 13:23:19 +00:00
|
|
|
.Va errno ,
|
1994-05-27 05:00:24 +00:00
|
|
|
and \-3 if a potential reference loop is detected (see
|
|
|
|
.Ic tc=
|
|
|
|
comments below).
|
|
|
|
.Pp
|
1996-08-22 22:05:59 +00:00
|
|
|
The
|
2000-10-30 13:23:19 +00:00
|
|
|
.Fn cgetset
|
1996-08-22 22:05:59 +00:00
|
|
|
function enables the addition of a character buffer containing a single capability
|
1994-05-27 05:00:24 +00:00
|
|
|
record entry
|
2000-10-30 13:23:19 +00:00
|
|
|
to the capability database.
|
1994-05-27 05:00:24 +00:00
|
|
|
Conceptually, the entry is added as the first ``file'' in the database, and
|
2000-10-30 13:23:19 +00:00
|
|
|
is therefore searched first on the call to
|
1996-08-22 22:05:59 +00:00
|
|
|
.Fn cgetent .
|
2000-10-30 13:23:19 +00:00
|
|
|
The entry is passed in
|
1994-05-27 05:00:24 +00:00
|
|
|
.Fa ent .
|
2000-10-30 13:23:19 +00:00
|
|
|
If
|
|
|
|
.Fa ent
|
1994-05-27 05:00:24 +00:00
|
|
|
is
|
|
|
|
.Dv NULL ,
|
2000-10-30 13:23:19 +00:00
|
|
|
the current entry is removed from the database.
|
1996-08-22 22:05:59 +00:00
|
|
|
A call to
|
2000-10-30 13:23:19 +00:00
|
|
|
.Fn cgetset
|
2004-07-02 23:52:20 +00:00
|
|
|
must precede the database traversal.
|
|
|
|
It must be called before the
|
2000-10-30 13:23:19 +00:00
|
|
|
.Fn cgetent
|
2004-07-02 23:52:20 +00:00
|
|
|
call.
|
|
|
|
If a sequential access is being performed (see below), it must be called
|
2001-07-03 21:16:34 +00:00
|
|
|
before the first sequential access call
|
|
|
|
.Fn ( cgetfirst
|
1994-05-27 05:00:24 +00:00
|
|
|
or
|
2001-07-03 21:16:34 +00:00
|
|
|
.Fn cgetnext ) ,
|
|
|
|
or be directly preceded by a
|
1996-08-22 22:05:59 +00:00
|
|
|
.Fn cgetclose
|
1994-05-27 05:00:24 +00:00
|
|
|
call.
|
|
|
|
On success 0 is returned and \-1 on failure.
|
|
|
|
.Pp
|
1996-08-22 22:05:59 +00:00
|
|
|
The
|
|
|
|
.Fn cgetmatch
|
|
|
|
function will return 0 if
|
1994-05-27 05:00:24 +00:00
|
|
|
.Fa name
|
|
|
|
is one of the names of the capability record
|
|
|
|
.Fa buf ,
|
|
|
|
\-1 if
|
|
|
|
not.
|
|
|
|
.Pp
|
1996-08-22 22:05:59 +00:00
|
|
|
The
|
|
|
|
.Fn cgetcap
|
|
|
|
function searches the capability record
|
1994-05-27 05:00:24 +00:00
|
|
|
.Fa buf
|
|
|
|
for the capability
|
|
|
|
.Fa cap
|
|
|
|
with type
|
|
|
|
.Fa type .
|
|
|
|
A
|
|
|
|
.Fa type
|
2004-07-02 23:52:20 +00:00
|
|
|
is specified using any single character.
|
|
|
|
If a colon (`:') is used, an
|
1994-05-27 05:00:24 +00:00
|
|
|
untyped capability will be searched for (see below for explanation of
|
2004-07-02 23:52:20 +00:00
|
|
|
types).
|
|
|
|
A pointer to the value of
|
1994-05-27 05:00:24 +00:00
|
|
|
.Fa cap
|
|
|
|
in
|
|
|
|
.Fa buf
|
|
|
|
is returned on success,
|
|
|
|
.Dv NULL
|
2005-02-13 22:25:33 +00:00
|
|
|
if the requested capability could not be
|
2004-07-02 23:52:20 +00:00
|
|
|
found.
|
|
|
|
The end of the capability value is signaled by a `:' or
|
1994-05-27 05:00:24 +00:00
|
|
|
.Tn ASCII
|
|
|
|
.Dv NUL
|
|
|
|
(see below for capability database syntax).
|
|
|
|
.Pp
|
1996-08-22 22:05:59 +00:00
|
|
|
The
|
|
|
|
.Fn cgetnum
|
|
|
|
function retrieves the value of the numeric capability
|
1994-05-27 05:00:24 +00:00
|
|
|
.Fa cap
|
|
|
|
from the capability record pointed to by
|
|
|
|
.Fa buf .
|
|
|
|
The numeric value is returned in the
|
|
|
|
.Ft long
|
|
|
|
pointed to by
|
|
|
|
.Fa num .
|
2005-02-13 22:25:33 +00:00
|
|
|
0 is returned on success, \-1 if the requested numeric capability could not
|
1994-05-27 05:00:24 +00:00
|
|
|
be found.
|
|
|
|
.Pp
|
1996-08-22 22:05:59 +00:00
|
|
|
The
|
|
|
|
.Fn cgetstr
|
|
|
|
function retrieves the value of the string capability
|
1994-05-27 05:00:24 +00:00
|
|
|
.Fa cap
|
|
|
|
from the capability record pointed to by
|
|
|
|
.Fa buf .
|
|
|
|
A pointer to a decoded,
|
|
|
|
.Dv NUL
|
|
|
|
terminated,
|
2001-02-01 16:38:02 +00:00
|
|
|
.Xr malloc 3 Ns \&'d
|
1994-05-27 05:00:24 +00:00
|
|
|
copy of the string is returned in the
|
|
|
|
.Ft char *
|
|
|
|
pointed to by
|
|
|
|
.Fa str .
|
|
|
|
The number of characters in the decoded string not including the trailing
|
|
|
|
.Dv NUL
|
2005-02-13 22:25:33 +00:00
|
|
|
is returned on success, \-1 if the requested string capability could not
|
1994-05-27 05:00:24 +00:00
|
|
|
be found, \-2 if a system error was encountered (storage allocation
|
|
|
|
failure).
|
|
|
|
.Pp
|
1996-08-22 22:05:59 +00:00
|
|
|
The
|
|
|
|
.Fn cgetustr
|
2000-10-30 13:23:19 +00:00
|
|
|
function is identical to
|
|
|
|
.Fn cgetstr
|
1994-05-27 05:00:24 +00:00
|
|
|
except that it does not expand special characters, but rather returns each
|
|
|
|
character of the capability string literally.
|
|
|
|
.Pp
|
1996-08-22 22:05:59 +00:00
|
|
|
The
|
|
|
|
.Fn cgetfirst
|
|
|
|
and
|
2000-10-30 13:23:19 +00:00
|
|
|
.Fn cgetnext
|
1996-08-22 22:05:59 +00:00
|
|
|
functions comprise a function group that provides for sequential
|
1994-05-27 05:00:24 +00:00
|
|
|
access of the
|
|
|
|
.Dv NULL
|
|
|
|
pointer terminated array of file names,
|
|
|
|
.Fa db_array .
|
1996-08-22 22:05:59 +00:00
|
|
|
The
|
2000-10-30 13:23:19 +00:00
|
|
|
.Fn cgetfirst
|
1996-08-22 22:05:59 +00:00
|
|
|
function returns the first record in the database and resets the access
|
1994-05-27 05:00:24 +00:00
|
|
|
to the first record.
|
1996-08-22 22:05:59 +00:00
|
|
|
The
|
2000-10-30 13:23:19 +00:00
|
|
|
.Fn cgetnext
|
1996-08-22 22:05:59 +00:00
|
|
|
function returns the next record in the database with respect to the
|
1994-05-27 05:00:24 +00:00
|
|
|
record returned by the previous
|
1996-08-22 22:05:59 +00:00
|
|
|
.Fn cgetfirst
|
1994-05-27 05:00:24 +00:00
|
|
|
or
|
2000-10-30 13:23:19 +00:00
|
|
|
.Fn cgetnext
|
2004-07-02 23:52:20 +00:00
|
|
|
call.
|
|
|
|
If there is no such previous call, the first record in the database is
|
1994-05-27 05:00:24 +00:00
|
|
|
returned.
|
|
|
|
Each record is returned in a
|
2001-02-01 16:38:02 +00:00
|
|
|
.Xr malloc 3 Ns \&'d
|
2000-10-30 13:23:19 +00:00
|
|
|
copy pointed to by
|
|
|
|
.Fa buf .
|
1994-05-27 05:00:24 +00:00
|
|
|
.Ic Tc
|
|
|
|
expansion is done (see
|
2000-10-30 13:23:19 +00:00
|
|
|
.Ic tc=
|
1994-05-27 05:00:24 +00:00
|
|
|
comments below).
|
2004-07-03 22:30:10 +00:00
|
|
|
Upon completion of the database 0 is returned, 1 is returned upon successful
|
2005-02-13 22:25:33 +00:00
|
|
|
return of record with possibly more remaining (we have not reached the end of
|
1994-05-27 05:00:24 +00:00
|
|
|
the database yet), 2 is returned if the record contains an unresolved
|
2002-12-18 10:10:32 +00:00
|
|
|
.Ic tc
|
2002-12-30 21:18:15 +00:00
|
|
|
expansion, \-1 is returned if a system error occurred, and \-2
|
2000-10-30 13:23:19 +00:00
|
|
|
is returned if a potential reference loop is detected (see
|
1994-05-27 05:00:24 +00:00
|
|
|
.Ic tc=
|
|
|
|
comments below).
|
|
|
|
Upon completion of database (0 return) the database is closed.
|
|
|
|
.Pp
|
1996-08-22 22:05:59 +00:00
|
|
|
The
|
2000-10-30 13:23:19 +00:00
|
|
|
.Fn cgetclose
|
|
|
|
function closes the sequential access and frees any memory and file descriptors
|
2004-07-02 23:52:20 +00:00
|
|
|
being used.
|
|
|
|
Note that it does not erase the buffer pushed by a call to
|
1996-08-22 22:05:59 +00:00
|
|
|
.Fn cgetset .
|
1994-05-27 05:00:24 +00:00
|
|
|
.Sh CAPABILITY DATABASE SYNTAX
|
|
|
|
Capability databases are normally
|
|
|
|
.Tn ASCII
|
|
|
|
and may be edited with standard
|
2004-07-02 23:52:20 +00:00
|
|
|
text editors.
|
|
|
|
Blank lines and lines beginning with a `#' are comments
|
|
|
|
and are ignored.
|
|
|
|
Lines ending with a `\|\e' indicate that the next line
|
1994-05-27 05:00:24 +00:00
|
|
|
is a continuation of the current line; the `\|\e' and following newline
|
2004-07-02 23:52:20 +00:00
|
|
|
are ignored.
|
|
|
|
Long lines are usually continued onto several physical
|
1994-05-27 05:00:24 +00:00
|
|
|
lines by ending each line except the last with a `\|\e'.
|
|
|
|
.Pp
|
|
|
|
Capability databases consist of a series of records, one per logical
|
2004-07-02 23:52:20 +00:00
|
|
|
line.
|
|
|
|
Each record contains a variable number of `:'-separated fields
|
|
|
|
(capabilities).
|
|
|
|
Empty fields consisting entirely of white space
|
1994-05-27 05:00:24 +00:00
|
|
|
characters (spaces and tabs) are ignored.
|
|
|
|
.Pp
|
|
|
|
The first capability of each record specifies its names, separated by `|'
|
2004-07-02 23:52:20 +00:00
|
|
|
characters.
|
|
|
|
These names are used to reference records in the database.
|
1994-05-27 05:00:24 +00:00
|
|
|
By convention, the last name is usually a comment and is not intended as
|
2004-07-02 23:52:20 +00:00
|
|
|
a lookup tag.
|
|
|
|
For example, the
|
1994-05-27 05:00:24 +00:00
|
|
|
.Em vt100
|
|
|
|
record from the
|
2002-12-18 10:10:32 +00:00
|
|
|
.Xr termcap 5
|
1994-05-27 05:00:24 +00:00
|
|
|
database begins:
|
|
|
|
.Pp
|
|
|
|
.Dl "d0\||\|vt100\||\|vt100-am\||\|vt100am\||\|dec vt100:"
|
|
|
|
.Pp
|
|
|
|
giving four names that can be used to access the record.
|
|
|
|
.Pp
|
|
|
|
The remaining non-empty capabilities describe a set of (name, value)
|
2001-06-20 22:03:10 +00:00
|
|
|
bindings, consisting of a names optionally followed by a typed value:
|
1994-05-27 05:00:24 +00:00
|
|
|
.Bl -column "nameTvalue"
|
|
|
|
.It name Ta "typeless [boolean] capability"
|
|
|
|
.Em name No "is present [true]"
|
|
|
|
.It name Ns Em \&T Ns value Ta capability
|
|
|
|
.Pq Em name , \&T
|
|
|
|
has value
|
|
|
|
.Em value
|
|
|
|
.It name@ Ta "no capability" Em name No exists
|
|
|
|
.It name Ns Em T Ns \&@ Ta capability
|
|
|
|
.Pq Em name , T
|
|
|
|
does not exist
|
|
|
|
.El
|
|
|
|
.Pp
|
2004-07-02 23:52:20 +00:00
|
|
|
Names consist of one or more characters.
|
|
|
|
Names may contain any character
|
2005-02-13 23:45:54 +00:00
|
|
|
except `:', but it is usually best to restrict them to the printable
|
2004-07-03 22:30:10 +00:00
|
|
|
characters and avoid use of graphics like `#', `=', `%', `@', etc.
|
|
|
|
Types
|
1994-05-27 05:00:24 +00:00
|
|
|
are single characters used to separate capability names from their
|
2004-07-02 23:52:20 +00:00
|
|
|
associated typed values.
|
|
|
|
Types may be any character except a `:'.
|
|
|
|
Typically, graphics like `#', `=', `%', etc.\& are used.
|
|
|
|
Values may be any
|
1994-05-27 05:00:24 +00:00
|
|
|
number of characters and may contain any character except `:'.
|
|
|
|
.Sh CAPABILITY DATABASE SEMANTICS
|
2004-07-02 23:52:20 +00:00
|
|
|
Capability records describe a set of (name, value) bindings.
|
|
|
|
Names may
|
|
|
|
have multiple values bound to them.
|
|
|
|
Different values for a name are
|
1994-05-27 05:00:24 +00:00
|
|
|
distinguished by their
|
|
|
|
.Fa types .
|
1996-08-22 22:05:59 +00:00
|
|
|
The
|
|
|
|
.Fn cgetcap
|
2000-10-30 13:23:19 +00:00
|
|
|
function will return a pointer to a value of a name given the capability
|
1996-08-22 22:05:59 +00:00
|
|
|
name and the type of the value.
|
1994-05-27 05:00:24 +00:00
|
|
|
.Pp
|
|
|
|
The types `#' and `=' are conventionally used to denote numeric and
|
2004-07-02 23:52:20 +00:00
|
|
|
string typed values, but no restriction on those types is enforced.
|
|
|
|
The
|
1994-05-27 05:00:24 +00:00
|
|
|
functions
|
1996-08-22 22:05:59 +00:00
|
|
|
.Fn cgetnum
|
1994-05-27 05:00:24 +00:00
|
|
|
and
|
1996-08-22 22:05:59 +00:00
|
|
|
.Fn cgetstr
|
1994-05-27 05:00:24 +00:00
|
|
|
can be used to implement the traditional syntax and semantics of `#'
|
|
|
|
and `='.
|
|
|
|
Typeless capabilities are typically used to denote boolean objects with
|
|
|
|
presence or absence indicating truth and false values respectively.
|
|
|
|
This interpretation is conveniently represented by:
|
|
|
|
.Pp
|
|
|
|
.Dl "(getcap(buf, name, ':') != NULL)"
|
|
|
|
.Pp
|
|
|
|
A special capability,
|
|
|
|
.Ic tc= name ,
|
|
|
|
is used to indicate that the record specified by
|
|
|
|
.Fa name
|
|
|
|
should be substituted for the
|
|
|
|
.Ic tc
|
|
|
|
capability.
|
|
|
|
.Ic Tc
|
|
|
|
capabilities may interpolate records which also contain
|
|
|
|
.Ic tc
|
|
|
|
capabilities and more than one
|
|
|
|
.Ic tc
|
2004-07-02 23:52:20 +00:00
|
|
|
capability may be used in a record.
|
|
|
|
A
|
1994-05-27 05:00:24 +00:00
|
|
|
.Ic tc
|
|
|
|
expansion scope (i.e., where the argument is searched for) contains the
|
|
|
|
file in which the
|
|
|
|
.Ic tc
|
|
|
|
is declared and all subsequent files in the file array.
|
|
|
|
.Pp
|
|
|
|
When a database is searched for a capability record, the first matching
|
2004-07-02 23:52:20 +00:00
|
|
|
record in the search is returned.
|
|
|
|
When a record is scanned for a
|
1994-05-27 05:00:24 +00:00
|
|
|
capability, the first matching capability is returned; the capability
|
|
|
|
.Ic :nameT@:
|
|
|
|
will hide any following definition of a value of type
|
|
|
|
.Em T
|
|
|
|
for
|
|
|
|
.Fa name ;
|
|
|
|
and the capability
|
|
|
|
.Ic :name@:
|
|
|
|
will prevent any following values of
|
|
|
|
.Fa name
|
|
|
|
from being seen.
|
|
|
|
.Pp
|
|
|
|
These features combined with
|
|
|
|
.Ic tc
|
|
|
|
capabilities can be used to generate variations of other databases and
|
|
|
|
records by either adding new capabilities, overriding definitions with new
|
|
|
|
definitions, or hiding following definitions via `@' capabilities.
|
|
|
|
.Sh EXAMPLES
|
|
|
|
.Bd -unfilled -offset indent
|
|
|
|
example\||\|an example of binding multiple values to names:\e
|
|
|
|
:foo%bar:foo^blah:foo@:\e
|
|
|
|
:abc%xyz:abc^frap:abc$@:\e
|
|
|
|
:tc=more:
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
The capability foo has two values bound to it (bar of type `%' and blah of
|
2004-07-02 23:52:20 +00:00
|
|
|
type `^') and any other value bindings are hidden.
|
|
|
|
The capability abc
|
1994-05-27 05:00:24 +00:00
|
|
|
also has two values bound but only a value of type `$' is prevented from
|
|
|
|
being defined in the capability record more.
|
|
|
|
.Pp
|
|
|
|
.Bd -unfilled -offset indent
|
|
|
|
file1:
|
|
|
|
new\||\|new_record\||\|a modification of "old":\e
|
|
|
|
:fript=bar:who-cares@:tc=old:blah:tc=extensions:
|
|
|
|
file2:
|
|
|
|
old\||\|old_record\||\|an old database record:\e
|
|
|
|
:fript=foo:who-cares:glork#200:
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
The records are extracted by calling
|
1996-08-22 22:05:59 +00:00
|
|
|
.Fn cgetent
|
1994-05-27 05:00:24 +00:00
|
|
|
with file1 preceding file2.
|
|
|
|
In the capability record new in file1, fript=bar overrides the definition
|
|
|
|
of fript=foo interpolated from the capability record old in file2,
|
|
|
|
who-cares@ prevents the definition of any who-cares definitions in old
|
|
|
|
from being seen, glork#200 is inherited from old, and blah and anything
|
|
|
|
defined by the record extensions is added to those definitions in old.
|
|
|
|
Note that the position of the fript=bar and who-cares@ definitions before
|
2004-07-02 23:52:20 +00:00
|
|
|
tc=old is important here.
|
|
|
|
If they were after, the definitions in old
|
1994-05-27 05:00:24 +00:00
|
|
|
would take precedence.
|
|
|
|
.Sh CGETNUM AND CGETSTR SYNTAX AND SEMANTICS
|
|
|
|
Two types are predefined by
|
1996-08-22 22:05:59 +00:00
|
|
|
.Fn cgetnum
|
1994-05-27 05:00:24 +00:00
|
|
|
and
|
1996-08-22 22:05:59 +00:00
|
|
|
.Fn cgetstr :
|
1994-05-27 05:00:24 +00:00
|
|
|
.Bl -column "nameXnumber"
|
|
|
|
.Sm off
|
|
|
|
.It Em name No \&# Em number Ta numeric
|
2001-02-01 16:38:02 +00:00
|
|
|
.Sm on
|
1994-05-27 05:00:24 +00:00
|
|
|
capability
|
|
|
|
.Em name
|
|
|
|
has value
|
|
|
|
.Em number
|
2001-02-01 16:38:02 +00:00
|
|
|
.Sm off
|
1994-05-27 05:00:24 +00:00
|
|
|
.It Em name No = Em string Ta "string capability"
|
2001-02-01 16:38:02 +00:00
|
|
|
.Sm on
|
1994-05-27 05:00:24 +00:00
|
|
|
.Em name
|
2000-10-30 13:23:19 +00:00
|
|
|
has value
|
1994-05-27 05:00:24 +00:00
|
|
|
.Em string
|
2001-02-01 16:38:02 +00:00
|
|
|
.Sm off
|
1994-05-27 05:00:24 +00:00
|
|
|
.It Em name No \&#@ Ta "the numeric capability"
|
2001-02-01 16:38:02 +00:00
|
|
|
.Sm on
|
1994-05-27 05:00:24 +00:00
|
|
|
.Em name
|
|
|
|
does not exist
|
2001-02-01 16:38:02 +00:00
|
|
|
.Sm off
|
1994-05-27 05:00:24 +00:00
|
|
|
.It Em name No \&=@ Ta "the string capability"
|
2001-02-01 16:38:02 +00:00
|
|
|
.Sm on
|
1994-05-27 05:00:24 +00:00
|
|
|
.Em name
|
|
|
|
does not exist
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
Numeric capability values may be given in one of three numeric bases.
|
|
|
|
If the number starts with either
|
|
|
|
.Ql 0x
|
|
|
|
or
|
|
|
|
.Ql 0X
|
|
|
|
it is interpreted as a hexadecimal number (both upper and lower case a-f
|
|
|
|
may be used to denote the extended hexadecimal digits).
|
|
|
|
Otherwise, if the number starts with a
|
|
|
|
.Ql 0
|
|
|
|
it is interpreted as an octal number.
|
|
|
|
Otherwise the number is interpreted as a decimal number.
|
|
|
|
.Pp
|
2004-07-02 23:52:20 +00:00
|
|
|
String capability values may contain any character.
|
|
|
|
Non-printable
|
1994-05-27 05:00:24 +00:00
|
|
|
.Dv ASCII
|
|
|
|
codes, new lines, and colons may be conveniently represented by the use
|
|
|
|
of escape sequences:
|
|
|
|
.Bl -column "\e\|X,X\e\|X" "(ASCII octal nnn)"
|
1997-01-31 01:06:39 +00:00
|
|
|
^X ('X' & 037) control-X
|
1994-05-27 05:00:24 +00:00
|
|
|
\e\|b, \e\|B (ASCII 010) backspace
|
|
|
|
\e\|t, \e\|T (ASCII 011) tab
|
|
|
|
\e\|n, \e\|N (ASCII 012) line feed (newline)
|
|
|
|
\e\|f, \e\|F (ASCII 014) form feed
|
|
|
|
\e\|r, \e\|R (ASCII 015) carriage return
|
|
|
|
\e\|e, \e\|E (ASCII 027) escape
|
|
|
|
\e\|c, \e\|C (:) colon
|
|
|
|
\e\|\e (\e\|) back slash
|
|
|
|
\e\|^ (^) caret
|
1997-01-31 01:06:39 +00:00
|
|
|
\e\|nnn (ASCII octal nnn)
|
1994-05-27 05:00:24 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
A `\|\e' may be followed by up to three octal digits directly specifies
|
2004-07-02 23:52:20 +00:00
|
|
|
the numeric code for a character.
|
|
|
|
The use of
|
1994-05-27 05:00:24 +00:00
|
|
|
.Tn ASCII
|
|
|
|
.Dv NUL Ns s ,
|
|
|
|
while easily
|
|
|
|
encoded, causes all sorts of problems and must be used with care since
|
|
|
|
.Dv NUL Ns s
|
|
|
|
are typically used to denote the end of strings; many applications
|
|
|
|
use `\e\|200' to represent a
|
|
|
|
.Dv NUL .
|
|
|
|
.Sh DIAGNOSTICS
|
2000-10-28 18:37:37 +00:00
|
|
|
The
|
|
|
|
.Fn cgetent ,
|
1996-08-22 22:05:59 +00:00
|
|
|
.Fn cgetset ,
|
|
|
|
.Fn cgetmatch ,
|
|
|
|
.Fn cgetnum ,
|
|
|
|
.Fn cgetstr ,
|
|
|
|
.Fn cgetustr ,
|
|
|
|
.Fn cgetfirst ,
|
1994-05-27 05:00:24 +00:00
|
|
|
and
|
1996-08-22 22:05:59 +00:00
|
|
|
.Fn cgetnext
|
2000-10-28 18:37:37 +00:00
|
|
|
functions
|
1994-05-27 05:00:24 +00:00
|
|
|
return a value greater than or equal to 0 on success and a value less
|
|
|
|
than 0 on failure.
|
1996-08-22 22:05:59 +00:00
|
|
|
The
|
|
|
|
.Fn cgetcap
|
|
|
|
function returns a character pointer on success and a
|
1994-05-27 05:00:24 +00:00
|
|
|
.Dv NULL
|
|
|
|
on failure.
|
|
|
|
.Pp
|
1996-08-22 22:05:59 +00:00
|
|
|
The
|
|
|
|
.Fn cgetent ,
|
2000-10-30 13:23:19 +00:00
|
|
|
and
|
1996-08-22 22:05:59 +00:00
|
|
|
.Fn cgetseq
|
2000-10-30 13:23:19 +00:00
|
|
|
functions may fail and set
|
1994-05-27 05:00:24 +00:00
|
|
|
.Va errno
|
|
|
|
for any of the errors specified for the library functions:
|
2000-10-30 13:23:19 +00:00
|
|
|
.Xr fopen 3 ,
|
1999-08-14 07:07:46 +00:00
|
|
|
.Xr fclose 3 ,
|
1994-05-27 05:00:24 +00:00
|
|
|
.Xr open 2 ,
|
2000-10-30 13:23:19 +00:00
|
|
|
and
|
1994-05-27 05:00:24 +00:00
|
|
|
.Xr close 2 .
|
|
|
|
.Pp
|
1996-08-22 22:05:59 +00:00
|
|
|
The
|
|
|
|
.Fn cgetent ,
|
|
|
|
.Fn cgetset ,
|
|
|
|
.Fn cgetstr ,
|
1994-05-27 05:00:24 +00:00
|
|
|
and
|
2000-10-30 13:23:19 +00:00
|
|
|
.Fn cgetustr
|
2000-10-28 18:37:37 +00:00
|
|
|
functions
|
2000-10-30 13:23:19 +00:00
|
|
|
may fail and set
|
|
|
|
.Va errno
|
1994-05-27 05:00:24 +00:00
|
|
|
as follows:
|
|
|
|
.Bl -tag -width Er
|
|
|
|
.It Bq Er ENOMEM
|
|
|
|
No memory to allocate.
|
|
|
|
.El
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr cap_mkdb 1 ,
|
|
|
|
.Xr malloc 3
|
|
|
|
.Sh BUGS
|
2005-02-13 22:25:33 +00:00
|
|
|
Colons (`:') cannot be used in names, types, or values.
|
1994-05-27 05:00:24 +00:00
|
|
|
.Pp
|
|
|
|
There are no checks for
|
2000-12-29 14:08:20 +00:00
|
|
|
.Ic tc Ns = Ns Ic name
|
1994-05-27 05:00:24 +00:00
|
|
|
loops in
|
1996-08-22 22:05:59 +00:00
|
|
|
.Fn cgetent .
|
1994-05-27 05:00:24 +00:00
|
|
|
.Pp
|
2000-10-30 13:23:19 +00:00
|
|
|
The buffer added to the database by a call to
|
|
|
|
.Fn cgetset
|
1994-05-27 05:00:24 +00:00
|
|
|
is not unique to the database but is rather prepended to any database used.
|