X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=util%2Fmarcdump.c;h=ca9b324146c6d318cc8967eae97f6a1bdaf51780;hb=9cc8f4a4d0fd7f1e4bd6c9d5c85ef2dccaab5743;hp=6dd79d1eba462e0068c0dd49f0930b169b648ca3;hpb=f514c7fcb9cd0c205b308a1213112317d564874c;p=yaz-moved-to-github.git diff --git a/util/marcdump.c b/util/marcdump.c index 6dd79d1..ca9b324 100644 --- a/util/marcdump.c +++ b/util/marcdump.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: marcdump.c,v 1.28 2005-03-06 21:27:09 adam Exp $ + * $Id: marcdump.c,v 1.30 2005-04-20 13:17:29 adam Exp $ */ #if HAVE_CONFIG_H @@ -199,18 +199,45 @@ int main (int argc, char **argv) r = fread (buf, 1, 5, inf); if (r < 5) { - if (r && print_offset) - printf ("Extra %d bytes", r); + if (r && print_offset && verbose) + printf ("\n", r); break; } + while (*buf < '0' || *buf > '9') + { + int i; + long off = ftell(inf) - 5; + if (verbose || print_offset) + printf("\n", + *buf & 0xff, *buf & 0xff, + off, off); + for (i = 0; i<4; i++) + buf[i] = buf[i+1]; + r = fread(buf+4, 1, 1, inf); + if (r < 1) + break; + } + if (r < 1) + { + if (verbose || print_offset) + printf ("\n"); + break; + } if (print_offset) { - long off = ftell(inf); - printf ("Record %d offset %ld\n", num, (long) off); + long off = ftell(inf) - 5; + printf ("\n", + num, off, off); } len = atoi_n(buf, 5); if (len < 25 || len > 100000) + { + long off = ftell(inf) - 5; + printf("Bad Length %d read at offset %ld (%lx)\n", + len, (long) off, (long) off); break; + } len = len - 5; r = fread (buf + 5, 1, len, inf); if (r < len) @@ -275,6 +302,8 @@ int main (int argc, char **argv) fprintf (cfile, "\"\n"); } num++; + if (verbose) + printf("\n"); } count++; if (cd)