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