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