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;
28 bool experimental_features_global_b = false;
29 bool postscript_global_b = true;
32 void destill_inname (String &name_str_r);
34 Long_option_init theopts[] = {
43 {0, "no-postscript", 'P'},
44 {0, "ignore-version", 'V'},
52 _("Usage: lilypond [options] [mudela-files]\n"
53 "Typeset and or produce midi output from mudela-file or stdin\n"
56 " -d, --debug enable debugging output\n"
57 " -I, --include=DIR add DIR to search path\n"
58 " -i, --init=FILE use FILE as init file\n"
59 " -h, --help this help\n"
60 " -w, --warranty show warranty and copyright\n"
61 " -o, --output=FILE set FILE as default output\n"
62 " -t, --test switch on experimental features\n"
63 " -M, --no-paper produce midi output only\n"
64 " -V, --ignore-version ignore mudela version\n"
65 " -P, --no-postscript don't use PostScript\n"
67 "GNU LilyPond was compiled with the following settings:\n")
74 #ifdef STRING_UTILS_INLINED
75 "STRING_UTILS_INLINED "
77 "datadir= " DIR_DATADIR
91 "GNU LilyPond -- The GNU Project music typesetter.\n"
92 "Copyright 1996, 97, 98 by\n"
93 " Han-Wen Nienhuys <hanwen@stack.nl>\n"
94 " Jan Nieuwenhuizen <jan@digicash.com>\n"
96 " This program is free software; you can redistribute it and/or\n"
97 "modify it under the terms of the GNU General Public License version 2\n"
98 "as published by the Free Software Foundation.\n"
100 " This program is distributed in the hope that it will be useful,\n"
101 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
102 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
103 "General Public License for more details.\n"
105 " You should have received a copy (refer to the file COPYING) of the\n"
106 "GNU General Public License along with this program; if not, write to\n"
107 "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
112 static File_path path;
115 do_one_file (String init_str, String file_str)
117 if (init_str.length_i () && path.find (init_str).empty_b ())
119 error (_("Can not find `") + init_str +"\'");
122 if (file_str.length_i () && path.find (file_str).empty_b ())
124 error (_("Can not find `") + file_str + "'");
129 source_global_l = &sources;
130 source_global_l->set_path (&path);
132 My_lily_parser parser (source_global_l);
133 parser.set_version_check (version_ignore_b);
134 parser.parse_file (init_str, file_str);
136 if (file_str.length_i () && file_str[0] != '-')
139 split_path (file_str, a, b, c, d);
140 default_outname_base_global = c;
143 default_outname_base_global = "lelie";
145 if (parser.error_level_i_)
159 cout << get_version_str () << endl;
163 main (int argc, char **argv)
166 call_constructors ();
167 debug_init (); // should be first
172 // must override (come before) "/usr/local/share/lilypond"!
173 char const *env_sz = getenv ("LILYINCLUDE");
175 path.parse_path (env_sz);
177 path.add (String (DIR_DATADIR) + "/init/");
179 path.push (DIR_DATADIR);
181 Getopt_long oparser (argc, argv,theopts);
182 String init_str ("lily-init.ly");
184 while (Long_option_init const * opt = oparser ())
186 switch (opt->shortname)
189 experimental_features_global_b = true;
192 default_outname_base_global = oparser.optional_argument_ch_C_;
199 path.push (oparser.optional_argument_ch_C_);
202 init_str = oparser.optional_argument_ch_C_;
209 version_ignore_b = true;
212 postscript_global_b = false;
218 no_paper_global_b = true;
228 while ((arg= oparser.get_next_arg ()))
232 do_one_file (init_str,f);
237 do_one_file (init_str, "");
240 return exit_status_i_;
243 /// make input file name: add default extension. "" is stdin.
245 destill_inname (String &name_str_r)
247 if (name_str_r.length_i ())
249 if (name_str_r[ 0 ] != '-')
252 split_path (name_str_r,a,b,c,d);
254 // add extension if not present.
257 name_str_r = a+b+c+d;
260 else name_str_r = "";