2 * Copyright (C) 1994, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.1 1995-04-10 10:28:46 quinn
8 * Added copy of CCL and MARC display
17 #define ISO2709_RS 035
18 #define ISO2709_FS 036
19 #define ISO2709_IDFS 037
21 int atoi_n (const char *buf, int len)
28 val = val*10 + (*buf - '0');
34 int marc_display (const char *buf, FILE *outf)
39 int identifier_length;
41 int length_data_entry;
43 int length_implementation;
45 record_length = atoi_n (buf, 5);
46 if (record_length < 25)
48 indicator_length = atoi_n (buf+10, 1);
49 identifier_length = atoi_n (buf+11, 1);
50 base_address = atoi_n (buf+12, 4);
52 length_data_entry = atoi_n (buf+20, 1);
53 length_starting = atoi_n (buf+21, 1);
54 length_implementation = atoi_n (buf+22, 1);
56 for (entry_p = 24; buf[entry_p] != ISO2709_FS; )
57 entry_p += 3+length_data_entry+length_starting;
58 base_address = entry_p+1;
59 for (entry_p = 24; buf[entry_p] != ISO2709_FS; )
67 memcpy (tag, buf+entry_p, 3);
70 fprintf (outf, "%s ", tag);
71 data_length = atoi_n (buf+entry_p, length_data_entry);
72 entry_p += length_data_entry;
73 data_offset = atoi_n (buf+entry_p, length_starting);
74 entry_p += length_starting;
75 i = data_offset + base_address;
76 end_offset = i+data_length-1;
77 if (memcmp (tag, "00", 2) && indicator_length)
79 for (j = 0; j<indicator_length; j++)
80 fprintf (outf, "%c", buf[i++]);
82 while (buf[i] != ISO2709_RS && buf[i] != ISO2709_FS && i < end_offset)
84 if (memcmp (tag, "00", 2) && identifier_length)
88 for (j = 1; j<identifier_length; j++)
89 fprintf (outf, "%c", buf[i++]);
91 while (buf[i] != ISO2709_RS && buf[i] != ISO2709_IDFS &&
92 buf[i] != ISO2709_FS && i < end_offset)
93 fprintf (outf, "%c", buf[i++]);
96 fprintf (outf, "%c", buf[i++]);
100 fprintf (outf, "-- separator but not at end of field\n");
101 if (buf[i] != ISO2709_RS && buf[i] != ISO2709_FS)
102 fprintf (outf, "-- no separator at end of field\n");
104 return record_length;