summaryrefslogtreecommitdiff
path: root/vendor/thecodingmachine/safe/generated/yaz.php
blob: 29c1d33c4021924935d4bb52e8b51ec248424bb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
<?php

namespace Safe;

use Safe\Exceptions\YazException;

/**
 * This function invokes a CCL parser. It converts a given CCL FIND query to
 * an RPN query which may be passed to the yaz_search
 * function to perform a search.
 *
 * To define a set of valid CCL fields call yaz_ccl_conf
 * prior to this function.
 *
 * @param resource $id The connection resource returned by yaz_connect.
 * @param string $query The CCL FIND query.
 * @param array|null $result If the function was executed successfully, this will be an array
 * containing the valid RPN query under the key rpn.
 *
 * Upon failure, three indexes are set in this array to indicate the cause
 * of failure:
 *
 *
 *
 * errorcode - the CCL error code (integer)
 *
 *
 *
 *
 * errorstring - the CCL error string
 *
 *
 *
 *
 * errorpos - approximate position in query of failure
 * (integer is character position)
 *
 *
 *
 *
 * errorcode - the CCL error code (integer)
 *
 * errorstring - the CCL error string
 *
 * errorpos - approximate position in query of failure
 * (integer is character position)
 * @throws YazException
 *
 */
function yaz_ccl_parse($id, string $query, ?array &$result): void
{
    error_clear_last();
    $result = \yaz_ccl_parse($id, $query, $result);
    if ($result === false) {
        throw YazException::createFromPhpError();
    }
}


/**
 * Closes the connection given by parameter id.
 *
 * @param resource $id The connection resource returned by yaz_connect.
 * @throws YazException
 *
 */
function yaz_close($id): void
{
    error_clear_last();
    $result = \yaz_close($id);
    if ($result === false) {
        throw YazException::createFromPhpError();
    }
}


/**
 * This function returns a connection resource on success, zero on
 * failure.
 *
 * yaz_connect prepares for a connection to a
 * Z39.50 server.
 * This function is non-blocking and does not attempt to establish
 * a connection  - it merely prepares a connect to be performed later when
 * yaz_wait is called.
 *
 * @param string $zurl A string that takes the form host[:port][/database].
 * If port is omitted, port 210 is used. If database is omitted
 * Default is used.
 * @param mixed $options If given as a string, it is treated as the Z39.50 V2 authentication
 * string (OpenAuth).
 *
 * If given as an array, the contents of the array serves as options.
 *
 *
 * user
 *
 *
 * Username for authentication.
 *
 *
 *
 *
 * group
 *
 *
 * Group for authentication.
 *
 *
 *
 *
 * password
 *
 *
 * Password for authentication.
 *
 *
 *
 *
 * cookie
 *
 *
 * Cookie for session (YAZ proxy).
 *
 *
 *
 *
 * proxy
 *
 *
 * Proxy for connection (YAZ proxy).
 *
 *
 *
 *
 * persistent
 *
 *
 * A boolean. If TRUE the connection is persistent; If FALSE the
 * connection is not persistent. By default connections are persistent.
 *
 *
 *
 * If you open a persistent connection, you won't be able to close
 * it later with yaz_close.
 *
 *
 *
 *
 *
 * piggyback
 *
 *
 * A boolean. If TRUE piggyback is enabled for searches; If FALSE
 * piggyback is disabled. By default piggyback is enabled.
 *
 *
 * Enabling piggyback is more efficient and usually saves a
 * network-round-trip for first time fetches of records. However, a
 * few Z39.50 servers do not support piggyback or they ignore element
 * set names. For those, piggyback should be disabled.
 *
 *
 *
 *
 * charset
 *
 *
 * A string that specifies character set to be used in Z39.50
 * language and character set negotiation. Use strings such as:
 * ISO-8859-1, UTF-8,
 * UTF-16.
 *
 *
 * Most Z39.50 servers do not support this feature (and thus, this is
 * ignored). Many servers use the ISO-8859-1 encoding for queries and
 * messages. MARC21/USMARC records are not affected by this setting.
 *
 *
 *
 *
 *
 * preferredMessageSize
 *
 *
 * An integer that specifies the maximum byte size of all records
 * to be returned by a target during retrieval. See the
 * Z39.50 standard for more
 * information.
 *
 *
 *
 * This option is supported in PECL YAZ 1.0.5 or later.
 *
 *
 *
 *
 *
 *
 * maximumRecordSize
 *
 *
 * An integer that specifies the maximum byte size of a single record
 * to be returned by a target during retrieval. This
 * entity is referred to as Exceptional-record-size in the
 * Z39.50 standard.
 *
 *
 *
 * This option is supported in PECL YAZ 1.0.5 or later.
 *
 *
 *
 *
 *
 *
 *
 * Username for authentication.
 *
 * Group for authentication.
 *
 * Password for authentication.
 *
 * Cookie for session (YAZ proxy).
 *
 * Proxy for connection (YAZ proxy).
 *
 * A boolean. If TRUE the connection is persistent; If FALSE the
 * connection is not persistent. By default connections are persistent.
 *
 * If you open a persistent connection, you won't be able to close
 * it later with yaz_close.
 *
 * A boolean. If TRUE piggyback is enabled for searches; If FALSE
 * piggyback is disabled. By default piggyback is enabled.
 *
 * Enabling piggyback is more efficient and usually saves a
 * network-round-trip for first time fetches of records. However, a
 * few Z39.50 servers do not support piggyback or they ignore element
 * set names. For those, piggyback should be disabled.
 *
 * A string that specifies character set to be used in Z39.50
 * language and character set negotiation. Use strings such as:
 * ISO-8859-1, UTF-8,
 * UTF-16.
 *
 * Most Z39.50 servers do not support this feature (and thus, this is
 * ignored). Many servers use the ISO-8859-1 encoding for queries and
 * messages. MARC21/USMARC records are not affected by this setting.
 *
 * An integer that specifies the maximum byte size of all records
 * to be returned by a target during retrieval. See the
 * Z39.50 standard for more
 * information.
 *
 * This option is supported in PECL YAZ 1.0.5 or later.
 *
 * An integer that specifies the maximum byte size of a single record
 * to be returned by a target during retrieval. This
 * entity is referred to as Exceptional-record-size in the
 * Z39.50 standard.
 *
 * This option is supported in PECL YAZ 1.0.5 or later.
 * @return mixed A connection resource on success, FALSE on error.
 * @throws YazException
 *
 */
function yaz_connect(string $zurl, $options = null)
{
    error_clear_last();
    if ($options !== null) {
        $result = \yaz_connect($zurl, $options);
    } else {
        $result = \yaz_connect($zurl);
    }
    if ($result === false) {
        throw YazException::createFromPhpError();
    }
    return $result;
}


/**
 * This function allows you to change databases within a session by
 * specifying one or more databases to be used in search, retrieval, etc.
 * - overriding databases specified in call to
 * yaz_connect.
 *
 * @param resource $id The connection resource returned by yaz_connect.
 * @param string $databases A string containing one or more databases. Multiple databases are
 * separated by a plus sign +.
 * @throws YazException
 *
 */
function yaz_database($id, string $databases): void
{
    error_clear_last();
    $result = \yaz_database($id, $databases);
    if ($result === false) {
        throw YazException::createFromPhpError();
    }
}


/**
 * This function sets the element set name for retrieval.
 *
 * Call this function before yaz_search or
 * yaz_present to specify the element set name for
 * records to be retrieved.
 *
 * @param resource $id The connection resource returned by yaz_connect.
 * @param string $elementset Most servers support F (for full records) and
 * B (for brief records).
 * @throws YazException
 *
 */
function yaz_element($id, string $elementset): void
{
    error_clear_last();
    $result = \yaz_element($id, $elementset);
    if ($result === false) {
        throw YazException::createFromPhpError();
    }
}


/**
 * This function prepares for retrieval of records after a successful search.
 *
 * The yaz_range function should be called prior to this
 * function to specify the range of records to be retrieved.
 *
 * @param resource $id The connection resource returned by yaz_connect.
 * @throws YazException
 *
 */
function yaz_present($id): void
{
    error_clear_last();
    $result = \yaz_present($id);
    if ($result === false) {
        throw YazException::createFromPhpError();
    }
}


/**
 * yaz_search prepares for a search on the given
 * connection.
 *
 * Like yaz_connect this function is non-blocking and
 * only prepares for a search to be executed later when
 * yaz_wait is called.
 *
 * @param resource $id The connection resource returned by yaz_connect.
 * @param string $type This parameter represents the query type - only "rpn"
 * is supported now in which case the third argument specifies a Type-1
 * query in prefix query notation.
 * @param string $query The RPN query is a textual representation of the Type-1 query as
 * defined by the Z39.50 standard. However, in the text representation
 * as used by YAZ a prefix notation is used, that is the operator
 * precedes the operands. The query string is a sequence of tokens where
 * white space is ignored unless surrounded by double quotes. Tokens beginning
 * with an at-character (@) are considered operators,
 * otherwise they are treated as search terms.
 *
 * You can find information about attributes at the
 * Z39.50 Maintenance Agency
 * site.
 *
 * If you would like to use a more friendly notation,
 * use the CCL parser - functions yaz_ccl_conf and
 * yaz_ccl_parse.
 * @throws YazException
 *
 */
function yaz_search($id, string $type, string $query): void
{
    error_clear_last();
    $result = \yaz_search($id, $type, $query);
    if ($result === false) {
        throw YazException::createFromPhpError();
    }
}


/**
 * This function carries out networked (blocked) activity for outstanding
 * requests which have been prepared by the functions
 * yaz_connect, yaz_search,
 * yaz_present, yaz_scan and
 * yaz_itemorder.
 *
 * yaz_wait returns when all servers have either
 * completed all requests or aborted (in case of errors).
 *
 * @param array $options An associative array of options:
 *
 *
 * timeout
 *
 *
 * Sets timeout in seconds. If a server has not responded within the
 * timeout it is considered dead and yaz_wait
 * returns. The default value for timeout is 15 seconds.
 *
 *
 *
 *
 * event
 *
 *
 * A boolean.
 *
 *
 *
 *
 *
 * Sets timeout in seconds. If a server has not responded within the
 * timeout it is considered dead and yaz_wait
 * returns. The default value for timeout is 15 seconds.
 *
 * A boolean.
 * @return mixed Returns TRUE on success.
 * In event mode, returns resource.
 * @throws YazException
 *
 */
function yaz_wait(array &$options = null)
{
    error_clear_last();
    $result = \yaz_wait($options);
    if ($result === false) {
        throw YazException::createFromPhpError();
    }
    return $result;
}