source: trunk/gsdl/packages/d2m/danMARC.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: 5.8 KB
Line 
1/* ------------------------------------------------------------------- */
2/* danMARC : Convert a metatag struct to DANMARC2 */
3/* */
4/* Specs : http://www.bibsys.no/meta/d2m/dancross.html */
5/* */
6/* Author : Ole Husby */
7/* Last update: 1998-09-30 */
8/* ------------------------------------------------------------------- */
9
10#include <stdio.h>
11#include <string.h>
12#include "d2m.h"
13
14
15
16/* Splits subject heading on ":". First occurence go into $a, second into $v */
17
18int split_dk5(char *str)
19{
20 char *p, *q, subtag[5];
21
22 if (!strstr(str, ":"))
23 return 1;
24
25 p = (char *) malloc(strlen(str) + 50);
26 *p = 0;
27 *subtag = 0;
28
29 q = strtok(str, ":");
30 if (q)
31 {
32 while ( ( q[0] == ' ' ) && ( strlen(q) ) )
33 q++;
34
35 while( ( q[strlen(q) - 1] == ' ' ) && ( strlen(q) ) )
36 q[strlen(q) - 1] = '\0';
37
38 if (*q)
39 {
40 strcat(p, subtag);
41 strcat(p, q);
42 strcpy(subtag, " $v ");
43 }
44 }
45
46 strcpy(str, p);
47 free(p);
48
49 return 1;
50}
51
52
53
54
55int danMARC(struct metatag *mt, struct marcrec *mr)
56{
57 char pre[64], type_tag[4];
58 int i;
59
60 *pre = 0;
61
62 if (strcasecmp(mt->name, "title") == 0)
63 {
64 if ( (!*mt->type)
65 | (strcasecmp(mt->type, "main") == 0)
66 | (strcasecmp(mt->type, "long") == 0) )
67 {
68 if (mr->ntitles)
69 {
70 strcat(mr->partitle, "$a ");
71 strcat(mr->partitle, mt->value);
72
73 }
74 else
75 {
76 mr->ntitles++;
77 strcpy(pre, "245 $a");
78 }
79 }
80 }
81
82 else if (strcasecmp(mt->name, "creator") == 0)
83 {
84 if ( strcasecmp(mt->type, "personal") == 0)
85 {
86 strcpy(pre, "700 $a");
87 split_name(mt->value);
88 }
89 else if (strcasecmp(mt->type, "corporate") == 0)
90 strcpy(pre, "710 $a");
91 }
92
93
94 else if (strcasecmp(mt->name, "publisher") == 0)
95 strcpy(pre, "260 $b");
96
97 else if (strcasecmp(mt->name, "description") == 0)
98 strcpy(pre, "504 $a");
99
100 else if (strncasecmp(mt->name, "contributor", 11) == 0)
101 {
102 if ( strcasecmp(mt->type, "personal") == 0 )
103 {
104 strcpy(pre, "700 $a");
105 split_name(mt->value);
106 }
107 else if (strcasecmp(mt->type, "corporate") == 0)
108 strcpy(pre, "710 $a");
109 }
110
111 else if (strcasecmp(mt->name, "coverage") == 0)
112 {
113 if (!*mt->type)
114 strcpy(pre, "559 $a");
115 else if (strcasecmp(mt->type , "spatial") == 0)
116 {
117 strcpy(pre, "633 $a");
118 split_subj(mt->value);
119 }
120 else if (strcasecmp(mt->type, "temporal") == 0)
121 {
122 strcpy(pre, "334 $b");
123 for (i = 0; i < strlen(mt->value); i++)
124 {
125 if (!isdigit(mt->value[i]))
126 {
127 strcpy(pre, "334 $a");
128 }
129 }
130 }
131 }
132
133 else if (strcasecmp(mt->name, "source") == 0)
134 strcpy(pre, "523 $a");
135
136 else if (strcasecmp(mt->name, "rights") == 0)
137 {
138 if (strcasecmp(mt->scheme, "url") == 0)
139 strcpy(pre, "856 $3 rights $u");
140 else
141 strcpy(pre, "518 $a");
142 }
143
144 else if (strcasecmp(mt->name, "identifier") == 0)
145 {
146 if (!*mt->scheme)
147 strcpy(mr->url, mt->value);
148 else if (strcasecmp(mt->scheme, "url") == 0)
149 strcpy(mr->url, mt->value);
150 else if (strcasecmp(mt->scheme, "urn") == 0)
151 strcpy(pre, "856 $g urn:");
152 else if (strcasecmp(mt->scheme, "isbn") == 0)
153 strcpy(pre, "021 $a");
154 else if (strcasecmp(mt->scheme, "issn") == 0)
155 strcpy(pre, "022 $a");
156 else if (strcasecmp(mt->scheme, "isrc") == 0)
157 strcpy(pre, "024 $a");
158 else if (strcasecmp(mt->scheme, "ismn") == 0)
159 strcpy(pre, "028 $a");
160 else if (strcasecmp(mt->scheme, "isrn") == 0)
161 strcpy(pre, "027 $a");
162 }
163
164 else if (strcasecmp(mt->name, "type") == 0)
165 strcpy(pre, "505 $a");
166
167 else if (strcasecmp(mt->name, "relation") == 0)
168 strcpy(pre, "559 $a");
169
170 else if (strcasecmp(mt->name, "language") == 0) /* Only if repeated ! */
171 {
172 if (strcasecmp(mt->scheme, "z39.53") == 0)
173 {
174 strcpy(pre, "041 $a");
175 put008(mr->s008, mt->value, F008_LANGUAGE);
176 }
177 }
178
179 else if (strcasecmp(mt->name, "format") == 0)
180 {
181 if ( (!*mt->scheme)
182 || (strcasecmp(mt->scheme, "imt") == 0)
183 || (strcasecmp(mt->scheme, "mime") == 0) )
184 strcpy(mr->fmat, mt->value);
185 }
186
187 else if (strcasecmp(mt->name, "subject") == 0)
188 {
189 if (!*mt->scheme)
190 strcpy(pre, "631 $a");
191 else if (strcasecmp(mt->scheme, "udc") == 0)
192 strcpy(pre, "080 $a");
193 else if (strcasecmp(mt->scheme, "lccs") == 0)
194 strcpy(pre, "050 $a");
195 else if (strcasecmp(mt->scheme, "lcsh") == 0)
196 strcpy(pre, "650 $a");
197 else if (strcasecmp(mt->scheme, "ddc") == 0)
198 strcpy(pre, "082 $a");
199 else if (strcasecmp(mt->scheme, "nlm") == 0)
200 strcpy(pre, "060 $a");
201 else if (strcasecmp(mt->scheme, "agr") == 0)
202 strcpy(pre, "662 $a");
203 else if (strcasecmp(mt->scheme, "eudised") == 0)
204 strcpy(pre, "661 $b");
205 else if (strcasecmp(mt->scheme, "dbc") == 0)
206 strcpy(pre, "666 $f");
207 else if (strcasecmp(mt->scheme, "mesh") == 0)
208 strcpy(pre, "690 $a");
209 else if (strcasecmp(mt->scheme, "dk5") == 0)
210 {
211 strcpy(pre, "652 $m");
212 split_dk5(mt->value);
213 }
214 }
215
216 else if (strcasecmp(mt->name, "date") == 0)
217 {
218 if ( (!*mt->type) || ( strcasecmp(mt->type, "current") == 0) )
219 {
220 if ( (strncasecmp(mt->scheme, "ans", 3) == 0)
221 || (strncasecmp(mt->scheme, "iso", 3) == 0) )
222 {
223 if (find_year(mt->value))
224 {
225 strcpy(mr->year, mt->value);
226 put008(mr->s008, mt->value, F008_DATE1);
227 }
228 }
229 }
230 }
231
232 if (*pre)
233 {
234 strcat(mr->marcline, pre);
235 strcat(mr->marcline, " ");
236 strcat(mr->marcline, mt->value);
237 strcat(mr->marcline, "\n");
238 }
239}
Note: See TracBrowser for help on using the repository browser.