New OID database - with public definitions in oid_db.h. Removed old OID
[yaz-moved-to-github.git] / include / yaz / oid_db.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: oid_db.h,v 1.1 2007-04-12 13:52:57 adam Exp $ */
28
29 /**
30  * \file oid_db.h
31  * \brief Header for OID database
32  */
33 #ifndef OID_DB_H
34 #define OID_DB_H
35
36 #include <yaz/yconfig.h>
37 #include <yaz/oid_util.h>
38 #include <yaz/odr.h>
39
40 YAZ_BEGIN_CDECL
41
42 /** \brief OID database */
43 typedef struct yaz_oid_entry *yaz_oid_db_t;
44
45 /** \brief returns standard OID database 
46     \retval OID database handle
47 */
48 YAZ_EXPORT
49 yaz_oid_db_t yaz_oid_std(void);
50
51 /** \brief maps named OID string to raw OID by database lookup
52     \param oid_db OID database
53     \param oclass class of string (enum oid_class) 
54     \param name OID name
55     \returns raw OID or NULL if name is unknown (bad)
56
57     This function only maps known names in the database provided.
58     Use yaz_string_to_oid_nmem or yaz_string_to_oid_odr to map
59     any named OID in dot-notation (1.2.8).
60 */
61 YAZ_EXPORT
62 const int *yaz_string_to_oid(yaz_oid_db_t oid_db,
63                              int oclass, const char *name);
64
65
66 /** \brief creates NMEM malloc'ed OID from string
67     \param oid_db OID database
68     \param oclass class of string (enum oid_class) 
69     \param name OID name
70     \param nmem memory for returned OID
71     \returns raw OID or NULL if name is unknown (bad)
72 */
73 YAZ_EXPORT
74 int *yaz_string_to_oid_nmem(yaz_oid_db_t oid_db,
75                             int oclass, const char *name, NMEM nmem);
76
77 /** \brief creates ODR malloc'ed OID from string
78     \param oid_db OID database
79     \param oclass class of string (enum oid_class) 
80     \param name OID name
81     \param odr memory for returned OID
82     \returns raw OID or NULL if name is unknown (bad)
83 */
84 YAZ_EXPORT
85 int *yaz_string_to_oid_odr(yaz_oid_db_t oid_db,
86                            int oclass, const char *name, ODR odr);
87
88 /** \brief maps raw OID to string
89     \param oid_db OID database
90     \param oid raw OID
91     \param oclass holds OID class if found (output parameter)
92     \returns OID name or NULL if not found in database
93 */
94 YAZ_EXPORT
95 const char *yaz_oid_to_string(yaz_oid_db_t oid_db,
96                               const int *oid, int *oclass);
97
98
99 /** \brief maps any OID to string (named or dot-notation)
100     \param oid raw OID
101     \param oclass holds OID class if found (output parameter)
102     \param buf string buffer for result (must be of size OID_STR_MAX)
103     \returns OID string (named or dot notatition) 
104 */
105 YAZ_EXPORT
106 const char *yaz_oid_to_string_buf(const int *oid, int *oclass, char *buf);
107
108 /** \brief traverses OIDs in a database
109     \param oid_db OID database
110     \param func function to be called for each OID
111     \param client_data data to be passed to func (custom defined)
112 */
113 YAZ_EXPORT void yaz_oid_trav(yaz_oid_db_t oid_db,
114                              void (*func)(const int *oid,
115                                           int oclass, const char *name,
116                                           void *client_data),
117                              void *client_data);
118
119 /** \brief checks if OID refers to MARC transfer syntax
120     \param oid raw OID
121     \retval 1 OID is a MARC type
122     \retval 0 OID is not a MARC type
123 */
124 YAZ_EXPORT
125 int yaz_oid_is_iso2709(const int *oid);
126
127 #define OID_STR_BIB1 "Bib-1"
128 #define OID_STR_DIAG1 "Diag-1"
129 #define OID_STR_USMARC "USmarc"
130 #define OID_STR_XML "XML"
131 #define OID_STR_SOIF "SOIF"
132 #define OID_STR_APPLICATION_XML "application-XML"
133 #define OID_STR_HTML "html"
134 #define OID_STR_GRS1 "GRS-1"
135 #define OID_STR_POSTSCRIPT "postscript"
136 #define OID_STR_SUTRS "SUTRS"
137 #define OID_STR_OPAC "OPAC"
138 #define OID_STR_EXPLAIN "Explain"
139 #define OID_STR_SUMMARY "Summary"
140 #define OID_STR_EXTENDED "Extended"
141 #define OID_STR_COOKIE "Cookie" 
142 #define OID_STR_PROXY "Proxy" 
143 #define OID_STR_CLIENT_IP "Client-IP"
144 #define OID_STR_ILL_1 "ISOILL-1"
145 #define OID_STR_ADMIN "Admin"
146 #define OID_STR_XMLES "XML-ES"
147 #define OID_STR_EXT_UPDATE "DB. Update"
148 #define OID_STR_ITEMORDER "Item order"
149 #define OID_STR_USERINFO_1 "UserInfo-1"
150 #define OID_STR_ID_CHARSET "ID-Charset"
151 #define OID_STR_CHARNEG_3 "CharSetandLanguageNegotiation-3"
152 #define OID_STR_CHARNEG_4 "CharSetandLanguageNegotiation-4"
153
154 YAZ_END_CDECL
155
156 #endif
157 /*
158  * Local variables:
159  * c-basic-offset: 4
160  * indent-tabs-mode: nil
161  * End:
162  * vim: shiftwidth=4 tabstop=8 expandtab
163  */
164