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_l_g = 0;
25 bool only_midi = false;
26 bool experimental_features_global_b = false;
27 bool postscript_global_b = false;
30 void destill_inname (String &name_str_r);
32 Long_option_init theopts[] = {
41 {0, "postscript", 'p'},
42 {0, "ignore-version", 'V'},
50 _("Usage: lilypond [options] [mudela-file]\n"
51 "Typeset and or produce midi output from mudela-file or stdin\n"
54 " -d, --debug enable debugging output\n"
55 " -I, --include=DIR add DIR to search path\n"
56 " -i, --init=FILE use FILE as init file\n"
57 " -h, --help this help\n"
58 " -w, --warranty show warranty and copyright\n"
59 " -o, --output=FILE set FILE as default output\n"
60 " -t, --test switch on experimental features\n"
61 " -M, --midi produce midi output only\n"
62 " -V, --ignore-version ignore mudela version\n"
63 " -p, --postscript try to use PostScript\n"
65 "GNU LilyPond was compiled with the following settings:\n")
72 #ifdef STRING_UTILS_INLINED
73 "STRING_UTILS_INLINED "
75 "datadir= " DIR_DATADIR
89 "GNU LilyPond -- The GNU Project music typesetter.\n"
90 "Copyright 1996,97 by\n"
91 " Han-Wen Nienhuys <hanwen@stack.nl>\n"
92 " Jan Nieuwenhuizen <jan@digicash.com>\n"
94 " This program is free software; you can redistribute it and/or\n"
95 "modify it under the terms of the GNU General Public License version 2\n"
96 "as published by the Free Software Foundation.\n"
98 " This program is distributed in the hope that it will be useful,\n"
99 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
100 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
101 "General Public License for more details.\n"
103 " You should have received a copy (refer to the file COPYING) of the\n"
104 "GNU General Public License along with this program; if not, write to\n"
105 "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
110 static File_path path;
113 do_one_file (String init_str, String file_str)
115 if (init_str.length_i () && path.find (init_str).empty_b ())
117 error (_("Can not find `") + init_str +"\'");
120 if (file_str.length_i () && path.find (file_str).empty_b ())
122 error (_("Can not find `") + file_str + "'");
127 source_l_g = &sources;
128 source_l_g->set_path (&path);
130 My_lily_parser parser (source_l_g);
131 parser.set_version_check (version_ignore_b);
132 parser.parse_file (init_str, file_str);
134 if (parser.error_level_i_)
146 main (int argc, char **argv)
148 debug_init(); // should be first
151 // must override (come before) "/usr/local/share/lilypond"!
152 char const * env_l=getenv ("LILYINCLUDE");
158 path.add (String (DIR_DATADIR) + "/init/");
160 path.push (DIR_DATADIR);
162 Getopt_long oparser (argc, argv,theopts);
163 cout << get_version_str() << endl;
164 String init_str ("lily-init.ly");
166 while (Long_option_init const * opt = oparser())
168 switch (opt->shortname)
171 experimental_features_global_b = true;
174 set_default_output (oparser.optional_argument_ch_C_);
181 path.push (oparser.optional_argument_ch_C_);
184 init_str = oparser.optional_argument_ch_C_;
191 version_ignore_b = true;
194 postscript_global_b = true;
210 while ((arg= oparser.get_next_arg()))
214 do_one_file (init_str,f);
219 do_one_file (init_str, "");
222 return exit_status_i_;
225 /// make input file name: add default extension. "" is stdin.
227 destill_inname (String &name_str_r)
229 if (name_str_r.length_i())
231 if (name_str_r[ 0 ] != '-')
234 split_path (name_str_r,a,b,c,d);
236 // add extension if not present.
239 name_str_r = a+b+c+d;
242 else name_str_r = "";