<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
                   "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<!-- lifted from troff+man by doclifter -->
<refentry id='xgetresman'>
<!-- '\" e -->
<!--  Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium -->

<!--  Permission is hereby granted, free of charge, to any person obtaining -->
<!--  a copy of this software and associated documentation files (the -->
<!--  "Software"), to deal in the Software without restriction, including -->
<!--  without limitation the rights to use, copy, modify, merge, publish, -->
<!--  distribute, sublicense, and/or sell copies of the Software, and to -->
<!--  permit persons to whom the Software is furnished to do so, subject to -->
<!--  the following conditions: -->

<!--  The above copyright notice and this permission notice shall be included -->
<!--  in all copies or substantial portions of the Software. -->

<!--  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -->
<!--  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -->
<!--  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -->
<!--  IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR -->
<!--  OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -->
<!--  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -->
<!--  OTHER DEALINGS IN THE SOFTWARE. -->

<!--  Except as contained in this notice, the name of the X Consortium shall -->
<!--  not be used in advertising or otherwise to promote the sale, use or -->
<!--  other dealings in this Software without prior written authorization -->
<!--  from the X Consortium. -->

<!--  Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by -->
<!--  Digital Equipment Corporation -->

<!--  Portions Copyright \(co 1990, 1991 by -->
<!--  Tektronix, Inc. -->

<!--  Permission to use, copy, modify and distribute this documentation for -->
<!--  any purpose and without fee is hereby granted, provided that the above -->
<!--  copyright notice appears in all copies and that both that copyright notice -->
<!--  and this permission notice appear in all copies, and that the names of -->
<!--  Digital and Tektronix not be used in in advertising or publicity pertaining -->
<!--  to this documentation without specific, written prior permission. -->
<!--  Digital and Tektronix makes no representations about the suitability -->
<!--  of this documentation for any purpose. -->
<!--  It is provided ``as is'' without express or implied warranty. -->
<!--   -->
<!--  $XFree86: xc/doc/man/X11/XGetRes.man,v 1.4 2003/04/28 22:17:54 herrb Exp $ -->

<!-- .na -->
<!-- Ds listing suppressed (not used) -->
<!-- De listing suppressed (not used) -->
<!-- FD listing suppressed (not used) -->
<!-- FN listing suppressed (not used) -->
<!-- IN listing suppressed (not used) -->
<!-- C{ listing suppressed (not used) -->
<!-- C} listing suppressed (not used) -->
<!-- Pn listing suppressed (not used) -->
<!-- hN listing suppressed (not used) -->
<!-- NT listing suppressed (not used) -->
<!-- .		\" Note End \-\- doug kraft 3/85 -->
<!-- NE listing suppressed (not used) -->
<!-- .ny0 -->
<!-- '\" e -->
<refmeta>
<refentrytitle>XrmGetResource</refentrytitle>
<manvolnum>3X11</manvolnum>
<refmiscinfo class='date'>__xorgversion__</refmiscinfo>
<refmiscinfo class='source'>XLIB FUNCTIONS</refmiscinfo>
</refmeta>
<refnamediv id='name'>
<refname>XrmGetResource</refname>
<refname>XrmQGetResource</refname>
<refname>XrmQGetSearchList</refname>
<refname>XrmQGetSearchResource</refname>
<refpurpose>retrieve database resources and search lists</refpurpose>
</refnamediv>
<!-- body begins here -->

<refsect1 id='syntax'><title>SYNTAX</title>

<para>Bool XrmGetResource&hairsp;(&hairsp;XrmDatabase <emphasis remap='I'>database</emphasis>&hairsp;, char *<emphasis remap='I'>str_name</emphasis>&hairsp;,
char *<emphasis remap='I'>str_class</emphasis>&hairsp;, char **<emphasis remap='I'>str_type_return</emphasis>&hairsp;, XrmValue
*<emphasis remap='I'>value_return</emphasis>&hairsp;);</para> 

<para>Bool XrmQGetResource&hairsp;(&hairsp;XrmDatabase <emphasis remap='I'>database</emphasis>&hairsp;, XrmNameList
<emphasis remap='I'>quark_name</emphasis>&hairsp;, XrmClassList <emphasis remap='I'>quark_class</emphasis>&hairsp;, XrmRepresentation
*<emphasis remap='I'>quark_type_return</emphasis>&hairsp;, XrmValue *<emphasis remap='I'>value_return</emphasis>&hairsp;);</para> 

<para>typedef XrmHashTable *XrmSearchList;</para>

<para>Bool XrmQGetSearchList&hairsp;(&hairsp;XrmDatabase <emphasis remap='I'>database</emphasis>&hairsp;, XrmNameList
<emphasis remap='I'>names</emphasis>&hairsp;, XrmClassList <emphasis remap='I'>classes</emphasis>&hairsp;, XrmSearchList
<emphasis remap='I'>list_return</emphasis>&hairsp;, int <emphasis remap='I'>list_length</emphasis>&hairsp;);</para> 

<para>Bool XrmQGetSearchResource&hairsp;(&hairsp;XrmSearchList <emphasis remap='I'>list</emphasis>&hairsp;, XrmName
<emphasis remap='I'>name</emphasis>&hairsp;, XrmClass <emphasis remap='I'>class</emphasis>&hairsp;, XrmRepresentation *<emphasis remap='I'>type_return</emphasis>&hairsp;, 
XrmValue *<emphasis remap='I'>value_return</emphasis>&hairsp;);</para> 
</refsect1>

<refsect1 id='arguments'><title>ARGUMENTS</title>
<variablelist remap='IP'>
  <varlistentry>
  <term><emphasis remap='I'>class</emphasis></term>
  <listitem>
<para>Specifies the resource class.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>classes</emphasis></term>
  <listitem>
<para>Specifies a list of resource classes.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>database</emphasis></term>
  <listitem>
<para>Specifies the database that is to be used.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>list</emphasis></term>
  <listitem>
<para>Specifies the search list returned by
<emphasis remap='I'>&hairsp;XrmQGetSearchList&hairsp;</emphasis>.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>list_length</emphasis></term>
  <listitem>
<para>Specifies the number of entries (not the byte size) allocated for list_return.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>list_return</emphasis></term>
  <listitem>
<para>Returns a search list for further use.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>name</emphasis></term>
  <listitem>
<para>Specifies the resource name.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>names</emphasis></term>
  <listitem>
<para>Specifies a list of resource names.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>quark_class</emphasis></term>
  <listitem>
<para>Specifies the fully qualified class of the value being retrieved (as a quark).</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>quark_name</emphasis></term>
  <listitem>
<para>Specifies the fully qualified name of the value being retrieved (as a quark).</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>quark_type_return</emphasis></term>
  <listitem>
<para>Returns the representation type of the destination (as a quark).</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>str_class</emphasis></term>
  <listitem>
<para>Specifies the fully qualified class of the value being retrieved (as a string).</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>str_name</emphasis></term>
  <listitem>
<para>Specifies the fully qualified name of the value being retrieved (as a string).</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>str_type_return</emphasis></term>
  <listitem>
<para>Returns the representation type of the destination (as a string).</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>type_return</emphasis></term>
  <listitem>
<para>Returns data representation type.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>value_return</emphasis></term>
  <listitem>
<para>Returns the value in the database.</para>
  </listitem>
  </varlistentry>
</variablelist>
</refsect1>

<refsect1 id='description'><title>DESCRIPTION</title>
<para>The 
<emphasis remap='I'>&hairsp;XrmGetResource&hairsp;</emphasis>
and 
<emphasis remap='I'>&hairsp;XrmQGetResource&hairsp;</emphasis>
functions retrieve a resource from the specified database.
Both take a fully qualified name/class pair, a destination
resource representation, and the address of a value
(size/address pair).  
The value and returned type point into database memory;
therefore, you must not modify the data.</para>

<para>The database only frees or overwrites entries on
<emphasis remap='I'>&hairsp;XrmPutResource&hairsp;</emphasis>,
<emphasis remap='I'>&hairsp;XrmQPutResource&hairsp;</emphasis>,
or 
<emphasis remap='I'>&hairsp;XrmMergeDatabases&hairsp;</emphasis>.
A client that is not storing new values into the database or
is not merging the database should be safe using the address passed 
back at any time until it exits.
If a resource was found, both
<emphasis remap='I'>&hairsp;XrmGetResource&hairsp;</emphasis>
and
<emphasis remap='I'>&hairsp;XrmQGetResource&hairsp;</emphasis>
return 
<emphasis remap='I'>&hairsp;True&hairsp;</emphasis>;
otherwise, they return 
<emphasis remap='I'>&hairsp;False&hairsp;</emphasis>.</para>

<para>The
<emphasis remap='I'>&hairsp;XrmQGetSearchList&hairsp;</emphasis>
function takes a list of names and classes
and returns a list of database levels where a match might occur.
The returned list is in best-to-worst order and
uses the same algorithm as 
<emphasis remap='I'>&hairsp;XrmGetResource&hairsp;</emphasis>
for determining precedence.
If list_return was large enough for the search list,
<emphasis remap='I'>&hairsp;XrmQGetSearchList&hairsp;</emphasis>
returns 
<emphasis remap='I'>&hairsp;True&hairsp;</emphasis>;
otherwise, it returns
<emphasis remap='I'>&hairsp;False&hairsp;</emphasis>.</para>

<para>The size of the search list that the caller must allocate is
dependent upon the number of levels and wildcards in the resource specifiers 
that are stored in the database.
The worst case length is %3 sup n%,
where <emphasis remap='I'>n</emphasis> is the number of name or class components in names or classes.</para>

<para>When using 
<emphasis remap='I'>&hairsp;XrmQGetSearchList&hairsp;</emphasis>
followed by multiple probes for resources with a common name and class prefix,
only the common prefix should be specified in the name and class list to 
<emphasis remap='I'>&hairsp;XrmQGetSearchList&hairsp;</emphasis>.</para>

<para>The
<emphasis remap='I'>&hairsp;XrmQGetSearchResource&hairsp;</emphasis>
function searches the specified database levels for the resource 
that is fully identified by the specified name and class.
The search stops with the first match.
<emphasis remap='I'>&hairsp;XrmQGetSearchResource&hairsp;</emphasis>
returns 
<emphasis remap='I'>&hairsp;True&hairsp;</emphasis>
if the resource was found;
otherwise, it returns
<emphasis remap='I'>&hairsp;False&hairsp;</emphasis>.</para>

<para>A call to 
<emphasis remap='I'>&hairsp;XrmQGetSearchList&hairsp;</emphasis>
with a name and class list containing all but the last component 
of a resource name followed by a call to 
<emphasis remap='I'>&hairsp;XrmQGetSearchResource&hairsp;</emphasis>
with the last component name and class returns the same database entry as 
<emphasis remap='I'>&hairsp;XrmGetResource&hairsp;</emphasis>
and 
<emphasis remap='I'>&hairsp;XrmQGetResource&hairsp;</emphasis>
with the fully qualified name and class.</para>
</refsect1>

<refsect1 id='matching_rules'><title>MATCHING RULES</title>
<para>The algorithm for determining which resource database entry
matches a given query is the heart of the resource manager.
All queries must fully specify the name and class of the desired resource
(use of the characters &ldquo;*&rdquo; and &ldquo;?&rdquo; are not permitted).
The library supports up to 100 components in a full name or class.
Resources are stored in the database with only partially specified
names and classes, using pattern matching constructs.
An asterisk (*) is a loose binding and is used to represent any number
of intervening components, including none.
A period (.) is a tight binding and is used to separate immediately
adjacent components.
A question mark (?) is used to match any single component name or class.
A database entry cannot end in a loose binding;
the final component (which cannot be the character &ldquo;?&rdquo;) must be specified.
The lookup algorithm searches the database for the entry that most
closely matches (is most specific for) the full name and class being queried.
When more than one database entry matches the full name and class,
precedence rules are used to select just one.</para>

<para>The full name and class are scanned from left to right (from highest
level in the hierarchy to lowest), one component at a time.
At each level, the corresponding component and/or binding of each
matching entry is determined, and these matching components and
bindings are compared according to precedence rules.
Each of the rules is applied at each level before moving to the next level,
until a rule selects a single entry over all others.
The rules, in order of precedence, are:</para>
<variablelist remap='IP'>
  <varlistentry>
  <term>1.</term>
  <listitem>
<para>An entry that contains a matching component (whether name, class,
or the character &ldquo;?&rdquo;)
takes precedence over entries that elide the level (that is, entries
that match the level in a loose binding).</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term>2.</term>
  <listitem>
<para>An entry with a matching name takes precedence over both
entries with a matching class and entries that match using the character &ldquo;?&rdquo;.
An entry with a matching class takes precedence over
entries that match using the character &ldquo;?&rdquo;.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term>3.</term>
  <listitem>
<para>An entry preceded by a tight binding takes precedence over entries
preceded by a loose binding.</para>
  </listitem>
  </varlistentry>
</variablelist>
</refsect1>

<refsect1 id='see_also'><title>SEE ALSO</title>
<para>XrmInitialize(3X11),
XrmMergeDatabases(3X11),
XrmPutResource(3X11),
XrmUniqueQuark(3X11)
<!-- .br -->
<userinput>Xlib - C Language X Interface</userinput></para>
</refsect1>
</refentry>

