* Europagate, 1994-1995.
*
* $Log: iso2709.c,v $
- * Revision 1.13 1995/03/30 07:33:32 adam
+ * Revision 1.14 1995/03/30 14:22:18 adam
+ * More work on new MARC anchor functions.
+ *
+ * Revision 1.13 1995/03/30 07:33:32 adam
* New 2709 function: iso2709_mk.
* First implementation of iso2709_a_insert.
*
int dpos_n;
if (p->identifier_length && identifier_flag)
{
- if (!((*fpp)->identifier = malloc (p->identifier_length+1)))
- {
- iso2709_rm (p);
- return NULL;
- }
strncpyx ((*fpp)->identifier, buf+dpos+1,
p->identifier_length-1);
dpos_n = dpos += p->identifier_length;
}
else
{
- (*fpp)->identifier = NULL;
+ *(*fpp)->identifier = '\0';
dpos_n = dpos;
while (buf[dpos_n] != ISO2709_FS && buf[dpos_n] != ISO2709_RS
&& dpos_n < epos)
{
if (buf[dpos] != ISO2709_FS && buf[dpos] != ISO2709_RS)
fprintf (stderr, "Missing separator at end of field "
- "in %s %s\n", dp->tag, (*fpp)->identifier ?
- (*fpp)->identifier : "");
+ "in %s %s\n", dp->tag, (*fpp)->identifier);
break;
}
if (buf[dpos] == ISO2709_FS || buf[dpos] == ISO2709_RS)
{
- fprintf (stderr, "Unexpected separator inside field\n");
+ fprintf (stderr, "Unexpected separator inside field %s %s\n",
+ dp->tag, (*fpp)->identifier);
break;
}
fpp = &(*fpp)->next;
for (field = dir->fields; field; field = field1)
{
- free (field->identifier);
free (field->data);
field1 = field->next;
free (field);
* Europagate, 1995.
*
* $Log: iso2709a.c,v $
- * Revision 1.2 1995/03/30 07:33:35 adam
+ * Revision 1.3 1995/03/30 14:22:18 adam
+ * More work on new MARC anchor functions.
+ *
+ * Revision 1.2 1995/03/30 07:33:35 adam
* New 2709 function: iso2709_mk.
* First implementation of iso2709_a_insert.
*
if (tag)
*tag = (*anchor->d0)->tag;
if (indicator)
+ {
*indicator = (*anchor->d0)->indicator;
+ if (*indicator && !**indicator)
+ *indicator = NULL;
+ }
if (identifier)
+ {
*identifier = (*anchor->f0)->identifier;
+ if (*identifier && !**identifier)
+ *identifier = NULL;
+ }
if (data)
*data = (*anchor->f0)->data;
return 1;
return 0;
field = *anchor->f0;
*anchor->f0 = field->next;
- free (field->identifier);
free (field->data);
free (field);
if (!*anchor->f0)
}
else
dir->indicator = NULL;
- dir->next = *a->d0;
- *a->d0 = dir;
+ if (*a->d0)
+ a->d0 = &(*a->d0)->next;
+ dir->next = *a->d0;
+ *a->d0 = dir;
dir->fields = NULL;
a->f0 = &dir->fields;
}
if (!(field = malloc (sizeof(*field))))
return 0;
if (identifier)
- {
- if (!(field->identifier = malloc (strlen (identifier)+1)))
- return 0;
strcpy (field->identifier, identifier);
- }
else
- field->identifier = NULL;
+ *field->identifier = '\0';
if (!(field->data = malloc (strlen (data)+1)))
return 0;
strcpy (field->data, data);
* Europagate, 1994-1995.
*
* $Log: iso2709dump.c,v $
- * Revision 1.8 1995/03/30 07:33:37 adam
+ * Revision 1.9 1995/03/30 14:22:18 adam
+ * More work on new MARC anchor functions.
+ *
+ * Revision 1.8 1995/03/30 07:33:37 adam
* New 2709 function: iso2709_mk.
* First implementation of iso2709_a_insert.
*
do {
if (!iso2709_a_info_field (a_in, &tag, &indicator, &identifier, &data))
break;
- printf ("[%s %s %s]", tag, indicator ? indicator : "",
- identifier ? identifier : "");
-#if 1
iso2709_a_insert (a_out, tag, indicator, identifier, data);
-#endif
} while (iso2709_a_next (a_in));
iso2709_a_rm (a_in);
iso2709_a_rm (a_out);
if (!quiet)
{
iso2709_display (rec_input, stdout);
+ iso2709_display (rec_output, stdout);
}
if (outf && fwrite (obuf, 1, olen, outf) != olen)
{
* Europagate, 1995.
*
* $Log: iso2709o.c,v $
- * Revision 1.1 1995/03/28 16:07:07 adam
+ * Revision 1.2 1995/03/30 14:22:19 adam
+ * More work on new MARC anchor functions.
+ *
+ * Revision 1.1 1995/03/28 16:07:07 adam
* New function: iso2709_out. This function is the reverse of iso2709_cvt.
*
*/
len += p->indicator_length;
for (field = dir->fields; field; field = field->next)
{
- if (field->identifier)
+ if (*field->identifier)
len += p->identifier_length;
len += strlen (field->data);
}
}
for (field = dir->fields; field; field = field->next)
{
- if (field->identifier)
+ if (*field->identifier)
{
op[data_p] = ISO2709_IDFS;
memcpy (op + data_p+1, field->identifier,