1 | /* ------------------------------------------------------------------- */
|
---|
2 | /* sweMARC : Convert a metatag struct to LIBRISMARC */
|
---|
3 | /* */
|
---|
4 | /* Author : Ole Husby */
|
---|
5 | /* Last update: 1998-09-30 */
|
---|
6 | /* ------------------------------------------------------------------- */
|
---|
7 |
|
---|
8 | #include <stdlib.h>
|
---|
9 | #include <stdio.h>
|
---|
10 | #include <string.h>
|
---|
11 | #include "d2m.h"
|
---|
12 |
|
---|
13 |
|
---|
14 |
|
---|
15 |
|
---|
16 | /* ---------------------------------------------------------------------- */
|
---|
17 | /* Decides on first indicator for personal name */
|
---|
18 | /* */
|
---|
19 | /* f : no comma */
|
---|
20 | /* e : comma, with only one word preceeding */
|
---|
21 | /* s : comma, with more than one word preceeding (delimiter blank or "-") */
|
---|
22 | /* ---------------------------------------------------------------------- */
|
---|
23 |
|
---|
24 | int personal_indicator(char *pname)
|
---|
25 | {
|
---|
26 | char *comma, *blank, *hyphen;
|
---|
27 |
|
---|
28 | comma = strstr(pname, ",");
|
---|
29 | if (!comma)
|
---|
30 | return (int) 'f';
|
---|
31 |
|
---|
32 | blank = strstr(pname, " ");
|
---|
33 | hyphen = strstr(pname, "-");
|
---|
34 |
|
---|
35 | if ( (blank && blank < comma) || (hyphen && hyphen < comma) )
|
---|
36 | return (int) 's';
|
---|
37 | else
|
---|
38 | return (int) 'e';
|
---|
39 | }
|
---|
40 |
|
---|
41 |
|
---|
42 |
|
---|
43 | /* ---------------------------------------------------------------------- */
|
---|
44 | /* Decides tag for type */
|
---|
45 | /* ---------------------------------------------------------------------- */
|
---|
46 |
|
---|
47 | int parse_swetype(char *str, char *tag)
|
---|
48 | {
|
---|
49 | if ( (strcasecmp(str, "diss." ) == 0)
|
---|
50 | || (strcasecmp(str, "dissertation" ) == 0)
|
---|
51 | || (strcasecmp(str, "thesis" ) == 0)
|
---|
52 | || (strcasecmp(str, "domkap.avh." ) == 0)
|
---|
53 | || (strcasecmp(str, "hab.-schr" ) == 0)
|
---|
54 | || (strcasecmp(str, "prästmösteavh." ) == 0)
|
---|
55 | || (strcasecmp(str, "avhandling" ) == 0) )
|
---|
56 | strcpy(tag, "502");
|
---|
57 | else
|
---|
58 | strcpy(tag, "500");
|
---|
59 |
|
---|
60 | return 1;
|
---|
61 | }
|
---|
62 |
|
---|
63 |
|
---|
64 | /* ---------------------------------------------------------------------- */
|
---|
65 | /* sweMARC() */
|
---|
66 | /* ---------------------------------------------------------------------- */
|
---|
67 |
|
---|
68 | int sweMARC(struct metatag *mt, struct marcrec *mr)
|
---|
69 | {
|
---|
70 | char pre[64], creator_tag[4], type_tag[4];
|
---|
71 | int ind1;
|
---|
72 |
|
---|
73 | *pre = 0;
|
---|
74 |
|
---|
75 | if (strcasecmp(mt->name, "title") == 0)
|
---|
76 | {
|
---|
77 | if ( (!*mt->type)
|
---|
78 | | (strcasecmp(mt->type, "main") == 0)
|
---|
79 | | (strcasecmp(mt->type, "long") == 0) )
|
---|
80 | {
|
---|
81 | if (mr->ntitles)
|
---|
82 | strcpy(pre, "740 $a");
|
---|
83 | else
|
---|
84 | {
|
---|
85 | mr->ntitles++;
|
---|
86 | strcpy(pre, "245 $a");
|
---|
87 | }
|
---|
88 | }
|
---|
89 | }
|
---|
90 |
|
---|
91 |
|
---|
92 | else if (strcasecmp(mt->name, "creator") == 0)
|
---|
93 | {
|
---|
94 | if (!*mt->type)
|
---|
95 | strcpy(pre, "720 $a");
|
---|
96 | else if (strcasecmp(mt->type, "personal") == 0)
|
---|
97 | {
|
---|
98 | ind1 = personal_indicator(mt->value);
|
---|
99 | if (mr->ncreators)
|
---|
100 | strcpy(creator_tag, "700");
|
---|
101 | else
|
---|
102 | {
|
---|
103 | strcpy(creator_tag, "100");
|
---|
104 | mr-> ncreators++;
|
---|
105 | }
|
---|
106 | sprintf(pre, "%s%c $a", creator_tag, ind1);
|
---|
107 | }
|
---|
108 | else if (strcasecmp(mt->type, "corporate") == 0)
|
---|
109 | {
|
---|
110 | if (mr->ncreators)
|
---|
111 | strcpy(creator_tag, "710");
|
---|
112 | else
|
---|
113 | {
|
---|
114 | strcpy(creator_tag, "110");
|
---|
115 | mr-> ncreators++;
|
---|
116 | }
|
---|
117 | sprintf(pre, "%sc $a", creator_tag);
|
---|
118 | }
|
---|
119 | }
|
---|
120 |
|
---|
121 |
|
---|
122 | else if (strncasecmp(mt->name, "contributor", 11) == 0) /* Note both pl and sgl allowed */
|
---|
123 | {
|
---|
124 | if (!*mt->type)
|
---|
125 | strcpy(pre, "720 $a");
|
---|
126 | else if (strcasecmp(mt->type, "personal") == 0)
|
---|
127 | {
|
---|
128 | ind1 = personal_indicator(mt->value);
|
---|
129 | sprintf(pre, "700%cm$a", ind1);
|
---|
130 | }
|
---|
131 | else if (strcasecmp(mt->type, "corporate") == 0)
|
---|
132 | strcpy(pre, "710 $a");
|
---|
133 | }
|
---|
134 |
|
---|
135 |
|
---|
136 | else if (strcasecmp(mt->name, "publisher") == 0) /* Note both should go to same tag! */
|
---|
137 | {
|
---|
138 | if (!*mt->type)
|
---|
139 | strcpy(pre, "260 $b");
|
---|
140 | else if (strcasecmp(mt->type, "email") == 0)
|
---|
141 | strcpy(pre, "260 $d");
|
---|
142 | }
|
---|
143 |
|
---|
144 |
|
---|
145 |
|
---|
146 | else if (strcasecmp(mt->name, "description") == 0)
|
---|
147 | strcpy(pre, "520 $a");
|
---|
148 |
|
---|
149 |
|
---|
150 |
|
---|
151 | else if (strcasecmp(mt->name, "coverage") == 0)
|
---|
152 | {
|
---|
153 | if (!*mt->type)
|
---|
154 | strcpy(pre, "500 $a");
|
---|
155 | else if (strcasecmp(mt->type , "spatial") == 0)
|
---|
156 | strcpy(pre, "651 $a");
|
---|
157 | else if (strcasecmp(mt->type, "temporal") == 0)
|
---|
158 | strcpy(pre, "650 $a");
|
---|
159 | }
|
---|
160 |
|
---|
161 | else if (strcasecmp(mt->name, "source") == 0)
|
---|
162 | strcpy(pre, "786 $a");
|
---|
163 |
|
---|
164 |
|
---|
165 | else if (strcasecmp(mt->name, "relation") == 0)
|
---|
166 | strcpy(pre, "787 $a");
|
---|
167 |
|
---|
168 |
|
---|
169 | else if (strcasecmp(mt->name, "rights") == 0)
|
---|
170 | {
|
---|
171 | if (!*mt->scheme)
|
---|
172 | strcpy(pre, "500 $a");
|
---|
173 | if (strcasecmp(mt->scheme, "url") == 0)
|
---|
174 | strcpy(pre, "856 $u");
|
---|
175 | if (strcasecmp(mt->scheme, "urn") == 0)
|
---|
176 | strcpy(pre, "856 $g");
|
---|
177 | }
|
---|
178 |
|
---|
179 | else if (strcasecmp(mt->name, "identifier") == 0)
|
---|
180 | {
|
---|
181 | if (!*mt->scheme)
|
---|
182 | strcpy(mr->url, mt->value);
|
---|
183 | else if (strcasecmp(mt->scheme, "url") == 0)
|
---|
184 | strcpy(mr->url, mt->value);
|
---|
185 | else if (strcasecmp(mt->scheme, "urn") == 0)
|
---|
186 | strcpy(pre, "856 $g");
|
---|
187 | else if (strcasecmp(mt->scheme, "ismn") == 0)
|
---|
188 | strcpy(pre, "538 $a ISMN $b");
|
---|
189 | else if (strcasecmp(mt->scheme, "sici") == 0)
|
---|
190 | strcpy(pre, "538 $a SICI $b");
|
---|
191 | else
|
---|
192 | sprintf(pre, "538 $a %s $b", mt->scheme);
|
---|
193 | }
|
---|
194 |
|
---|
195 | else if (strcasecmp(mt->name, "type") == 0)
|
---|
196 | {
|
---|
197 | parse_swetype(mt->value, (char *) type_tag);
|
---|
198 | sprintf(pre, "%s $a", type_tag);
|
---|
199 | }
|
---|
200 |
|
---|
201 | else if (strcasecmp(mt->name, "language") == 0)
|
---|
202 | {
|
---|
203 | strcpy(pre, "506 $a");
|
---|
204 | if (strcasecmp(mt->scheme, "z39.53") == 0)
|
---|
205 | put008(mr->s008, mt->value, F008_LANGUAGE);
|
---|
206 | }
|
---|
207 |
|
---|
208 | else if (strcasecmp(mt->name, "format") == 0)
|
---|
209 | {
|
---|
210 | if ( (!*mt->scheme)
|
---|
211 | || (strcasecmp(mt->scheme, "imt") == 0)
|
---|
212 | || (strcasecmp(mt->scheme, "mime") == 0) )
|
---|
213 | strcpy(pre, "856 $q");
|
---|
214 | }
|
---|
215 |
|
---|
216 | else if (strcasecmp(mt->name, "subject") == 0)
|
---|
217 | {
|
---|
218 | if (!*mt->scheme)
|
---|
219 | strcpy(pre, "697 $a");
|
---|
220 | else if (strcasecmp(mt->scheme, "udc") == 0)
|
---|
221 | strcpy(pre, "080 $a");
|
---|
222 | else if (strcasecmp(mt->scheme, "lcsh") == 0)
|
---|
223 | strcpy(pre, "650 $a");
|
---|
224 | else if (strcasecmp(mt->scheme, "ddc") == 0)
|
---|
225 | strcpy(pre, "082 $a");
|
---|
226 | else if (strcasecmp(mt->scheme, "lcc") == 0)
|
---|
227 | strcpy(pre, "087 $a");
|
---|
228 | else if (strcasecmp(mt->scheme, "sab") == 0)
|
---|
229 | strcpy(pre, "081 $a");
|
---|
230 | else if (strcasecmp(mt->scheme, "mesh") == 0)
|
---|
231 | strcpy(pre, "660 $a");
|
---|
232 | else
|
---|
233 | strcpy(pre, "650 $a");
|
---|
234 | }
|
---|
235 |
|
---|
236 | else if (strcasecmp(mt->name, "date") == 0)
|
---|
237 | {
|
---|
238 | if ( (!*mt->type) || ( strcasecmp(mt->type, "current") == 0) )
|
---|
239 | {
|
---|
240 | if ( (strncasecmp(mt->scheme, "ans", 3) == 0)
|
---|
241 | || (strncasecmp(mt->scheme, "iso", 3) == 0) )
|
---|
242 | {
|
---|
243 | if (find_year(mt->value))
|
---|
244 | {
|
---|
245 | strcpy(mr->year, mt->value);
|
---|
246 | put008(mr->s008, mt->value, F008_DATE1);
|
---|
247 | }
|
---|
248 | }
|
---|
249 | }
|
---|
250 | }
|
---|
251 |
|
---|
252 | if (*pre)
|
---|
253 | {
|
---|
254 | strcat(mr->marcline, pre);
|
---|
255 | strcat(mr->marcline, " ");
|
---|
256 | strcat(mr->marcline, mt->value);
|
---|
257 | strcat(mr->marcline, "\n");
|
---|
258 | }
|
---|
259 | }
|
---|