source: trunk/gsdl/packages/d2m/finMARC.c@ 10365

Last change on this file since 10365 was 10365, checked in by kjdon, 19 years ago

changed my mind, now adding these all individually instead of in a tar file

  • Property svn:keywords set to Author Date Id Revision
File size: 7.0 KB
Line 
1/* ------------------------------------------------------------------- */
2/* finMARC : Convert a metatag struct to FINMARC */
3/* */
4/* Author : Ole Husby */
5/* Last update: 1998-09-30 */
6/* ------------------------------------------------------------------- */
7
8#include <stdio.h>
9#include <string.h>
10#include "d2m.h"
11
12
13/* Decides tag for format */
14
15int parse_format(char *str, char *format)
16{
17 if (strcasecmp(str, "text/html") == 0)
18 strcpy(format, "HTML");
19
20 return 1;
21}
22
23
24/* Decides tag for type */
25
26int parse_type(char *str, char *tag)
27{
28 strcpy(tag, "500");
29
30 if ( (strcasecmp(str, "diss." ) == 0)
31 || (strcasecmp(str, "dissertation" ) == 0)
32 || (strcasecmp(str, "phd thesis" ) == 0)
33 || (strcasecmp(str, "väitöskirja" ) == 0)
34 || (strcasecmp(str, "väitösk." ) == 0)
35 || (strcasecmp(str, "avhandling" ) == 0) )
36 strcpy(tag, "502");
37
38 else
39 if ( (strcasecmp(str, "masters thesis" ) == 0)
40 || (strcasecmp(str, "honours thesis" ) == 0)
41 || (strcasecmp(str, "opinnäyte" ) == 0)
42 || (strcasecmp(str, "opinn." ) == 0) )
43 strcpy(tag, "509");
44
45 return 1;
46}
47
48
49int finMARC(struct metatag *mt, struct marcrec *mr)
50{
51 char pre[64], type_tag[4];
52
53 *pre = 0;
54
55 if (strcasecmp(mt->name, "title") == 0)
56 {
57 if ( (!*mt->type)
58 | (strcasecmp(mt->type, "main") == 0)
59 | (strcasecmp(mt->type, "long") == 0) )
60 {
61 if (mr->ntitles)
62 {
63 strcat(mr->partitle, "$r ");
64 strcat(mr->partitle, mt->value);
65
66 }
67 else
68 {
69 mr->ntitles++;
70 strcpy(pre, "245 $a");
71 }
72 }
73 }
74
75 else if (strcasecmp(mt->name, "creator") == 0)
76 {
77 if (!*mt->type)
78 {
79 strcpy(pre, "720 $a");
80 split_name(mt->value);
81 }
82 else if ( (strcasecmp(mt->type, "name") == 0)
83 || (strcasecmp(mt->type, "personal") == 0) )
84 {
85 strcpy(pre, "100 $a");
86 split_name(mt->value);
87 }
88 else if (strcasecmp(mt->type, "corporate") == 0)
89 strcpy(pre, "110 $a");
90 }
91
92 else if (strcasecmp(mt->name, "publisher") == 0)
93 {
94 if (!*mt->type)
95 strcpy(pre, "260 $b");
96 else if (strcasecmp(mt->type, "name") == 0)
97 strcpy(pre, "260 $b");
98 }
99
100 else if (strcasecmp(mt->name, "description") == 0)
101 strcpy(pre, "519 $a");
102
103 else if (strncasecmp(mt->name, "contributor", 11) == 0) /* Note both pl and sgl allowed */
104 {
105 if (!*mt->type)
106 {
107 strcpy(pre, "720 $a");
108 split_name(mt->value);
109 }
110 else if ( (strcasecmp(mt->type, "name") == 0)
111 || (strcasecmp(mt->type, "personal") == 0) )
112 {
113 strcpy(pre, "700 $a");
114 split_name(mt->value);
115 }
116 else if (strcasecmp(mt->type, "corporate") == 0)
117 strcpy(pre, "710 $a");
118 }
119
120 else if (strcasecmp(mt->name, "coverage") == 0)
121 {
122 if (!*mt->type)
123 strcpy(pre, "500 $a");
124 else if (strcasecmp(mt->type , "spatial") == 0)
125 {
126 strcpy(pre, "655 $a");
127 split_subj(mt->value);
128 }
129 else if (strcasecmp(mt->type, "temporal") == 0)
130 {
131 strcpy(pre, "652 $a");
132 split_subj(mt->value);
133 }
134 }
135
136 else if (strcasecmp(mt->name, "source") == 0)
137 strcpy(pre, "501 $a");
138
139 else if (strcasecmp(mt->name, "rights") == 0)
140 {
141 if (strcasecmp(mt->scheme, "url") == 0)
142 strcpy(pre, "856 $u");
143 }
144
145 else if (strcasecmp(mt->name, "identifier") == 0)
146 {
147 if (!*mt->scheme)
148 strcpy(mr->url, mt->value);
149 else if (strcasecmp(mt->scheme, "url") == 0)
150 strcpy(mr->url, mt->value);
151 else if (strcasecmp(mt->scheme, "urn") == 0)
152 strcpy(pre, "856 $g");
153 else if (strcasecmp(mt->scheme, "isbn") == 0)
154 strcpy(pre, "021 $a");
155 else if (strcasecmp(mt->scheme, "issn") == 0)
156 strcpy(pre, "022 $a");
157 else if (strcasecmp(mt->scheme, "nbn") == 0)
158 strcpy(pre, "015 $a");
159 else if (strcasecmp(mt->scheme, "isrc") == 0)
160 strcpy(pre, "015 $a");
161 else if (strcasecmp(mt->scheme, "ismn") == 0)
162 strcpy(pre, "024 $a");
163 else if (strcasecmp(mt->scheme, "isrn") == 0)
164 strcpy(pre, "027 $a");
165 }
166
167 else if (strcasecmp(mt->name, "type") == 0)
168 {
169 parse_type(mt->value, (char *) type_tag);
170 sprintf(pre, "%s $a", type_tag);
171 }
172
173 else if (strcasecmp(mt->name, "language") == 0)
174 {
175 if (strcasecmp(mt->scheme, "z39.53") == 0)
176 {
177 strcpy(pre, "041 $a");
178 if (strlen(mt->value) == 3)
179 put008(mr->s008, mt->value, F008_LANGUAGE);
180 }
181 }
182
183 else if (strcasecmp(mt->name, "format") == 0)
184 {
185 if ( (!*mt->scheme)
186 || (strcasecmp(mt->scheme, "imt") == 0)
187 || (strcasecmp(mt->scheme, "mime") == 0) )
188 parse_format(mt->value, (char *) mr->fmat);
189 }
190
191 else if (strcasecmp(mt->name, "subject") == 0)
192 {
193 if (!*mt->scheme)
194 strcpy(pre, "692 $a");
195 else if (strcasecmp(mt->scheme, "udc") == 0)
196 strcpy(pre, "080 $a");
197 else if (strcasecmp(mt->scheme, "lcsh") == 0)
198 strcpy(pre, "650 $a");
199 else if (strcasecmp(mt->scheme, "ddc") == 0)
200 strcpy(pre, "082 $a");
201 else if (strcasecmp(mt->scheme, "mesh") == 0)
202 strcpy(pre, "690 $a");
203 else if (strcasecmp(mt->scheme, "ykl") == 0)
204 strcpy(pre, "098 $a");
205 else if (strcasecmp(mt->scheme, "ysa") == 0)
206 {
207 strcpy(pre, "652 $a");
208 split_subj(mt->value);
209 }
210 else if (strcasecmp(mt->scheme, "fimu") == 0)
211 {
212 strcpy(pre, "653 $a");
213 split_subj(mt->value);
214 }
215 else if (strcasecmp(mt->scheme, "fige") == 0)
216 {
217 strcpy(pre, "655 $a");
218 split_subj(mt->value);
219 }
220 else if (strcasecmp(mt->scheme, "file") == 0)
221 {
222 strcpy(pre, "665 $a");
223 split_subj(mt->value);
224 }
225 else if (strcasecmp(mt->scheme, "fiso") == 0)
226 {
227 strcpy(pre, "670 $a");
228 split_subj(mt->value);
229 }
230 else if (strcasecmp(mt->scheme, "fire") == 0)
231 {
232 strcpy(pre, "680 $a");
233 split_subj(mt->value);
234 }
235 else if (strcasecmp(mt->scheme, "fifo") == 0)
236 {
237 strcpy(pre, "685 $a");
238 split_subj(mt->value);
239 }
240 else if (strcasecmp(mt->scheme, "fiag") == 0)
241 {
242 strcpy(pre, "686 $a");
243 split_subj(mt->value);
244 }
245 else if (strcasecmp(mt->scheme, "fiep") == 0)
246 {
247 strcpy(pre, "660 $a");
248 split_subj(mt->value);
249 }
250 }
251
252 else if (strcasecmp(mt->name, "date") == 0)
253 {
254 if ( (!*mt->type) || ( strcasecmp(mt->type, "current") == 0) )
255 {
256 if ( (strncasecmp(mt->scheme, "ans", 3) == 0)
257 || (strncasecmp(mt->scheme, "iso", 3) == 0) )
258 {
259 if (find_year(mt->value))
260 {
261 strcpy(mr->year, mt->value);
262 put008(mr->s008, mt->value, F008_DATE1);
263 }
264 }
265 }
266 }
267
268 if (*pre)
269 {
270 strcat(mr->marcline, pre);
271 strcat(mr->marcline, " ");
272 strcat(mr->marcline, mt->value);
273 strcat(mr->marcline, "\n");
274 }
275}
Note: See TracBrowser for help on using the repository browser.