a0426e779e07bc5e02be0ee0165a45e47b951a78
[yaz-moved-to-github.git] / include / yaz / retrieval.h
1 /*
2  * Copyright (C) 2005-2006, Index Data ApS
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and
5  * its documentation, in whole or in part, for any purpose, is hereby granted,
6  * provided that:
7  *
8  * 1. This copyright and permission notice appear in all copies of the
9  * software and its documentation. Notices of copyright or attribution
10  * which appear at the beginning of any file must remain unchanged.
11  *
12  * 2. The name of Index Data or the individual authors may not be used to
13  * endorse or promote products derived from this software without specific
14  * prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
18  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
19  * IN NO EVENT SHALL INDEX DATA BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
20  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
21  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR
22  * NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
23  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24  * OF THIS SOFTWARE.
25  *
26  * $Id: retrieval.h,v 1.5 2006-05-09 13:39:46 adam Exp $
27  */
28 /**
29  * \file retrieval.h
30  * \brief Retrieval Utility
31  */
32
33 #ifndef YAZ_RETRIEVAL_H
34 #define YAZ_RETRIEVAL_H
35
36 #include <stddef.h>
37 #include <yaz/wrbuf.h>
38 #include <yaz/yconfig.h>
39
40 #include <yaz/record_conv.h>
41
42 YAZ_BEGIN_CDECL
43
44 /** retrieval handle  */
45 typedef struct yaz_retrieval_struct *yaz_retrieval_t;
46
47 /** creates retrieval handle
48     \return retrieval handle
49 */
50 YAZ_EXPORT yaz_retrieval_t yaz_retrieval_create(void);
51
52 /** destroys retrieval handle
53     \param p retrieval handle
54 */
55 YAZ_EXPORT void yaz_retrieval_destroy(yaz_retrieval_t p);
56
57 /** configures retrieval
58     \param p retrieval handle
59     \param node xmlNode pointer (root element of XML config)
60     \retval 0 success
61     \retval -1 failure
62
63     On failure, use yaz_retrieval_get_error to get error string.
64     
65     For retrieval:
66     \verbatim
67     <retrievalinfo>
68        <retrieval syntax="usmarc" name="marcxml"
69             identifier="info:srw/schema/1/marcxml-v1.1"
70             backendsyntax="xml" backendname="dc"
71        >
72          <title>MARCXML</title>
73          <convert>
74             <marc inputformat="marc" outputformat="marcxml"
75                          inputcharset="marc-8"/>
76             <xslt stylesheet="marcxml2mods.xsl"/>
77             <xslt stylesheet="mods2dc.xsl"/>
78          </convert>
79        </retrieval>
80     </retrievalinfo>
81     \endverbatim
82 */
83 YAZ_EXPORT
84 int yaz_retrieval_configure(yaz_retrieval_t p, const void *node);
85
86
87 /** performs retrieval request based on schema and format
88     \param p retrieval handle
89     \param schema record schema (SRU) / element set name (Z39.50)
90     \param syntax record syntax (format)
91     \param match_schema matched schema (if conversion was successful)
92     \param match_syntax matced syntax OID  if conversion was successful)
93     \param rc record conversion reference (if conversion was successful)
94     \param backend_schema backend scchema (if conversion was successful)
95     \param backend_syntax backend syntax (if conversion was successful)
96     \retval 0 success, schema and syntax matches
97     \retval -1 failure, use yaz_retrieval_get_error() for reason
98     \retval 1 schema does not match
99     \retval 2 syntax does not match
100     \retval 3 both match but not together
101 */
102 YAZ_EXPORT
103 int yaz_retrieval_request(yaz_retrieval_t p,
104                           const char *schema, int *syntax,
105                           const char **match_schema, int **match_syntax,
106                           yaz_record_conv_t *rc,
107                           const char **backend_schema,
108                           int **backend_syntax);
109
110 /** returns error string (for last error)
111     \param p record conversion handle
112     \return error string
113 */    
114 YAZ_EXPORT
115 const char *yaz_retrieval_get_error(yaz_retrieval_t p);
116
117
118 /** set path for opening stylesheets etc.
119     \param p record conversion handle
120     \param path file path (UNIX style with : / Windows with ;)
121 */    
122 YAZ_EXPORT
123 void yaz_retrieval_set_path(yaz_retrieval_t p, const char *path);
124
125 YAZ_END_CDECL
126
127 #endif
128 /*
129  * Local variables:
130  * c-basic-offset: 4
131  * indent-tabs-mode: nil
132  * End:
133  * vim: shiftwidth=4 tabstop=8 expandtab
134  */
135