From 39d29539fcda6555089fe3a581953829af06ac7e Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 10 Mar 1995 09:10:56 +0000 Subject: [PATCH] Removed dbc2709_cvt function. Makes heuristic guess for DBC2709 records. --- util/Makefile | 7 +++++-- util/iso2709.c | 62 ++++++++++++++++++++++++++++++++------------------------ 2 files changed, 41 insertions(+), 28 deletions(-) diff --git a/util/Makefile b/util/Makefile index c0d6c11..3e34da0 100644 --- a/util/Makefile +++ b/util/Makefile @@ -2,7 +2,10 @@ # Europagate, 1995 # # $Log: Makefile,v $ -# Revision 1.7 1995/02/22 21:32:36 adam +# Revision 1.8 1995/03/10 09:10:56 adam +# Removed dbc2709_cvt function. Makes heuristic guess for DBC2709 records. +# +# Revision 1.7 1995/02/22 21:32:36 adam # Changed header. # # Revision 1.5 1995/02/22 08:51:46 adam @@ -29,7 +32,7 @@ TPROG1=iso2709dump LIB=../lib/util.a PO=iso2709.o iso27dis.o CPP=$(CC) -E -DEFS=$(INCLUDE) +DEFS=$(INCLUDE) -DSTUPID_ISO_DBC=1 all: $(TPROG1) $(TPROG2) diff --git a/util/iso2709.c b/util/iso2709.c index 4001dcb..812f8da 100644 --- a/util/iso2709.c +++ b/util/iso2709.c @@ -4,7 +4,10 @@ * Europagate, 1994-1995. * * $Log: iso2709.c,v $ - * Revision 1.9 1995/03/08 12:36:39 adam + * Revision 1.10 1995/03/10 09:10:56 adam + * Removed dbc2709_cvt function. Makes heuristic guess for DBC2709 records. + * + * Revision 1.9 1995/03/08 12:36:39 adam * New function: dbc2709_cvt. * * Revision 1.8 1995/03/08 12:03:15 adam @@ -97,7 +100,7 @@ char *iso2709_read (FILE *inf) } -static Iso2709Rec iso2709_cvt_g (const char *buf, int use_dbc) +Iso2709Rec iso2709_cvt (const char *buf) { struct iso2709_dir **dpp, *dp; int pos = 24; @@ -131,6 +134,7 @@ static Iso2709Rec iso2709_cvt_g (const char *buf, int use_dbc) while (buf[pos] != ISO2709_FS) { *dpp = malloc (sizeof(**dpp)); + assert (*dpp); (*dpp)->next = NULL; strncpyx ((*dpp)->tag, buf+pos, 3); pos += 3; @@ -145,45 +149,60 @@ static Iso2709Rec iso2709_cvt_g (const char *buf, int use_dbc) /* deal with datafields */ for (dp = p->directory; dp; dp = dp->next) { - int tag00; + int identifier_flag; struct iso2709_field **fpp; int dpos = pos+dp->offset; fpp = &dp->fields; *fpp = malloc (sizeof(**fpp)); + assert (*fpp); (*fpp)->next = NULL; - if (p->indicator_length && (memcmp (dp->tag, "00", 2) || use_dbc)) + + identifier_flag = 1; + if (p->indicator_length) + { +#if STUPID_ISO_DBC + if (buf[dpos+p->indicator_length] != ISO2709_IDFS) + identifier_flag = 0; +#else + if (!memcmp (dp->tag, "00", 2)) + identifier_flag = 0; +#endif + } + else if (!memcmp (dp->tag, "00", 2)) + identifier_flag = 0; + if (identifier_flag && p->indicator_length) { dp->indicator = malloc (p->indicator_length+1); + assert (dp->indicator); strncpyx (dp->indicator, buf+dpos, p->indicator_length); dpos += p->indicator_length; } else dp->indicator = NULL; - if (memcmp (dp->tag, "00", 2)) - tag00 = 0; - else - tag00 = 1; while (1) { int dpos_n; - if (p->identifier_length && (!tag00 || use_dbc)) + if (p->identifier_length && identifier_flag) { (*fpp)->identifier = malloc (p->identifier_length+1); strncpyx ((*fpp)->identifier, buf+dpos+1, p->identifier_length-1); - dpos += p->identifier_length; + dpos_n = dpos += p->identifier_length; + while (buf[dpos_n] != ISO2709_FS && buf[dpos_n] != ISO2709_RS + && buf[dpos_n] != ISO2709_IDFS) + dpos_n++; } else + { (*fpp)->identifier = NULL; - - dpos_n = dpos; - while (buf[dpos_n] != ISO2709_FS && buf[dpos_n] != ISO2709_IDFS && - buf[dpos_n] != ISO2709_RS) - dpos_n++; - + dpos_n = dpos; + while (buf[dpos_n] != ISO2709_FS && buf[dpos_n] != ISO2709_RS) + dpos_n++; + } (*fpp)->data = malloc (dpos_n - dpos + 1); + assert ((*fpp)->data); strncpyx ((*fpp)->data, buf+dpos, dpos_n - dpos); dpos = dpos_n; @@ -192,22 +211,13 @@ static Iso2709Rec iso2709_cvt_g (const char *buf, int use_dbc) fpp = &(*fpp)->next; *fpp = malloc (sizeof(**fpp)); + assert (*fpp); (*fpp)->next = NULL; } } return p; } -Iso2709Rec iso2709_cvt (const char *buf) -{ - return iso2709_cvt_g (buf, 0); -} - -Iso2709Rec dbc2709_cvt (const char *buf) -{ - return iso2709_cvt_g (buf, 1); -} - void iso2709_rm (Iso2709Rec rec) { struct iso2709_dir *dir, *dir1; -- 1.7.10.4