2 * FML interpreter. Europagate, 1995
5 * Revision 1.2 1995/02/10 16:52:08 adam
6 * Indicator field moved in MARC structure. The FML list representation
7 * of a MARC record has changed.
9 * Revision 1.1 1995/02/10 15:50:56 adam
10 * MARC interface implemented. Minor bugs fixed. fmltest can
11 * be used to format single MARC records. New function '\list'
26 struct fml_node *marc_to_fml (Fml fml, Iso2709Rec rec)
28 struct fml_node *ptr_0 = NULL, *ptr_1;
29 struct iso2709_dir *dir;
31 for (dir = rec->directory; dir; dir=dir->next)
35 ptr = fml_node_alloc (fml);
45 struct iso2709_field *fields = dir->fields;
47 ptr = fml_node_alloc (fml);
48 ptr->p[0] = fml_atom_alloc (fml, fields->data);
51 while ((fields = fields->next))
53 ptr = ptr->p[0] = fml_node_alloc (fml);
54 ptr->p[0] = fml_atom_alloc (fml, fields->data);
63 static void add_string (const char *str, char **buf, int *max, int *size)
65 if (*size + strlen(str) >= *max)
68 int nsize = *size + strlen(str) + 2048;
70 nbuf = malloc (nsize);
80 strcpy (*buf + *size, str);
84 char *marc_to_str (Fml fml, Iso2709Rec rec)
86 struct iso2709_dir *dir;
87 static char *buf = NULL;
91 add_string ("{", &buf, &max, &size);
92 for (dir = rec->directory; dir; dir=dir->next)
94 struct iso2709_field *fields;
96 add_string ("{\'", &buf, &max, &size);
97 add_string (dir->tag, &buf, &max, &size);
98 add_string ("\'",&buf, &max, &size);
101 add_string ("\'", &buf, &max, &size);
102 add_string (dir->indicator, &buf, &max, &size);
103 add_string ("\'", &buf, &max, &size);
106 add_string ("{}", &buf, &max, &size);
107 add_string ("{", &buf, &max, &size);
108 for (fields = dir->fields; fields; fields=fields->next)
110 add_string ("{", &buf, &max, &size);
111 if (fields->identifier)
113 add_string ("\'", &buf, &max, &size);
114 add_string (fields->identifier, &buf, &max, &size);
115 add_string ("\'", &buf, &max, &size);
118 add_string ("{}", &buf, &max, &size);
119 add_string (" \'", &buf, &max, &size);
120 add_string (fields->data, &buf, &max, &size);
121 add_string ("\'}", &buf, &max, &size);
123 add_string ("}}\n", &buf, &max, &size);
125 add_string ("}", &buf, &max, &size);