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;
29 void destill_inname (String &name_str_r);
31 Long_option_init theopts[] = {
40 {0, "ignore-version", 'V'},
48 _("Usage: lilypond [options] [mudela-file]\n"
49 "Typeset and or produce midi output from mudela-file or stdin\n"
52 " -d, --debug enable debugging output\n"
53 " -I, --include=DIR add DIR to search path\n"
54 " -i, --init=FILE use FILE as init file\n"
55 " -h, --help this help\n"
56 " -w, --warranty show warranty and copyright\n"
57 " -o, --output=FILE set FILE as default output\n"
58 " -t, --test switch on experimental features\n"
59 " -M, --midi produce midi output only\n"
60 " -V, --ignore-version ignore mudela version\n"
62 "GNU LilyPond was compiled with the following settings:\n")
69 #ifdef STRING_UTILS_INLINED
70 "STRING_UTILS_INLINED "
72 "datadir= " DIR_DATADIR
86 "GNU LilyPond -- The GNU Project music typesetter.\n"
87 "Copyright 1996,97 by\n"
88 " Han-Wen Nienhuys <hanwen@stack.nl>\n"
89 " Jan Nieuwenhuizen <jan@digicash.com>\n"
91 " This program is free software; you can redistribute it and/or\n"
92 "modify it under the terms of the GNU General Public License version 2\n"
93 "as published by the Free Software Foundation.\n"
95 " This program is distributed in the hope that it will be useful,\n"
96 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
97 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
98 "General Public License for more details.\n"
100 " You should have received a copy (refer to the file COPYING) of the\n"
101 "GNU General Public License along with this program; if not, write to\n"
102 "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
107 static File_path path;
110 do_one_file (String init_str, String file_str)
112 if (init_str.length_i () && path.find (init_str).empty_b ())
114 error (_("Can not find `") + init_str +"\'");
117 if (file_str.length_i () && path.find (file_str).empty_b ())
119 error (_("Can not find `") + file_str + "'");
124 source_l_g = &sources;
125 source_l_g->set_path (&path);
127 My_lily_parser parser (source_l_g);
128 parser.set_version_check (version_ignore_b);
129 parser.parse_file (init_str, file_str);
131 if (parser.error_level_i_)
143 main (int argc, char **argv)
145 debug_init(); // should be first
148 // must override (come before) "/usr/local/share/lilypond"!
149 char const * env_l=getenv ("LILYINCLUDE");
155 path.add (String (DIR_DATADIR) + "/init/");
157 path.push (DIR_DATADIR);
159 Getopt_long oparser (argc, argv,theopts);
160 cout << get_version_str() << endl;
161 String init_str ("symbol.ly");
163 while (Long_option_init const * opt = oparser())
165 switch (opt->shortname)
168 experimental_features_global_b = true;
171 set_default_output (oparser.optional_argument_ch_C_);
178 path.push (oparser.optional_argument_ch_C_);
181 init_str = oparser.optional_argument_ch_C_;
188 version_ignore_b = true;
204 while ((arg= oparser.get_next_arg()))
208 do_one_file (init_str,f);
213 do_one_file (init_str, "");
216 return exit_status_i_;
219 /// make input file name: add default extension. "" is stdin.
221 destill_inname (String &name_str_r)
223 if (name_str_r.length_i())
225 if (name_str_r[ 0 ] != '-')
228 split_path (name_str_r,a,b,c,d);
230 // add extension if not present.
233 name_str_r = a+b+c+d;
236 else name_str_r = "";