1 | /* ------------------------------------------------------------------- */
|
---|
2 | /* isMARC : Convert a metatag struct to ISMARC */
|
---|
3 | /* (i.e. UKMARC as used in the National and University */
|
---|
4 | /* Library of Island). */
|
---|
5 | /* */
|
---|
6 | /* Specs : http://www.bibsys.no/meta/d2m/iscross.txt */
|
---|
7 | /* */
|
---|
8 | /* Author : Ole Husby */
|
---|
9 | /* Last update: 1998-09-30 */
|
---|
10 | /* ------------------------------------------------------------------- */
|
---|
11 |
|
---|
12 | #include <stdio.h>
|
---|
13 | #include <string.h>
|
---|
14 | #include "d2m.h"
|
---|
15 |
|
---|
16 |
|
---|
17 |
|
---|
18 |
|
---|
19 | /* ------------------------------------------------------------------- */
|
---|
20 | /* Splits Icelandig name without a comma */
|
---|
21 | /* ------------------------------------------------------------------- */
|
---|
22 |
|
---|
23 | int split_ice2(char *str)
|
---|
24 | {
|
---|
25 | char *q, *temp, *suba, *subi, *subb;
|
---|
26 |
|
---|
27 | if (!strstr(str, " "))
|
---|
28 | return 1;
|
---|
29 |
|
---|
30 | suba = (char *) malloc(strlen(str) + 50);
|
---|
31 | subi = (char *) malloc(strlen(str) + 50);
|
---|
32 | subb = (char *) malloc(strlen(str) + 50);
|
---|
33 | temp = (char *) malloc(strlen(str) + 50);
|
---|
34 |
|
---|
35 | *suba = *subi = *subb = *temp = 0;
|
---|
36 |
|
---|
37 | q = strtok(str, " ");
|
---|
38 | while (q)
|
---|
39 | {
|
---|
40 | while ( ( q[0] == ' ' ) && ( strlen(q) ) )
|
---|
41 | q++;
|
---|
42 |
|
---|
43 | while( ( q[strlen(q) - 1] == ' ' ) && ( strlen(q) ) )
|
---|
44 | q[strlen(q) - 1] = '\0';
|
---|
45 |
|
---|
46 | if (*q)
|
---|
47 | {
|
---|
48 | if (!*suba)
|
---|
49 | strcpy(suba, q);
|
---|
50 | else
|
---|
51 | {
|
---|
52 | if (*temp)
|
---|
53 | {
|
---|
54 | if (*subi)
|
---|
55 | strcat(subi, " ");
|
---|
56 | strcat(subi, temp);
|
---|
57 | }
|
---|
58 | strcpy(temp, q);
|
---|
59 | }
|
---|
60 | }
|
---|
61 | q = strtok(NULL, " ");
|
---|
62 | }
|
---|
63 |
|
---|
64 | *str = 0;
|
---|
65 |
|
---|
66 | if (*temp)
|
---|
67 | {
|
---|
68 | if (*subi)
|
---|
69 | strcpy(subb, temp);
|
---|
70 | else
|
---|
71 | strcpy(subi, temp);
|
---|
72 | }
|
---|
73 |
|
---|
74 | if (*suba)
|
---|
75 | {
|
---|
76 | strcpy(str, suba);
|
---|
77 | if (*subi)
|
---|
78 | {
|
---|
79 | strcat(str, " $i ");
|
---|
80 | strcat(str, subi);
|
---|
81 | }
|
---|
82 | if (*subb)
|
---|
83 | {
|
---|
84 | strcat(str, " $b ");
|
---|
85 | strcat(str, subb);
|
---|
86 | }
|
---|
87 | }
|
---|
88 |
|
---|
89 | free(suba);
|
---|
90 | free(subi);
|
---|
91 | free(subb);
|
---|
92 | free(temp);
|
---|
93 |
|
---|
94 | return 40;
|
---|
95 | }
|
---|
96 |
|
---|
97 |
|
---|
98 |
|
---|
99 |
|
---|
100 |
|
---|
101 | /* ------------------------------------------------------------------- */
|
---|
102 | /* Splits Icelandig name */
|
---|
103 | /* ------------------------------------------------------------------- */
|
---|
104 |
|
---|
105 | int split_icename(char *str, int i2)
|
---|
106 | {
|
---|
107 | char *p, *q, subtag[5];
|
---|
108 |
|
---|
109 | if (!strstr(str, ","))
|
---|
110 | {
|
---|
111 | if (i2)
|
---|
112 | return split_ice2(str);
|
---|
113 | else
|
---|
114 | return 1;
|
---|
115 | }
|
---|
116 |
|
---|
117 | p = (char *) malloc(strlen(str) + 50);
|
---|
118 | *p = 0;
|
---|
119 | *subtag = 0;
|
---|
120 |
|
---|
121 | q = strtok(str, ",");
|
---|
122 | if (q)
|
---|
123 | {
|
---|
124 | strcpy(p, q);
|
---|
125 | q = strtok(NULL, "\0");
|
---|
126 | if (q)
|
---|
127 | {
|
---|
128 | while ( ( q[0] == ' ' ) && ( strlen(q) ) )
|
---|
129 | q++;
|
---|
130 | strcat(p, " $h ");
|
---|
131 | strcat(p, q);
|
---|
132 | }
|
---|
133 | strcpy(str, p);
|
---|
134 | }
|
---|
135 |
|
---|
136 | free(p);
|
---|
137 |
|
---|
138 | return 10;
|
---|
139 | }
|
---|
140 |
|
---|
141 |
|
---|
142 | int isMARC(struct metatag *mt, struct marcrec *mr)
|
---|
143 | {
|
---|
144 | char pre[64], type_tag[4], creator_tag[4], title_tag[6];
|
---|
145 | int i, ind, ice2;
|
---|
146 |
|
---|
147 | *pre = 0;
|
---|
148 |
|
---|
149 | if (strcasecmp(mt->name, "title") == 0)
|
---|
150 | {
|
---|
151 | if ( (!*mt->type)
|
---|
152 | | (strcasecmp(mt->type, "main") == 0)
|
---|
153 | | (strcasecmp(mt->type, "long") == 0) )
|
---|
154 | {
|
---|
155 | if (mr->ntitles)
|
---|
156 | strcpy(title_tag, "24630");
|
---|
157 | else
|
---|
158 | strcpy(title_tag, "24510");
|
---|
159 |
|
---|
160 | mr->ntitles++;
|
---|
161 |
|
---|
162 | sprintf(pre, "%s$a", title_tag);
|
---|
163 | }
|
---|
164 | }
|
---|
165 |
|
---|
166 | else if (strcasecmp(mt->name, "creator") == 0)
|
---|
167 | {
|
---|
168 | if ( strcasecmp(mt->type, "personal") == 0)
|
---|
169 | {
|
---|
170 | if (!mr->ncreators)
|
---|
171 | strcpy(creator_tag, "100");
|
---|
172 | else
|
---|
173 | strcpy(creator_tag, "700");
|
---|
174 |
|
---|
175 | ice2 = 1;
|
---|
176 | ind = split_icename(mt->value, ice2);
|
---|
177 | sprintf(pre, "%s%2d$a", creator_tag, ind);
|
---|
178 | }
|
---|
179 | else if (strcasecmp(mt->type, "corporate") == 0)
|
---|
180 | {
|
---|
181 | if (!mr->ncreators)
|
---|
182 | strcpy(creator_tag, "110");
|
---|
183 | else
|
---|
184 | strcpy(creator_tag, "710");
|
---|
185 | sprintf(pre, "%s20$a", creator_tag);
|
---|
186 | }
|
---|
187 | else
|
---|
188 | {
|
---|
189 | ice2 = 0;
|
---|
190 | strcpy(pre, "720 $a");
|
---|
191 | ind = split_icename(mt->value, ice2);
|
---|
192 | }
|
---|
193 | mr->ncreators++;
|
---|
194 | }
|
---|
195 |
|
---|
196 | else if (strncasecmp(mt->name, "contributor", 11) == 0)
|
---|
197 | {
|
---|
198 | if ( strcasecmp(mt->type, "personal") == 0)
|
---|
199 | {
|
---|
200 | ice2 = 1;
|
---|
201 | ind = split_icename(mt->value, ice2);
|
---|
202 | sprintf(pre, "700%2d$a", ind);
|
---|
203 | }
|
---|
204 | else if (strcasecmp(mt->type, "corporate") == 0)
|
---|
205 | {
|
---|
206 | strcpy(pre, "71020$a");
|
---|
207 | }
|
---|
208 | else
|
---|
209 | {
|
---|
210 | ice2 = 0;
|
---|
211 | strcpy(pre, "720 $a");
|
---|
212 | ind = split_icename(mt->value, ice2);
|
---|
213 | }
|
---|
214 | mr->ncreators++;
|
---|
215 | }
|
---|
216 |
|
---|
217 |
|
---|
218 | else if (strcasecmp(mt->name, "publisher") == 0)
|
---|
219 | strcpy(pre, "260 $b");
|
---|
220 |
|
---|
221 | else if (strcasecmp(mt->name, "description") == 0)
|
---|
222 | strcpy(pre, "513 $a");
|
---|
223 |
|
---|
224 | else if (strcasecmp(mt->name, "coverage") == 0)
|
---|
225 | {
|
---|
226 | if (strcasecmp(mt->type , "spatial") == 0)
|
---|
227 | {
|
---|
228 | strcpy(pre, "651 $a");
|
---|
229 | split_subj(mt->value);
|
---|
230 | }
|
---|
231 | else
|
---|
232 | strcpy(pre, "500 $a");
|
---|
233 | }
|
---|
234 |
|
---|
235 | else if (strcasecmp(mt->name, "source") == 0)
|
---|
236 | strcpy(pre, "787 $a");
|
---|
237 |
|
---|
238 | else if (strcasecmp(mt->name, "rights") == 0)
|
---|
239 | {
|
---|
240 | if (strcasecmp(mt->scheme, "url") == 0)
|
---|
241 | strcpy(pre, "856 $3 rights $u");
|
---|
242 | else
|
---|
243 | strcpy(pre, "500 $a");
|
---|
244 | }
|
---|
245 |
|
---|
246 | else if (strcasecmp(mt->name, "identifier") == 0)
|
---|
247 | {
|
---|
248 | if (!*mt->scheme)
|
---|
249 | strcpy(mr->url, mt->value);
|
---|
250 | else if (strcasecmp(mt->scheme, "url") == 0)
|
---|
251 | strcpy(mr->url, mt->value);
|
---|
252 | else if (strcasecmp(mt->scheme, "urn") == 0)
|
---|
253 | strcpy(pre, "8567 $u urn:");
|
---|
254 | else if (strcasecmp(mt->scheme, "nbn") == 0)
|
---|
255 | strcpy(pre, "015 $a");
|
---|
256 | else if (strcasecmp(mt->scheme, "isbn") == 0)
|
---|
257 | strcpy(pre, "021 $a");
|
---|
258 | else if (strcasecmp(mt->scheme, "issn") == 0)
|
---|
259 | strcpy(pre, "022 $a");
|
---|
260 | else if (strcasecmp(mt->scheme, "isrc") == 0)
|
---|
261 | strcpy(pre, "024 $a");
|
---|
262 | else if (strcasecmp(mt->scheme, "ismn") == 0)
|
---|
263 | strcpy(pre, "025 $a");
|
---|
264 | else if (strcasecmp(mt->scheme, "isrn") == 0)
|
---|
265 | strcpy(pre, "027 $a");
|
---|
266 | }
|
---|
267 |
|
---|
268 | else if (strcasecmp(mt->name, "type") == 0)
|
---|
269 | strcpy(pre, "655 $a");
|
---|
270 |
|
---|
271 | else if (strcasecmp(mt->name, "relation") == 0)
|
---|
272 | strcpy(pre, "787 $a");
|
---|
273 |
|
---|
274 | else if (strcasecmp(mt->name, "language") == 0)
|
---|
275 | {
|
---|
276 | if (strcasecmp(mt->scheme, "z39.53") == 0)
|
---|
277 | {
|
---|
278 | strcpy(pre, "04109$a");
|
---|
279 | if (strlen(mt->value) == 3)
|
---|
280 | put008(mr->s008, mt->value, F008_LANGUAGE);
|
---|
281 | }
|
---|
282 | else if (strcasecmp(mt->scheme, "usmarc") == 0)
|
---|
283 | strcpy(pre, "04109$a");
|
---|
284 | else
|
---|
285 | strcpy(pre, "546 $a");
|
---|
286 | }
|
---|
287 |
|
---|
288 | else if (strcasecmp(mt->name, "format") == 0)
|
---|
289 | strcpy(mr->fmat, mt->value);
|
---|
290 |
|
---|
291 | else if (strcasecmp(mt->name, "subject") == 0)
|
---|
292 | {
|
---|
293 | if (!*mt->scheme)
|
---|
294 | strcpy(pre, "680 $a");
|
---|
295 | else if (strcasecmp(mt->scheme, "udc") == 0)
|
---|
296 | strcpy(pre, "080 $a");
|
---|
297 | else if (strcasecmp(mt->scheme, "lcc") == 0)
|
---|
298 | strcpy(pre, "050 $a");
|
---|
299 | else if (strcasecmp(mt->scheme, "lcsh") == 0)
|
---|
300 | strcpy(pre, "650 $a");
|
---|
301 | else if (strcasecmp(mt->scheme, "ddc") == 0)
|
---|
302 | strcpy(pre, "082 $a");
|
---|
303 | else if (strcasecmp(mt->scheme, "nlm") == 0)
|
---|
304 | strcpy(pre, "060 $a");
|
---|
305 | else if (strcasecmp(mt->scheme, "landslyk") == 0)
|
---|
306 | strcpy(pre, "659 $a");
|
---|
307 | else if (strcasecmp(mt->scheme, "kerfefn") == 0)
|
---|
308 | strcpy(pre, "659 $a");
|
---|
309 | else if (strcasecmp(mt->scheme, "dbc") == 0)
|
---|
310 | strcpy(pre, "65002$a");
|
---|
311 | else if (strcasecmp(mt->scheme, "mesh") == 0)
|
---|
312 | strcpy(pre, "690 $a");
|
---|
313 | else
|
---|
314 | strcpy(pre, "65004$a");
|
---|
315 | }
|
---|
316 |
|
---|
317 | else if (strcasecmp(mt->name, "date") == 0)
|
---|
318 | {
|
---|
319 | if (find_year(mt->value))
|
---|
320 | {
|
---|
321 | strcpy(mr->year, mt->value);
|
---|
322 | put008(mr->s008, mt->value, F008_DATE1);
|
---|
323 | }
|
---|
324 | }
|
---|
325 |
|
---|
326 | if (*pre)
|
---|
327 | {
|
---|
328 | strcat(mr->marcline, pre);
|
---|
329 | strcat(mr->marcline, " ");
|
---|
330 | strcat(mr->marcline, mt->value);
|
---|
331 | strcat(mr->marcline, "\n");
|
---|
332 | }
|
---|
333 | }
|
---|