1 '\" te
   2 .\" Copyright (c) 2005, Sun Microsystems, Inc. All Rights Reserved.
   3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
   4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
   5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
   6 .TH POOL_GET_POOL 3POOL "Jul 18, 2005"
   7 .SH NAME
   8 pool_get_pool, pool_get_resource, pool_query_components, pool_query_pools,
   9 pool_query_resources \- retrieve resource pool configuration elements
  10 .SH SYNOPSIS
  11 .LP
  12 .nf
  13 cc [ \fIflag\fR]\&.\|.\|.  \fIfile\fR\&.\|.\|. \fB-lpool\fR [ \fIlibrary\fR\&.\|.\|. ]
  14 #include <pool.h>
  15 
  16 \fBpool_t *\fR\fBpool_get_pool\fR(\fBpool_conf_t *\fR\fIconf\fR, \fBconst char *\fR\fIname\fR);
  17 .fi
  18 
  19 .LP
  20 .nf
  21 \fBpool_resource_t *\fR\fBpool_get_resource\fR(\fBpool_conf_t *\fR\fIconf\fR
  22      \fBconst char *\fR\fItype\fR, \fBconst char *\fR\fIname\fR);
  23 .fi
  24 
  25 .LP
  26 .nf
  27 \fBpool_component_t **\fR\fBpool_query_components\fR(\fBpool_conf_t *\fR\fIconf\fR,
  28      \fBuint_t *\fR\fInelem\fR, \fBpool_value_t **\fR\fIprops\fR);
  29 .fi
  30 
  31 .LP
  32 .nf
  33 \fBpool_t **\fR\fBpool_query_pools\fR(\fBpool_conf_t *\fR\fIconf\fR, \fBuint_t *\fR\fInelem\fR,
  34      \fBpool_value_t **\fR\fIprops\fR);
  35 .fi
  36 
  37 .LP
  38 .nf
  39 \fBpool_component_t **\fR\fBpool_query_resources\fR(\fBpool_conf_t *\fR\fIconf\fR,
  40      \fBuint_t *\fR\fInelem\fR, \fBpool_value_t **\fR\fIprops\fR);
  41 .fi
  42 
  43 .SH DESCRIPTION
  44 .sp
  45 .LP
  46 These functions provide a means for querying the contents of the specified
  47 configuration. The \fIconf\fR argument for each function refers to the target
  48 configuration to which the operation applies.
  49 .sp
  50 .LP
  51 The \fBpool_get_pool()\fR function returns the pool with the given name from
  52 the provided configuration.
  53 .sp
  54 .LP
  55 The \fBpool_get_resource()\fR function returns the resource with the given name
  56 and type from the provided configuration.
  57 .sp
  58 .LP
  59 The \fBpool_query_components()\fR function retrieves all resource components
  60 that match the given list of properties. If the list of properties is
  61 \fINULL\fR, all components are returned. The number of elements returned is
  62 stored in the location pointed to by \fInelem\fR. The value returned by
  63 \fBpool_query_components()\fR is allocated with \fBmalloc\fR(3C) and must be
  64 explicitly freed.
  65 .sp
  66 .LP
  67 The \fBpool_query_pools()\fR function behaves similarly to
  68 \fBpool_query_components()\fR and returns the list of pools that match the
  69 given list of properties. The value returned must be freed by the caller.
  70 .sp
  71 .LP
  72 The \fBpool_query_resources()\fR function similarly returns the list of
  73 resources that match the given list of properties. The return value must be
  74 freed by the caller.
  75 .SH RETURN VALUES
  76 .sp
  77 .LP
  78 The \fBpool_get_pool()\fR and \fBpool_get_resource()\fR functions return the
  79 matching pool and resource, respectively. Otherwise, they return \fINULL\fR and
  80 \fBpool_error\fR(3POOL) returns the pool-specific error value.
  81 .sp
  82 .LP
  83 The \fBpool_query_components()\fR, \fBpool_query_pools()\fR, and
  84 \fBpool_query_resources()\fR functions return a null-terminated array of
  85 components, pools, and resources, respectively. If the query was unsuccessful
  86 or there were no matches, \fINULL\fR is returned and \fBpool_error()\fR returns
  87 the pool-specific error value.
  88 .SH ERRORS
  89 .sp
  90 .LP
  91 The \fBpool_get_pool()\fR will fail if:
  92 .sp
  93 .ne 2
  94 .na
  95 \fB\fBPOE_BADPARAM\fR\fR
  96 .ad
  97 .RS 16n
  98 The supplied configuration's status is not \fBPOF_VALID\fR.
  99 .RE
 100 
 101 .sp
 102 .LP
 103 The \fBpool_get_resource()\fR will fail if:
 104 .sp
 105 .ne 2
 106 .na
 107 \fB\fBPOE_BADPARAM\fR\fR
 108 .ad
 109 .RS 16n
 110 The supplied configuration's status is not \fBPOF_VALID\fR.
 111 .RE
 112 
 113 .sp
 114 .ne 2
 115 .na
 116 \fB\fBPOE_SYSTEM\fR\fR
 117 .ad
 118 .RS 16n
 119 There is not enough memory available to allocate working buffers. Check
 120 \fBerrno\fR for the specific system error code.
 121 .RE
 122 
 123 .sp
 124 .LP
 125 The \fBpool_query_components()\fR, \fBpool_query_pools()\fR, and
 126 \fBpool_query_resources()\fR will fail if:
 127 .sp
 128 .ne 2
 129 .na
 130 \fB\fBPOE_BADPARAM\fR\fR
 131 .ad
 132 .RS 20n
 133 The supplied configuration's status is not \fBPOF_VALID\fR.
 134 .RE
 135 
 136 .sp
 137 .ne 2
 138 .na
 139 \fB\fBPOE_INVALID_CONF\fR\fR
 140 .ad
 141 .RS 20n
 142 The query generated results that were not of the correct type. The
 143 configuration is invalid.
 144 .RE
 145 
 146 .sp
 147 .ne 2
 148 .na
 149 \fB\fBPOE_SYSTEM\fR\fR
 150 .ad
 151 .RS 20n
 152 There is not enough memory available to allocate working buffers. Check
 153 \fBerrno\fR for the specific system error code.
 154 .RE
 155 
 156 .SH EXAMPLES
 157 .LP
 158 \fBExample 1 \fRRetrieve the pool named "foo" from a given configuration.
 159 .sp
 160 .in +2
 161 .nf
 162 #include <pool.h>
 163 #include <stdio.h>
 164 
 165 \&...
 166 
 167 pool_conf_t *conf;
 168 pool_t *pool;
 169 
 170 \&...
 171 
 172 if ((pool = pool_get_pool(conf, "foo")) == NULL) {
 173         (void) fprintf(stderr, "Cannot retrieve pool named
 174         'foo'\\B{}n");
 175         ...
 176 }
 177 .fi
 178 .in -2
 179 
 180 .SH ATTRIBUTES
 181 .sp
 182 .LP
 183 See \fBattributes\fR(5) for descriptions of the following attributes:
 184 .sp
 185 
 186 .sp
 187 .TS
 188 box;
 189 c | c
 190 l | l .
 191 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 192 _
 193 CSI     Enabled
 194 _
 195 Interface Stability     Unstable
 196 _
 197 MT-Level        Safe
 198 .TE
 199 
 200 .SH SEE ALSO
 201 .sp
 202 .LP
 203 \fBlibpool\fR(3LIB), \fBpool_error\fR(3POOL), \fBattributes\fR(5)