2 main.cc -- implement main: entrypoints
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
21 #include "my-lily-parser.hh"
23 static bool version_ignore_b = false;
24 Sources* source_global_l = 0;
25 bool no_paper_global_b = false;
27 bool experimental_features_global_b = false;
28 bool postscript_global_b = true;
31 void destill_inname (String &name_str_r);
33 Long_option_init theopts[] = {
42 {0, "no-postscript", 'P'},
43 {0, "ignore-version", 'V'},
51 _("Usage: lilypond [options] [mudela-files]\n"
52 "Typeset and or produce midi output from mudela-file or stdin\n"
55 " -d, --debug enable debugging output\n"
56 " -I, --include=DIR add DIR to search path\n"
57 " -i, --init=FILE use FILE as init file\n"
58 " -h, --help this help\n"
59 " -w, --warranty show warranty and copyright\n"
60 " -o, --output=FILE set FILE as default output\n"
61 " -t, --test switch on experimental features\n"
62 " -M, --no-paper produce midi output only\n"
63 " -V, --ignore-version ignore mudela version\n"
64 " -P, --no-postscript don't use PostScript\n"
66 "GNU LilyPond was compiled with the following settings:\n")
73 #ifdef STRING_UTILS_INLINED
74 "STRING_UTILS_INLINED "
76 "datadir= " DIR_DATADIR
90 "GNU LilyPond -- The GNU Project music typesetter.\n"
91 "Copyright 1996, 97, 98 by\n"
92 " Han-Wen Nienhuys <hanwen@stack.nl>\n"
93 " Jan Nieuwenhuizen <jan@digicash.com>\n"
95 " This program is free software; you can redistribute it and/or\n"
96 "modify it under the terms of the GNU General Public License version 2\n"
97 "as published by the Free Software Foundation.\n"
99 " This program is distributed in the hope that it will be useful,\n"
100 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
101 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
102 "General Public License for more details.\n"
104 " You should have received a copy (refer to the file COPYING) of the\n"
105 "GNU General Public License along with this program; if not, write to\n"
106 "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
111 static File_path path;
114 do_one_file (String init_str, String file_str)
116 if (init_str.length_i () && path.find (init_str).empty_b ())
118 error (_("Can not find `") + init_str +"\'");
121 if (file_str.length_i () && path.find (file_str).empty_b ())
123 error (_("Can not find `") + file_str + "'");
128 source_global_l = &sources;
129 source_global_l->set_path (&path);
131 My_lily_parser parser (source_global_l);
132 parser.set_version_check (version_ignore_b);
133 parser.parse_file (init_str, file_str);
135 if (file_str.length_i() && file_str[0] != '-')
138 split_path (file_str, a, b, c, d);
139 default_outname_base_global = c;
142 default_outname_base_global = "lelie";
144 if (parser.error_level_i_)
158 cout << get_version_str() << endl;
162 main (int argc, char **argv)
165 debug_init(); // should be first
168 // must override (come before) "/usr/local/share/lilypond"!
169 char const *env_sz = getenv ("LILYINCLUDE");
171 path.parse_path (env_sz);
174 path.add (String (DIR_DATADIR) + "/init/");
176 path.push (DIR_DATADIR);
178 Getopt_long oparser (argc, argv,theopts);
179 String init_str ("lily-init.ly");
181 while (Long_option_init const * opt = oparser())
183 switch (opt->shortname)
186 experimental_features_global_b = true;
189 default_outname_base_global = oparser.optional_argument_ch_C_;
196 path.push (oparser.optional_argument_ch_C_);
199 init_str = oparser.optional_argument_ch_C_;
206 version_ignore_b = true;
209 postscript_global_b = false;
215 no_paper_global_b = true;
225 while ((arg= oparser.get_next_arg()))
229 do_one_file (init_str,f);
234 do_one_file (init_str, "");
237 return exit_status_i_;
240 /// make input file name: add default extension. "" is stdin.
242 destill_inname (String &name_str_r)
244 if (name_str_r.length_i())
246 if (name_str_r[ 0 ] != '-')
249 split_path (name_str_r,a,b,c,d);
251 // add extension if not present.
254 name_str_r = a+b+c+d;
257 else name_str_r = "";