Exceptions
5 days ago
apache.php
5 days ago
apcu.php
5 days ago
array.php
5 days ago
bzip2.php
5 days ago
calendar.php
5 days ago
classobj.php
5 days ago
com.php
5 days ago
cubrid.php
5 days ago
curl.php
5 days ago
datetime.php
5 days ago
dir.php
5 days ago
eio.php
5 days ago
errorfunc.php
5 days ago
exec.php
5 days ago
fileinfo.php
5 days ago
filesystem.php
5 days ago
filter.php
5 days ago
fpm.php
5 days ago
ftp.php
5 days ago
funchand.php
5 days ago
functionsList.php
5 days ago
gmp.php
5 days ago
gnupg.php
5 days ago
hash.php
5 days ago
ibase.php
5 days ago
ibmDb2.php
5 days ago
iconv.php
5 days ago
image.php
5 days ago
imap.php
5 days ago
info.php
5 days ago
ingres-ii.php
5 days ago
inotify.php
5 days ago
json.php
5 days ago
ldap.php
5 days ago
libxml.php
5 days ago
lzf.php
5 days ago
mailparse.php
5 days ago
mbstring.php
5 days ago
misc.php
5 days ago
msql.php
5 days ago
mysql.php
5 days ago
mysqli.php
5 days ago
mysqlndMs.php
5 days ago
mysqlndQc.php
5 days ago
network.php
5 days ago
oci8.php
5 days ago
opcache.php
5 days ago
openssl.php
5 days ago
outcontrol.php
5 days ago
password.php
5 days ago
pcntl.php
5 days ago
pcre.php
5 days ago
pdf.php
5 days ago
pgsql.php
5 days ago
posix.php
5 days ago
ps.php
5 days ago
pspell.php
5 days ago
readline.php
5 days ago
rpminfo.php
5 days ago
rrd.php
5 days ago
sem.php
5 days ago
session.php
5 days ago
shmop.php
5 days ago
simplexml.php
5 days ago
sockets.php
5 days ago
sodium.php
5 days ago
solr.php
5 days ago
spl.php
5 days ago
sqlsrv.php
5 days ago
ssdeep.php
5 days ago
ssh2.php
5 days ago
stream.php
5 days ago
strings.php
5 days ago
swoole.php
5 days ago
uodbc.php
5 days ago
uopz.php
5 days ago
url.php
5 days ago
var.php
5 days ago
xdiff.php
5 days ago
xml.php
5 days ago
xmlrpc.php
5 days ago
yaml.php
5 days ago
yaz.php
5 days ago
zip.php
5 days ago
zlib.php
5 days ago
yaz.php
424 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ProfilePressVendor\Safe; |
| 4 | |
| 5 | use ProfilePressVendor\Safe\Exceptions\YazException; |
| 6 | /** |
| 7 | * This function invokes a CCL parser. It converts a given CCL FIND query to |
| 8 | * an RPN query which may be passed to the yaz_search |
| 9 | * function to perform a search. |
| 10 | * |
| 11 | * To define a set of valid CCL fields call yaz_ccl_conf |
| 12 | * prior to this function. |
| 13 | * |
| 14 | * @param resource $id The connection resource returned by yaz_connect. |
| 15 | * @param string $query The CCL FIND query. |
| 16 | * @param array|null $result If the function was executed successfully, this will be an array |
| 17 | * containing the valid RPN query under the key rpn. |
| 18 | * |
| 19 | * Upon failure, three indexes are set in this array to indicate the cause |
| 20 | * of failure: |
| 21 | * |
| 22 | * |
| 23 | * |
| 24 | * errorcode - the CCL error code (integer) |
| 25 | * |
| 26 | * |
| 27 | * |
| 28 | * |
| 29 | * errorstring - the CCL error string |
| 30 | * |
| 31 | * |
| 32 | * |
| 33 | * |
| 34 | * errorpos - approximate position in query of failure |
| 35 | * (integer is character position) |
| 36 | * |
| 37 | * |
| 38 | * |
| 39 | * |
| 40 | * errorcode - the CCL error code (integer) |
| 41 | * |
| 42 | * errorstring - the CCL error string |
| 43 | * |
| 44 | * errorpos - approximate position in query of failure |
| 45 | * (integer is character position) |
| 46 | * @throws YazException |
| 47 | * |
| 48 | */ |
| 49 | function yaz_ccl_parse($id, string $query, ?array &$result): void |
| 50 | { |
| 51 | error_clear_last(); |
| 52 | $result = \yaz_ccl_parse($id, $query, $result); |
| 53 | if ($result === \false) { |
| 54 | throw YazException::createFromPhpError(); |
| 55 | } |
| 56 | } |
| 57 | /** |
| 58 | * Closes the connection given by parameter id. |
| 59 | * |
| 60 | * @param resource $id The connection resource returned by yaz_connect. |
| 61 | * @throws YazException |
| 62 | * |
| 63 | */ |
| 64 | function yaz_close($id): void |
| 65 | { |
| 66 | error_clear_last(); |
| 67 | $result = \yaz_close($id); |
| 68 | if ($result === \false) { |
| 69 | throw YazException::createFromPhpError(); |
| 70 | } |
| 71 | } |
| 72 | /** |
| 73 | * This function returns a connection resource on success, zero on |
| 74 | * failure. |
| 75 | * |
| 76 | * yaz_connect prepares for a connection to a |
| 77 | * Z39.50 server. |
| 78 | * This function is non-blocking and does not attempt to establish |
| 79 | * a connection - it merely prepares a connect to be performed later when |
| 80 | * yaz_wait is called. |
| 81 | * |
| 82 | * @param string $zurl A string that takes the form host[:port][/database]. |
| 83 | * If port is omitted, port 210 is used. If database is omitted |
| 84 | * Default is used. |
| 85 | * @param mixed $options If given as a string, it is treated as the Z39.50 V2 authentication |
| 86 | * string (OpenAuth). |
| 87 | * |
| 88 | * If given as an array, the contents of the array serves as options. |
| 89 | * |
| 90 | * |
| 91 | * user |
| 92 | * |
| 93 | * |
| 94 | * Username for authentication. |
| 95 | * |
| 96 | * |
| 97 | * |
| 98 | * |
| 99 | * group |
| 100 | * |
| 101 | * |
| 102 | * Group for authentication. |
| 103 | * |
| 104 | * |
| 105 | * |
| 106 | * |
| 107 | * password |
| 108 | * |
| 109 | * |
| 110 | * Password for authentication. |
| 111 | * |
| 112 | * |
| 113 | * |
| 114 | * |
| 115 | * cookie |
| 116 | * |
| 117 | * |
| 118 | * Cookie for session (YAZ proxy). |
| 119 | * |
| 120 | * |
| 121 | * |
| 122 | * |
| 123 | * proxy |
| 124 | * |
| 125 | * |
| 126 | * Proxy for connection (YAZ proxy). |
| 127 | * |
| 128 | * |
| 129 | * |
| 130 | * |
| 131 | * persistent |
| 132 | * |
| 133 | * |
| 134 | * A boolean. If TRUE the connection is persistent; If FALSE the |
| 135 | * connection is not persistent. By default connections are persistent. |
| 136 | * |
| 137 | * |
| 138 | * |
| 139 | * If you open a persistent connection, you won't be able to close |
| 140 | * it later with yaz_close. |
| 141 | * |
| 142 | * |
| 143 | * |
| 144 | * |
| 145 | * |
| 146 | * piggyback |
| 147 | * |
| 148 | * |
| 149 | * A boolean. If TRUE piggyback is enabled for searches; If FALSE |
| 150 | * piggyback is disabled. By default piggyback is enabled. |
| 151 | * |
| 152 | * |
| 153 | * Enabling piggyback is more efficient and usually saves a |
| 154 | * network-round-trip for first time fetches of records. However, a |
| 155 | * few Z39.50 servers do not support piggyback or they ignore element |
| 156 | * set names. For those, piggyback should be disabled. |
| 157 | * |
| 158 | * |
| 159 | * |
| 160 | * |
| 161 | * charset |
| 162 | * |
| 163 | * |
| 164 | * A string that specifies character set to be used in Z39.50 |
| 165 | * language and character set negotiation. Use strings such as: |
| 166 | * ISO-8859-1, UTF-8, |
| 167 | * UTF-16. |
| 168 | * |
| 169 | * |
| 170 | * Most Z39.50 servers do not support this feature (and thus, this is |
| 171 | * ignored). Many servers use the ISO-8859-1 encoding for queries and |
| 172 | * messages. MARC21/USMARC records are not affected by this setting. |
| 173 | * |
| 174 | * |
| 175 | * |
| 176 | * |
| 177 | * |
| 178 | * preferredMessageSize |
| 179 | * |
| 180 | * |
| 181 | * An integer that specifies the maximum byte size of all records |
| 182 | * to be returned by a target during retrieval. See the |
| 183 | * Z39.50 standard for more |
| 184 | * information. |
| 185 | * |
| 186 | * |
| 187 | * |
| 188 | * This option is supported in PECL YAZ 1.0.5 or later. |
| 189 | * |
| 190 | * |
| 191 | * |
| 192 | * |
| 193 | * |
| 194 | * |
| 195 | * maximumRecordSize |
| 196 | * |
| 197 | * |
| 198 | * An integer that specifies the maximum byte size of a single record |
| 199 | * to be returned by a target during retrieval. This |
| 200 | * entity is referred to as Exceptional-record-size in the |
| 201 | * Z39.50 standard. |
| 202 | * |
| 203 | * |
| 204 | * |
| 205 | * This option is supported in PECL YAZ 1.0.5 or later. |
| 206 | * |
| 207 | * |
| 208 | * |
| 209 | * |
| 210 | * |
| 211 | * |
| 212 | * |
| 213 | * Username for authentication. |
| 214 | * |
| 215 | * Group for authentication. |
| 216 | * |
| 217 | * Password for authentication. |
| 218 | * |
| 219 | * Cookie for session (YAZ proxy). |
| 220 | * |
| 221 | * Proxy for connection (YAZ proxy). |
| 222 | * |
| 223 | * A boolean. If TRUE the connection is persistent; If FALSE the |
| 224 | * connection is not persistent. By default connections are persistent. |
| 225 | * |
| 226 | * If you open a persistent connection, you won't be able to close |
| 227 | * it later with yaz_close. |
| 228 | * |
| 229 | * A boolean. If TRUE piggyback is enabled for searches; If FALSE |
| 230 | * piggyback is disabled. By default piggyback is enabled. |
| 231 | * |
| 232 | * Enabling piggyback is more efficient and usually saves a |
| 233 | * network-round-trip for first time fetches of records. However, a |
| 234 | * few Z39.50 servers do not support piggyback or they ignore element |
| 235 | * set names. For those, piggyback should be disabled. |
| 236 | * |
| 237 | * A string that specifies character set to be used in Z39.50 |
| 238 | * language and character set negotiation. Use strings such as: |
| 239 | * ISO-8859-1, UTF-8, |
| 240 | * UTF-16. |
| 241 | * |
| 242 | * Most Z39.50 servers do not support this feature (and thus, this is |
| 243 | * ignored). Many servers use the ISO-8859-1 encoding for queries and |
| 244 | * messages. MARC21/USMARC records are not affected by this setting. |
| 245 | * |
| 246 | * An integer that specifies the maximum byte size of all records |
| 247 | * to be returned by a target during retrieval. See the |
| 248 | * Z39.50 standard for more |
| 249 | * information. |
| 250 | * |
| 251 | * This option is supported in PECL YAZ 1.0.5 or later. |
| 252 | * |
| 253 | * An integer that specifies the maximum byte size of a single record |
| 254 | * to be returned by a target during retrieval. This |
| 255 | * entity is referred to as Exceptional-record-size in the |
| 256 | * Z39.50 standard. |
| 257 | * |
| 258 | * This option is supported in PECL YAZ 1.0.5 or later. |
| 259 | * @return mixed A connection resource on success, FALSE on error. |
| 260 | * @throws YazException |
| 261 | * |
| 262 | */ |
| 263 | function yaz_connect(string $zurl, $options = null) |
| 264 | { |
| 265 | error_clear_last(); |
| 266 | if ($options !== null) { |
| 267 | $result = \yaz_connect($zurl, $options); |
| 268 | } else { |
| 269 | $result = \yaz_connect($zurl); |
| 270 | } |
| 271 | if ($result === \false) { |
| 272 | throw YazException::createFromPhpError(); |
| 273 | } |
| 274 | return $result; |
| 275 | } |
| 276 | /** |
| 277 | * This function allows you to change databases within a session by |
| 278 | * specifying one or more databases to be used in search, retrieval, etc. |
| 279 | * - overriding databases specified in call to |
| 280 | * yaz_connect. |
| 281 | * |
| 282 | * @param resource $id The connection resource returned by yaz_connect. |
| 283 | * @param string $databases A string containing one or more databases. Multiple databases are |
| 284 | * separated by a plus sign +. |
| 285 | * @throws YazException |
| 286 | * |
| 287 | */ |
| 288 | function yaz_database($id, string $databases): void |
| 289 | { |
| 290 | error_clear_last(); |
| 291 | $result = \yaz_database($id, $databases); |
| 292 | if ($result === \false) { |
| 293 | throw YazException::createFromPhpError(); |
| 294 | } |
| 295 | } |
| 296 | /** |
| 297 | * This function sets the element set name for retrieval. |
| 298 | * |
| 299 | * Call this function before yaz_search or |
| 300 | * yaz_present to specify the element set name for |
| 301 | * records to be retrieved. |
| 302 | * |
| 303 | * @param resource $id The connection resource returned by yaz_connect. |
| 304 | * @param string $elementset Most servers support F (for full records) and |
| 305 | * B (for brief records). |
| 306 | * @throws YazException |
| 307 | * |
| 308 | */ |
| 309 | function yaz_element($id, string $elementset): void |
| 310 | { |
| 311 | error_clear_last(); |
| 312 | $result = \yaz_element($id, $elementset); |
| 313 | if ($result === \false) { |
| 314 | throw YazException::createFromPhpError(); |
| 315 | } |
| 316 | } |
| 317 | /** |
| 318 | * This function prepares for retrieval of records after a successful search. |
| 319 | * |
| 320 | * The yaz_range function should be called prior to this |
| 321 | * function to specify the range of records to be retrieved. |
| 322 | * |
| 323 | * @param resource $id The connection resource returned by yaz_connect. |
| 324 | * @throws YazException |
| 325 | * |
| 326 | */ |
| 327 | function yaz_present($id): void |
| 328 | { |
| 329 | error_clear_last(); |
| 330 | $result = \yaz_present($id); |
| 331 | if ($result === \false) { |
| 332 | throw YazException::createFromPhpError(); |
| 333 | } |
| 334 | } |
| 335 | /** |
| 336 | * yaz_search prepares for a search on the given |
| 337 | * connection. |
| 338 | * |
| 339 | * Like yaz_connect this function is non-blocking and |
| 340 | * only prepares for a search to be executed later when |
| 341 | * yaz_wait is called. |
| 342 | * |
| 343 | * @param resource $id The connection resource returned by yaz_connect. |
| 344 | * @param string $type This parameter represents the query type - only "rpn" |
| 345 | * is supported now in which case the third argument specifies a Type-1 |
| 346 | * query in prefix query notation. |
| 347 | * @param string $query The RPN query is a textual representation of the Type-1 query as |
| 348 | * defined by the Z39.50 standard. However, in the text representation |
| 349 | * as used by YAZ a prefix notation is used, that is the operator |
| 350 | * precedes the operands. The query string is a sequence of tokens where |
| 351 | * white space is ignored unless surrounded by double quotes. Tokens beginning |
| 352 | * with an at-character (@) are considered operators, |
| 353 | * otherwise they are treated as search terms. |
| 354 | * |
| 355 | * You can find information about attributes at the |
| 356 | * Z39.50 Maintenance Agency |
| 357 | * site. |
| 358 | * |
| 359 | * If you would like to use a more friendly notation, |
| 360 | * use the CCL parser - functions yaz_ccl_conf and |
| 361 | * yaz_ccl_parse. |
| 362 | * @throws YazException |
| 363 | * |
| 364 | */ |
| 365 | function yaz_search($id, string $type, string $query): void |
| 366 | { |
| 367 | error_clear_last(); |
| 368 | $result = \yaz_search($id, $type, $query); |
| 369 | if ($result === \false) { |
| 370 | throw YazException::createFromPhpError(); |
| 371 | } |
| 372 | } |
| 373 | /** |
| 374 | * This function carries out networked (blocked) activity for outstanding |
| 375 | * requests which have been prepared by the functions |
| 376 | * yaz_connect, yaz_search, |
| 377 | * yaz_present, yaz_scan and |
| 378 | * yaz_itemorder. |
| 379 | * |
| 380 | * yaz_wait returns when all servers have either |
| 381 | * completed all requests or aborted (in case of errors). |
| 382 | * |
| 383 | * @param array $options An associative array of options: |
| 384 | * |
| 385 | * |
| 386 | * timeout |
| 387 | * |
| 388 | * |
| 389 | * Sets timeout in seconds. If a server has not responded within the |
| 390 | * timeout it is considered dead and yaz_wait |
| 391 | * returns. The default value for timeout is 15 seconds. |
| 392 | * |
| 393 | * |
| 394 | * |
| 395 | * |
| 396 | * event |
| 397 | * |
| 398 | * |
| 399 | * A boolean. |
| 400 | * |
| 401 | * |
| 402 | * |
| 403 | * |
| 404 | * |
| 405 | * Sets timeout in seconds. If a server has not responded within the |
| 406 | * timeout it is considered dead and yaz_wait |
| 407 | * returns. The default value for timeout is 15 seconds. |
| 408 | * |
| 409 | * A boolean. |
| 410 | * @return mixed Returns TRUE on success. |
| 411 | * In event mode, returns resource. |
| 412 | * @throws YazException |
| 413 | * |
| 414 | */ |
| 415 | function yaz_wait(array &$options = null) |
| 416 | { |
| 417 | error_clear_last(); |
| 418 | $result = \yaz_wait($options); |
| 419 | if ($result === \false) { |
| 420 | throw YazException::createFromPhpError(); |
| 421 | } |
| 422 | return $result; |
| 423 | } |
| 424 |