2001-03-01 04:28:40 +00:00
|
|
|
.\" -*- nroff -*-
|
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 2001 M. Warner Losh
|
|
|
|
.\"
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" This program is free software.
|
|
|
|
.\"
|
|
|
|
.\" 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.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``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 DEVELOPERS 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.
|
|
|
|
.\"
|
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
|
|
|
.Dd March 1, 2001
|
|
|
|
.Dt RESOURCE_QUERY_STRING 9
|
2001-07-10 15:31:11 +00:00
|
|
|
.Os
|
2001-03-01 04:28:40 +00:00
|
|
|
.Sh NAME
|
2001-03-02 08:09:19 +00:00
|
|
|
.Nm resource_query_string , resource_query_name , resource_query_unit
|
|
|
|
.Nd query the
|
2001-03-02 04:30:16 +00:00
|
|
|
.Dq hints
|
|
|
|
database for matches
|
2001-03-01 04:28:40 +00:00
|
|
|
.Sh SYNOPSIS
|
2001-10-01 16:09:29 +00:00
|
|
|
.In sys/bus.h
|
2001-03-01 04:28:40 +00:00
|
|
|
.Ft int
|
|
|
|
.Fn resource_query_string "int num" "const char *field" "const char *what"
|
|
|
|
.Ft char *
|
|
|
|
.Fn resource_query_name "int num"
|
2001-03-02 04:30:16 +00:00
|
|
|
.Ft int
|
|
|
|
.Fn resource_query_unit "int num"
|
2001-03-01 04:28:40 +00:00
|
|
|
.Sh DESCRIPTION
|
2001-03-02 08:09:19 +00:00
|
|
|
.Fn resource_query_string
|
2001-03-02 04:30:16 +00:00
|
|
|
enumerates all devices in the
|
|
|
|
.Dq hints
|
|
|
|
database whose
|
|
|
|
.Fa field
|
|
|
|
value matches the
|
2001-03-01 04:28:40 +00:00
|
|
|
.Fa what
|
2001-03-02 04:30:16 +00:00
|
|
|
parameter.
|
|
|
|
A cookie is returned for use as the
|
|
|
|
.Fa num
|
|
|
|
parameter in calls to
|
|
|
|
.Fn resource_query_name
|
|
|
|
and
|
|
|
|
.Fn resource_query_unit .
|
|
|
|
This cookie should be passed as the
|
|
|
|
.Fa num
|
|
|
|
parameter on subsequent calls.
|
|
|
|
A return value of \-1 means no further matches exist.
|
2001-03-01 04:28:40 +00:00
|
|
|
.Pp
|
2001-03-02 08:09:19 +00:00
|
|
|
.Fn resource_query_name
|
2001-03-02 04:30:16 +00:00
|
|
|
returns the name of the device matched by
|
|
|
|
.Fn resource_query_string .
|
|
|
|
.Pp
|
|
|
|
.Fn resource_query_unit
|
|
|
|
returns the unit of the device matched by
|
|
|
|
.Fn resource_query_string .
|
|
|
|
.Pp
|
2001-03-02 08:09:19 +00:00
|
|
|
The functions take the following arguments:
|
|
|
|
.Bl -tag -width "field"
|
|
|
|
.It Fa num
|
2001-03-02 04:30:16 +00:00
|
|
|
is the
|
|
|
|
.Dq index
|
|
|
|
of the item to lookup.
|
|
|
|
Set to \-1 for the first call, and the return value of the previous
|
2001-03-01 04:28:40 +00:00
|
|
|
.Fn resource_query_string
|
|
|
|
on subsequent calls.
|
2001-03-02 04:30:16 +00:00
|
|
|
The
|
|
|
|
.Dq index
|
2001-03-02 08:09:19 +00:00
|
|
|
is an opaque cookie.
|
|
|
|
.It Fa field
|
2001-03-02 04:30:16 +00:00
|
|
|
is the name of the field in the
|
|
|
|
.Dq hints
|
|
|
|
database to query.
|
2001-03-02 08:09:19 +00:00
|
|
|
.It Fa what
|
2001-03-02 04:30:16 +00:00
|
|
|
is the value of
|
|
|
|
.Fa field
|
|
|
|
in the
|
|
|
|
.Dq hints
|
|
|
|
database for which to search.
|
2001-03-02 08:09:19 +00:00
|
|
|
.El
|
2001-03-01 04:28:40 +00:00
|
|
|
.Sh RETURN VALUES
|
2001-03-02 04:30:16 +00:00
|
|
|
.Fn resource_query_string
|
2001-03-02 08:09:19 +00:00
|
|
|
returns \-1 on failure, otherwise a cookie to pass to
|
|
|
|
.Fn resource_query_name
|
2001-03-02 04:30:16 +00:00
|
|
|
or
|
|
|
|
.Fn resource_query_unit .
|
|
|
|
.Pp
|
|
|
|
.Fn resource_query_name
|
|
|
|
returns the device name matching the cookie.
|
|
|
|
.Pp
|
|
|
|
.Fn resource_query_unit
|
|
|
|
returns the device unit number matching the cookie.
|
2001-03-01 04:28:40 +00:00
|
|
|
.Sh EXAMPLES
|
2001-03-02 04:30:16 +00:00
|
|
|
The following example will return all the
|
|
|
|
.Dq hints
|
|
|
|
that say they are
|
2001-03-02 08:09:19 +00:00
|
|
|
.Dq Li "at gerbil0" .
|
|
|
|
.Pp
|
2001-03-01 09:01:43 +00:00
|
|
|
An example hint would be:
|
2001-03-02 08:09:19 +00:00
|
|
|
.Bd -literal -offset indent
|
2001-03-01 04:28:40 +00:00
|
|
|
hint.habitat.0.at="gerbil0"
|
|
|
|
hint.ewheel.0.at="gerbil0"
|
|
|
|
hint.fred.0.at="nexus"
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
The following code
|
2001-03-02 08:09:19 +00:00
|
|
|
.Bd -literal -offset indent
|
|
|
|
int i = -1;
|
|
|
|
while ((i = resource_query_string(i, "at", "gerbil0")) != -1) {
|
|
|
|
printf("Found %s%d at gerbil0\en", resource_query_name(i),
|
|
|
|
resource_query_unit(i));
|
|
|
|
}
|
2001-03-01 04:28:40 +00:00
|
|
|
.Ed
|
2001-03-02 08:09:19 +00:00
|
|
|
.Pp
|
2001-03-01 04:28:40 +00:00
|
|
|
would produce two lines:
|
2001-03-02 08:09:19 +00:00
|
|
|
.Bd -literal -offset indent
|
2001-03-01 04:28:40 +00:00
|
|
|
Found habitat0 at gerbil0
|
|
|
|
Found ewheel0 at gerbil0
|
|
|
|
.Ed
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr device 9 ,
|
2001-03-02 08:09:19 +00:00
|
|
|
.Xr driver 9 ,
|
|
|
|
.Xr resource_int_value 9
|
2001-03-01 04:28:40 +00:00
|
|
|
.Sh AUTHORS
|
2001-03-02 08:09:19 +00:00
|
|
|
This manual page was written by
|
2001-03-01 04:28:40 +00:00
|
|
|
.An Warner Losh Aq imp@FreeBSD.org .
|