From: Adam Dickmeiss Date: Fri, 10 Feb 1995 16:50:25 +0000 (+0000) Subject: Indicator field moved to 'struct iso2709_dir' from 'struct X-Git-Url: http://lists.indexdata.com/cgi-bin?a=commitdiff_plain;h=890cdaa817fe87d209ce4038a0615346106df4cf;p=egate.git Indicator field moved to 'struct iso2709_dir' from 'struct iso2709_field'. Function iso2709_rm implemented - to delete a MARC record. --- diff --git a/include/iso2709.h b/include/iso2709.h index a327e06..acaf9bc 100644 --- a/include/iso2709.h +++ b/include/iso2709.h @@ -4,12 +4,23 @@ Europagate, 1994-1995. $Log: iso2709.h,v $ - Revision 1.1 1995/02/09 17:27:11 adam - Initial revision + Revision 1.2 1995/02/10 16:50:25 adam + Indicator field moved to 'struct iso2709_dir' from 'struct + iso2709_field'. + Function iso2709_rm implemented - to delete a MARC record. + * Revision 1.1.1.1 1995/02/09 17:27:12 adam + * Initial version of email gateway under CVS control. + * */ +#ifndef ISO2709_H +#define ISO2709_H + typedef struct iso2709_rec *Iso2709Rec; char *iso2709_read (FILE *inf); Iso2709Rec iso2709_cvt (const char *buf); +void iso2709_rm (Iso2709Rec rec); + +#endif diff --git a/include/iso2709p.h b/include/iso2709p.h index 0c8472f..3fd4558 100644 --- a/include/iso2709p.h +++ b/include/iso2709p.h @@ -4,15 +4,22 @@ Europagate, 1994-1995. $Log: iso2709p.h,v $ - Revision 1.1 1995/02/09 17:27:11 adam - Initial revision - + Revision 1.2 1995/02/10 16:50:26 adam + Indicator field moved to 'struct iso2709_dir' from 'struct + iso2709_field'. + Function iso2709_rm implemented - to delete a MARC record. + + * Revision 1.1.1.1 1995/02/09 17:27:12 adam + * Initial version of email gateway under CVS control. + * */ +#ifndef ISO2709P_H +#define ISO2709P_H + #include struct iso2709_field { - char *indicator; char *identifier; char *data; struct iso2709_field *next; @@ -22,6 +29,7 @@ struct iso2709_dir { char tag[4]; int length; int offset; + char *indicator; struct iso2709_dir *next; struct iso2709_field *fields; }; @@ -45,3 +53,5 @@ struct iso2709_rec { #define ISO2709_FS 036 #define ISO2709_IDFS 037 + +#endif diff --git a/util/iso2709.c b/util/iso2709.c index 62cb8fe..927df07 100644 --- a/util/iso2709.c +++ b/util/iso2709.c @@ -4,9 +4,14 @@ Europagate, 1994-1995. $Log: iso2709.c,v $ - Revision 1.1 1995/02/09 17:27:10 adam - Initial revision - + Revision 1.2 1995/02/10 16:50:32 adam + Indicator field moved to 'struct iso2709_dir' from 'struct + iso2709_field'. + Function iso2709_rm implemented - to delete a MARC record. + + * Revision 1.1.1.1 1995/02/09 17:27:11 adam + * Initial version of email gateway under CVS control. + * */ #include @@ -78,6 +83,7 @@ Iso2709Rec iso2709_cvt (const char *buf) if (!(p = malloc (sizeof(*p)))) return NULL; + /* deal with record label (24 characters) */ p->record_length = atoin (buf, 5); strncpyx (p->record_status, buf+5, 1); strncpyx (p->implementation_codes, buf+6, 4); @@ -91,8 +97,8 @@ Iso2709Rec iso2709_cvt (const char *buf) p->length_implementation = atoin (buf+22, 1); strncpyx (p->future_use, buf+23, 1); + /* deal with directory */ dpp = &p->directory; - *dpp = NULL; while (buf[pos] != ISO2709_FS) { @@ -108,6 +114,7 @@ Iso2709Rec iso2709_cvt (const char *buf) dpp = &(*dpp)->next; } pos++; + /* deal with datafields */ #if 0 fprintf (stderr, "indicator_len=%d, identifier_len=%d\n", p->indicator_length, p->identifier_length); @@ -117,7 +124,6 @@ Iso2709Rec iso2709_cvt (const char *buf) int tag00; struct iso2709_field **fpp; int dpos = pos+dp->offset; - char *save_indicator = NULL; fpp = &dp->fields; @@ -125,18 +131,20 @@ Iso2709Rec iso2709_cvt (const char *buf) (*fpp)->next = NULL; if (p->indicator_length && memcmp (dp->tag, "00", 2)) { - (*fpp)->indicator = malloc (p->indicator_length+1); - strncpyx ((*fpp)->indicator, buf+dpos, p->indicator_length); + dp->indicator = malloc (p->indicator_length+1); + strncpyx (dp->indicator, buf+dpos, p->indicator_length); dpos += p->indicator_length; } else - (*fpp)->indicator = NULL; + dp->indicator = NULL; if (memcmp (dp->tag, "00", 2)) tag00 = 0; else tag00 = 1; fprintf (stderr, "%s", dp->tag); + if (dp->indicator) + fprintf (stderr, " %s", dp->indicator); while (1) { int dpos_n; @@ -158,21 +166,38 @@ Iso2709Rec iso2709_cvt (const char *buf) strncpyx ((*fpp)->data, buf+dpos, dpos_n - dpos); dpos = dpos_n; - if (!save_indicator && (*fpp)->indicator) - fprintf (stderr, " %s", (*fpp)->indicator); if ((*fpp)->identifier) fprintf (stderr, " *%s", (*fpp)->identifier); fprintf (stderr, " %s", (*fpp)->data); if (buf[dpos] == ISO2709_FS) break; - save_indicator = (*fpp)->indicator; fpp = &(*fpp)->next; *fpp = malloc (sizeof(**fpp)); (*fpp)->next = NULL; - (*fpp)->indicator = save_indicator; } fprintf (stderr, "\n"); } return p; } + +void iso2709_rm (Iso2709Rec rec) +{ + struct iso2709_dir *dir, *dir1; + + for (dir = rec->directory; dir; dir = dir1) + { + struct iso2709_field *field, *field1; + + for (field = dir->fields; field; field = field1) + { + free (field->identifier); + free (field->data); + field1 = field->next; + free (field); + } + free (dir->indicator); + dir1 = dir->next; + free (dir); + } +} diff --git a/util/iso2709dump.c b/util/iso2709dump.c index fbf66dc..4a284bf 100644 --- a/util/iso2709dump.c +++ b/util/iso2709dump.c @@ -4,9 +4,14 @@ Europagate, 1994-1995. $Log: iso2709dump.c,v $ - Revision 1.1 1995/02/09 17:27:10 adam - Initial revision + Revision 1.2 1995/02/10 16:50:33 adam + Indicator field moved to 'struct iso2709_dir' from 'struct + iso2709_field'. + Function iso2709_rm implemented - to delete a MARC record. + * Revision 1.1.1.1 1995/02/09 17:27:11 adam + * Initial version of email gateway under CVS control. + * */ #include @@ -23,6 +28,7 @@ int main (int argc, char **argv) { rec = iso2709_cvt (buf); free (buf); + iso2709_rm (rec); } return 0; }