2 main.cc -- implement main: entrypoints
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
22 #include "my-lily-parser.hh"
24 static bool version_ignore_b = false;
25 Sources* source_global_l = 0;
26 bool no_paper_global_b = false;
27 bool no_timestamps_global_b = false;
29 bool experimental_features_global_b = false;
33 void destill_inname (String &name_str_r);
35 Long_option_init theopts[] = {
45 {0, "no-timestamps", 'T'},
46 {0, "ignore-version", 'V'},
54 _("Usage: lilypond [options] [mudela-files]\n"
55 "Typeset and or produce midi output from mudela-file or stdin\n"
58 " -d, --debug enable debugging output\n"
59 " -I, --include=DIR add DIR to search path\n"
60 " -i, --init=FILE use FILE as init file\n"
61 " -h, --help this help\n"
62 " -w, --warranty show warranty and copyright\n"
63 " -o, --output=FILE set FILE as default output\n"
64 " -t, --test switch on experimental features\n"
65 " -M, --no-paper produce midi output only\n"
66 " -V, --ignore-version ignore mudela version\n"
68 " -T, --no-timestamps don't timestamp the output\n"
70 "GNU LilyPond was compiled with the following settings:\n")
77 #ifdef STRING_UTILS_INLINED
78 "STRING_UTILS_INLINED "
80 "datadir= " DIR_DATADIR
94 "GNU LilyPond -- The GNU Project music typesetter.\n"
95 "Copyright 1996, 97, 98 by\n"
96 " Han-Wen Nienhuys <hanwen@stack.nl>\n"
97 " Jan Nieuwenhuizen <jan@digicash.com>\n"
99 " This program is free software; you can redistribute it and/or\n"
100 "modify it under the terms of the GNU General Public License version 2\n"
101 "as published by the Free Software Foundation.\n"
103 " This program is distributed in the hope that it will be useful,\n"
104 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
105 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
106 "General Public License for more details.\n"
108 " You should have received a copy (refer to the file COPYING) of the\n"
109 "GNU General Public License along with this program; if not, write to\n"
110 "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
115 static File_path path;
118 do_one_file (String init_str, String file_str)
120 if (init_str.length_i () && path.find (init_str).empty_b ())
122 error (_("Can not find `") + init_str +"\'");
125 if (file_str.length_i () && path.find (file_str).empty_b ())
127 error (_("Can not find `") + file_str + "'");
132 source_global_l = &sources;
133 source_global_l->set_path (&path);
135 My_lily_parser parser (source_global_l);
136 parser.set_version_check (version_ignore_b);
137 parser.parse_file (init_str, file_str);
139 if (file_str.length_i () && file_str[0] != '-')
142 split_path (file_str, a, b, c, d);
143 default_outname_base_global = c;
146 default_outname_base_global = "lelie";
148 if (parser.error_level_i_)
162 cout << get_version_str () << endl;
166 main (int argc, char **argv)
169 call_constructors ();
170 debug_init (); // should be first
175 // must override (come before) "/usr/local/share/lilypond"!
176 char const *env_sz = getenv ("LILYINCLUDE");
178 path.parse_path (env_sz);
180 path.add (String (DIR_DATADIR) + "/init/");
182 path.push (DIR_DATADIR);
184 Getopt_long oparser (argc, argv,theopts);
185 String init_str ("lily-init.ly");
187 while (Long_option_init const * opt = oparser ())
189 switch (opt->shortname)
192 experimental_features_global_b = true;
195 default_outname_base_global = oparser.optional_argument_ch_C_;
202 path.push (oparser.optional_argument_ch_C_);
205 init_str = oparser.optional_argument_ch_C_;
212 version_ignore_b = true;
218 no_paper_global_b = true;
221 no_timestamps_global_b = true;
231 while ((arg= oparser.get_next_arg ()))
235 do_one_file (init_str,f);
240 do_one_file (init_str, "");
243 return exit_status_i_;
246 /// make input file name: add default extension. "" is stdin.
248 destill_inname (String &name_str_r)
250 if (name_str_r.length_i ())
252 if (name_str_r[ 0 ] != '-')
255 split_path (name_str_r,a,b,c,d);
257 // add extension if not present.
260 name_str_r = a+b+c+d;
263 else name_str_r = "";