2 * Copyright (c) 1995, the EUROPAGATE consortium (see below).
4 * The EUROPAGATE consortium members are:
6 * University College Dublin
7 * Danmarks Teknologiske Videnscenter
8 * An Chomhairle Leabharlanna
9 * Consejo Superior de Investigaciones Cientificas
11 * Permission to use, copy, modify, distribute, and sell this software and
12 * its documentation, in whole or in part, for any purpose, is hereby granted,
15 * 1. This copyright and permission notice appear in all copies of the
16 * software and its documentation. Notices of copyright or attribution
17 * which appear at the beginning of any file must remain unchanged.
19 * 2. The names of EUROPAGATE or the project partners may not be used to
20 * endorse or promote products derived from this software without specific
21 * prior written permission.
23 * 3. Users of this software (implementors and gateway operators) agree to
24 * inform the EUROPAGATE consortium of their use of the software. This
25 * information will be used to evaluate the EUROPAGATE project and the
26 * software, and to plan further developments. The consortium may use
27 * the information in later publications.
29 * 4. Users of this software agree to make their best efforts, when
30 * documenting their use of the software, to acknowledge the EUROPAGATE
31 * consortium, and the role played by the software in their work.
33 * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
34 * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
35 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
36 * IN NO EVENT SHALL THE EUROPAGATE CONSORTIUM OR ITS MEMBERS BE LIABLE
37 * FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF
38 * ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
39 * OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND
40 * ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
41 * USE OR PERFORMANCE OF THIS SOFTWARE.
45 * FML interpreter. Europagate, 1995
48 * Revision 1.9 1995/05/16 09:39:35 adam
51 * Revision 1.8 1995/03/02 08:06:10 adam
52 * Fml function strsub implemented. New test files marc[45].fml.
53 * New test options in fmltest.
55 * Revision 1.7 1995/02/23 08:32:06 adam
58 * Revision 1.5 1995/02/10 15:50:56 adam
59 * MARC interface implemented. Minor bugs fixed. fmltest can
60 * be used to format single MARC records. New function '\list'
63 * Revision 1.4 1995/02/09 16:06:08 adam
64 * FML can be called from the outside multiple times by the functions:
65 * fml_exec_call and fml_exec_call_str.
66 * An interactive parameter (-i) to fmltest starts a shell-like
67 * interface to FML by using the fml_exec_call_str function.
69 * Revision 1.3 1995/02/09 13:07:15 adam
70 * Nodes are freed now. Many bugs fixed.
72 * Revision 1.2 1995/02/07 16:09:24 adam
73 * The \ character is no longer INCLUDED when terminating a token.
74 * Major changes in tokenization routines. Bug fixes in expressions
75 * with lists (fml_sub0).
77 * Revision 1.1.1.1 1995/02/06 13:48:10 adam
78 * First version of the FML interpreter. It's slow and memory isn't
79 * freed properly. In particular, the FML nodes aren't released yet.
92 static int inf_read (void)
97 int main (int argc, char **argv)
103 const char *iso2709_fname = NULL;
104 const char *format_func = NULL;
105 int number_of_records = 10000;
114 if (argv[0][1] == 'd')
116 else if (argv[0][1] == 'm')
118 else if (argv[0][1] == 'i')
120 else if (argv[0][1] == 's')
122 else if (argv[0][1] == 'n')
126 number_of_records = atoi (*++argv);
130 else if (argv[0][1] == '2')
134 iso2709_fname = *++argv;
136 format_func = *++argv;
141 fprintf (stderr, "missing marcfile and format\n");
147 fprintf (stderr, "unknown option `%s'\n", *argv);
154 inf = fopen (*argv, "r");
157 fprintf (stderr, "cannot open FML file `%s'\n", *argv);
160 fml->read_func = inf_read;
161 fml_preprocess (fml);
168 fml_preprocess (fml);
171 else if (iso2709_fname)
175 const char *nargv[5];
179 inf = fopen (iso2709_fname, "r");
182 fprintf (stderr, "cannot open %s\n", iso2709_fname);
185 while (no < number_of_records && (buf = iso2709_read (inf)))
187 rec = iso2709_cvt (buf);
190 nargv[1] = format_func;
191 nargv[2] = " \\list";
193 nargv[3]= marc_to_str (fml, rec);
195 printf ("\n[%s]\n", nargv[3]);
197 fml_exec_call_argv (fml, nargv);
211 const char *nargv[4];
216 if (!fgets (arg, 127, stdin))
218 if ((cp = strchr (arg, '\n')))
222 fml_exec_call_argv (fml, nargv);