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 embedded_mf_global_b = false;
30 bool experimental_features_global_b = false;
31 bool postscript_global_b = true;
34 void destill_inname (String &name_str_r);
36 Long_option_init theopts[] = {
45 {0, "no-postscript", 'P'},
46 {0, "no-timestamps", 'T'},
47 {0, "ignore-version", 'V'},
55 _("Usage: lilypond [options] [mudela-files]\n"
56 "Typeset and or produce midi output from mudela-file or stdin\n"
59 " -d, --debug enable debugging output\n"
60 " -I, --include=DIR add DIR to search path\n"
61 " -i, --init=FILE use FILE as init file\n"
62 " -h, --help this help\n"
63 " -w, --warranty show warranty and copyright\n"
64 " -o, --output=FILE set FILE as default output\n"
65 " -t, --test switch on experimental features\n"
66 " -M, --no-paper produce midi output only\n"
67 " -V, --ignore-version ignore mudela version\n"
68 " -P, --no-postscript don't use PostScript\n"
69 " -T, --no-timestamps don't timestamp the output\n"
71 "GNU LilyPond was compiled with the following settings:\n")
78 #ifdef STRING_UTILS_INLINED
79 "STRING_UTILS_INLINED "
81 "datadir= " DIR_DATADIR
95 "GNU LilyPond -- The GNU Project music typesetter.\n"
96 "Copyright 1996, 97, 98 by\n"
97 " Han-Wen Nienhuys <hanwen@stack.nl>\n"
98 " Jan Nieuwenhuizen <jan@digicash.com>\n"
100 " This program is free software; you can redistribute it and/or\n"
101 "modify it under the terms of the GNU General Public License version 2\n"
102 "as published by the Free Software Foundation.\n"
104 " This program is distributed in the hope that it will be useful,\n"
105 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
106 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
107 "General Public License for more details.\n"
109 " You should have received a copy (refer to the file COPYING) of the\n"
110 "GNU General Public License along with this program; if not, write to\n"
111 "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
116 static File_path path;
119 do_one_file (String init_str, String file_str)
121 if (init_str.length_i () && path.find (init_str).empty_b ())
123 error (_("Can not find `") + init_str +"\'");
126 if (file_str.length_i () && path.find (file_str).empty_b ())
128 error (_("Can not find `") + file_str + "'");
133 source_global_l = &sources;
134 source_global_l->set_path (&path);
136 My_lily_parser parser (source_global_l);
137 parser.set_version_check (version_ignore_b);
138 parser.parse_file (init_str, file_str);
140 if (file_str.length_i () && file_str[0] != '-')
143 split_path (file_str, a, b, c, d);
144 default_outname_base_global = c;
147 default_outname_base_global = "lelie";
149 if (parser.error_level_i_)
163 cout << get_version_str () << endl;
167 main (int argc, char **argv)
170 call_constructors ();
171 debug_init (); // should be first
176 // must override (come before) "/usr/local/share/lilypond"!
177 char const *env_sz = getenv ("LILYINCLUDE");
179 path.parse_path (env_sz);
181 path.add (String (DIR_DATADIR) + "/init/");
183 path.push (DIR_DATADIR);
185 Getopt_long oparser (argc, argv,theopts);
186 String init_str ("lily-init.ly");
188 while (Long_option_init const * opt = oparser ())
190 switch (opt->shortname)
193 experimental_features_global_b = true;
196 default_outname_base_global = oparser.optional_argument_ch_C_;
203 path.push (oparser.optional_argument_ch_C_);
206 init_str = oparser.optional_argument_ch_C_;
213 version_ignore_b = true;
216 postscript_global_b = false;
222 no_paper_global_b = true;
225 no_timestamps_global_b = true;
235 while ((arg= oparser.get_next_arg ()))
239 do_one_file (init_str,f);
244 do_one_file (init_str, "");
247 return exit_status_i_;
250 /// make input file name: add default extension. "" is stdin.
252 destill_inname (String &name_str_r)
254 if (name_str_r.length_i ())
256 if (name_str_r[ 0 ] != '-')
259 split_path (name_str_r,a,b,c,d);
261 // add extension if not present.
264 name_str_r = a+b+c+d;
267 else name_str_r = "";