YAZ 5.35.1
diag_map.c
Go to the documentation of this file.
1/* This file is part of the YAZ toolkit.
2 * Copyright (C) Index Data
3 * See the file LICENSE for details.
4 */
9#if HAVE_CONFIG_H
10#include <config.h>
11#endif
12
13#include <stdlib.h>
14#include <assert.h>
15#include <yaz/srw.h>
16
17/* bib1:srw */
18static int bib1_srw_map[] = {
19 1, 1,
20 2, 2,
21 3, 48,
22 4, 35,
23 5, 12,
24 6, 38,
25 7, 30,
26 8, 32,
27 9, 29,
28 10, 10,
29 11, 12,
30 11, 23,
31 12, 60,
32 13, 61,
33 13, 62,
34 14, 63,
35 14, 64,
36 14, 65,
37 15, 68,
38 15, 69,
39 16, 70,
40 17, 70,
41 18, 50,
42 19, 55,
43 20, 56,
44 21, 52,
45 22, 50,
46 23, 3,
47 24, 66,
48 25, 66,
49 26, 66,
50 27, 51,
51 28, 52,
52 29, 52,
53 30, 51,
54 31, 57,
55 32, 58,
56 33, 59,
57 100, 1, /* bad map */
58 101, 3,
59 102, 3,
60 103, 3,
61 104, 3,
62 105, 3,
63 106, 66,
64 107, 11,
65 108, 10,
66 108, 13,
67 108, 14,
68 108, 25,
69 108, 26,
70 108, 27,
71 108, 45,
72
73 109, 235,
74 110, 37,
75 111, 1,
76 112, 58,
77 113, 10,
78 114, 16,
79 115, 16,
80 116, 16,
81 117, 19,
82 117, 20,
83 118, 22,
84 119, 32,
85 119, 31,
86 120, 28,
87 121, 15,
88 122, 32,
89 123, 22,
90 123, 17,
91 123, 18,
92 124, 24,
93 125, 36,
94 126, 36,
95 127, 36,
96 128, 51,
97 129, 39,
98 130, 43,
99 131, 40,
100 132, 42,
101 201, 44,
102 201, 33,
103 201, 34,
104 202, 41,
105 203, 43,
106 205, 1, /* bad map */
107 206, 1, /* bad map */
108 207, 89,
109 208, 1, /* bad map */
110 209, 80,
111 210, 80,
112 210, 81,
113 211, 84,
114 212, 85,
115 213, 92,
116 214, 90,
117 215, 91,
118 216, 92,
119 217, 63,
120 218, 1, /* bad map */
121 219, 1, /* bad map */
122 220, 1, /* bad map */
123 221, 1, /* bad map */
124 222, 3,
125 223, 1, /* bad map */
126 224, 1, /* bad map */
127 225, 1, /* bad map */
128 226, 1, /* bad map */
129 227, 66,
130 228, 1, /* bad map */
131 229, 36,
132 230, 83,
133 231, 89,
134 232, 1,
135 233, 1, /* bad map */
136 234, 1, /* bad map */
137 235, 235,
138 236, 236,
139 237, 82,
140 238, 67,
141 239, 66,
142 240, 1, /* bad map */
143 241, 1, /* bad map */
144 242, 70,
145 243, 1, /* bad map */
146 244, 66,
147 245, 10,
148 246, 10,
149 247, 10,
150 1001, 1, /* bad map */
151 1002, 1, /* bad map */
152 1003, 1, /* bad map */
153 1004, 1, /* bad map */
154 1005, 1, /* bad map */
155 1006, 1, /* bad map */
156 1007, 100,
157 1008, 1,
158 1009, 1,
159 1010, 3,
160 1011, 3,
161 1012, 3,
162 1013, 3,
163 1014, 3,
164 1015, 1015,
165 1015, 3,
166 1016, 3,
167 1017, 3,
168 1018, 2,
169 1019, 2,
170 1020, 2,
171 1021, 3,
172 1022, 3,
173 1023, 3,
174 1024, 16,
175 1025, 3,
176 1026, 64,
177 1027, 1,
178 1028, 65,
179 1029, 1,
180 1040, 1,
181 /* 1041-1065 */
182 1066, 66,
183 1066, 67,
184 1073, 16,
185 1074, 1074,
186 0
187};
188
189/*
190 * This array contains overrides for when the first occurrence of a
191 * particular SRW error in the array above does not correspond with
192 * the best back-translation of that SRW error.
193 */
194static int srw_bib1_map[] = {
195 10, 108,
196 66, 238,
197 235, 235,
198 /* No doubt there are many more */
199 0
200};
201
202
204{
205 const int *p = bib1_srw_map;
206 while (*p)
207 {
208 if (code == p[0])
209 return p[1];
210 p += 2;
211 }
212 return 1;
213}
214
216{
217 /* Check explicit reverse-map first */
218 const int *p = srw_bib1_map;
219 while (*p)
220 {
221 if (code == p[0])
222 return p[1];
223 p += 2;
224 }
225
226 /* Fall back on reverse lookup in main map */
227 p = bib1_srw_map;
228 while (*p)
229 {
230 if (code == p[1])
231 return p[0];
232 p += 2;
233 }
234 return 1;
235}
236
237/*
238 * Local variables:
239 * c-basic-offset: 4
240 * c-file-style: "Stroustrup"
241 * indent-tabs-mode: nil
242 * End:
243 * vim: shiftwidth=4 tabstop=8 expandtab
244 */
245
static int srw_bib1_map[]
Definition diag_map.c:194
int yaz_diag_bib1_to_srw(int code)
Definition diag_map.c:203
static int bib1_srw_map[]
Definition diag_map.c:18
int yaz_diag_srw_to_bib1(int code)
Definition diag_map.c:215
Header for SRW/SRU.