For OIDs use Odr_oid type everywhere, i.e. do not assume Odr_oid=int.
[yaz-moved-to-github.git] / include / yaz / retrieval.h
1 /*
2  * Copyright (c) 1995-2007, Index Data
3  * All rights reserved.
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  *     * Redistributions of source code must retain the above copyright
8  *       notice, this list of conditions and the following disclaimer.
9  *     * Redistributions in binary form must reproduce the above copyright
10  *       notice, this list of conditions and the following disclaimer in the
11  *       documentation and/or other materials provided with the distribution.
12  *     * Neither the name of Index Data nor the names of its contributors
13  *       may be used to endorse or promote products derived from this
14  *       software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 /* $Id: retrieval.h,v 1.10 2007-05-08 08:22:35 adam Exp $ */
28
29 /**
30  * \file retrieval.h
31  * \brief Retrieval Utility
32  */
33
34 #ifndef YAZ_RETRIEVAL_H
35 #define YAZ_RETRIEVAL_H
36
37 #include <stddef.h>
38 #include <yaz/wrbuf.h>
39 #include <yaz/yconfig.h>
40 #include <yaz/oid_util.h>
41 #include <yaz/record_conv.h>
42
43 YAZ_BEGIN_CDECL
44
45 /** retrieval handle  */
46 typedef struct yaz_retrieval_struct *yaz_retrieval_t;
47
48 /** creates retrieval handle
49     \return retrieval handle
50 */
51 YAZ_EXPORT yaz_retrieval_t yaz_retrieval_create(void);
52
53 /** destroys retrieval handle
54     \param p retrieval handle
55 */
56 YAZ_EXPORT void yaz_retrieval_destroy(yaz_retrieval_t p);
57
58 /** configures retrieval
59     \param p retrieval handle
60     \param node xmlNode pointer (root element of XML config)
61     \retval 0 success
62     \retval -1 failure
63
64     On failure, use yaz_retrieval_get_error to get error string.
65     
66     For retrieval:
67     \verbatim
68      <retrievalinfo>
69        <retrieval syntax="usmarc" name="F"/>
70        <retrieval syntax="usmarc" name="B"/>
71        <retrieval syntax="xml" name="marcxml"
72                   identifier="info:srw/schema/1/marcxml-v1.1">
73          <backend syntax="usmarc" name="F">
74            <marc inputformat="marc" outputformat="marcxml"
75                  inputcharset="marc-8"/>
76          </backend>
77        </retrieval>
78        <retrieval syntax="xml" name="dc">
79          <backend syntax="usmarc" name="F">
80            <marc inputformat="marc" outputformat="marcxml"
81                  inputcharset="marc-8"/>
82            <xslt stylesheet="MARC21slim2DC.xsl"/>
83          </backend>
84        </retrieval>
85      </retrievalinfo>
86     \endverbatim
87 */
88 YAZ_EXPORT
89 int yaz_retrieval_configure(yaz_retrieval_t p, const xmlNode *node);
90
91
92 /** performs retrieval request based on schema and format
93     \param p retrieval handle
94     \param schema record schema (SRU) / element set name (Z39.50)
95     \param syntax record syntax (format)
96     \param match_schema matched schema (if conversion was successful)
97     \param match_syntax matced syntax OID  if conversion was successful)
98     \param rc record conversion reference (if conversion was successful)
99     \param backend_schema backend scchema (if conversion was successful)
100     \param backend_syntax backend syntax (if conversion was successful)
101     \retval 0 success, schema and syntax matches
102     \retval -1 failure, use yaz_retrieval_get_error() for reason
103     \retval 1 schema does not match
104     \retval 2 syntax does not match
105     \retval 3 both match but not together
106 */
107 YAZ_EXPORT
108 int yaz_retrieval_request(yaz_retrieval_t p,
109                           const char *schema, Odr_oid *syntax,
110                           const char **match_schema, Odr_oid **match_syntax,
111                           yaz_record_conv_t *rc,
112                           const char **backend_schema,
113                           Odr_oid **backend_syntax);
114
115 /** returns error string (for last error)
116     \param p record conversion handle
117     \return error string
118 */    
119 YAZ_EXPORT
120 const char *yaz_retrieval_get_error(yaz_retrieval_t p);
121
122
123 /** set path for opening stylesheets etc.
124     \param p record conversion handle
125     \param path file path (UNIX style with : / Windows with ;)
126 */    
127 YAZ_EXPORT
128 void yaz_retrieval_set_path(yaz_retrieval_t p, const char *path);
129
130 YAZ_END_CDECL
131
132 #endif
133 /*
134  * Local variables:
135  * c-basic-offset: 4
136  * indent-tabs-mode: nil
137  * End:
138  * vim: shiftwidth=4 tabstop=8 expandtab
139  */
140