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 Sources* source_l_g = 0;
24 bool only_midi = false;
25 bool version_ignore_b_ = false;
28 void destill_inname (String &name_str_r);
30 Long_option_init theopts[] = {
38 {0, "ignore-version", 'V'},
46 "Usage: lilypond [options] [mudela-file]\n"
47 "Typeset and or produce midi output from mudela-file or stdin\n"
50 " -d, --debug enable debugging output\n"
51 " -I, --include=DIR add DIR to search path\n"
52 " -i, --init=FILE use FILE as init file\n"
53 " -h, --help this help\n"
54 " -w, --warranty show warranty and copyright\n"
55 " -o, --output=FILE set FILE as default output\n"
56 " -M, --midi produce midi output only\n"
57 " -V, --ignore-version ignore mudela version\n"
59 "GNU LilyPond was compiled with the following settings:\n"
66 #ifdef STRING_UTILS_INLINED
67 "STRING_UTILS_INLINED "
69 "datadir= " DIR_DATADIR
83 "GNU LilyPond -- The GNU Project music typesetter.\n"
84 "Copyright 1996,97 by\n"
85 " Han-Wen Nienhuys <hanwen@stack.nl>\n"
86 " Jan Nieuwenhuizen <jan@digicash.com>\n"
88 " This program is free software; you can redistribute it and/or\n"
89 "modify it under the terms of the GNU General Public License version 2\n"
90 "as published by the Free Software Foundation.\n"
92 " This program is distributed in the hope that it will be useful,\n"
93 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
94 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
95 "General Public License for more details.\n"
97 " You should have received a copy (refer to the file COPYING) of the\n"
98 "GNU General Public License along with this program; if not, write to\n"
99 "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
104 static File_path path;
107 do_one_file (String init_str, String file_str)
109 if (init_str != "" && "" == path.find (init_str))
111 error ("Can not find `" + init_str +"\'");
114 if (file_str!= "" && path.find (file_str) == "")
116 error ("Can not find `" + file_str + "'");
121 source_l_g = &sources;
122 source_l_g->set_path (&path);
124 My_lily_parser parser (source_l_g);
125 parser.set_version_check (version_ignore_b_);
126 parser.parse_file (init_str, file_str);
127 exit_status_i_ |= parser.error_level_i_;
134 main (int argc, char **argv)
136 debug_init(); // should be first
139 // must override (come before) "/usr/local/share/lilypond"!
140 char const * env_l=getenv ("LILYINCLUDE");
146 path.add (String (DIR_DATADIR) + "/init/");
148 path.push (DIR_DATADIR);
150 Getopt_long oparser (argc, argv,theopts);
151 cout << get_version_str() << endl;
152 String init_str ("symbol.ly");
154 while (Long_option_init const * opt = oparser())
156 switch (opt->shortname)
159 set_default_output (oparser.optional_argument_ch_C_);
166 path.push (oparser.optional_argument_ch_C_);
169 init_str = oparser.optional_argument_ch_C_;
176 version_ignore_b_ = true;
192 while ((arg= oparser.get_next_arg()))
196 do_one_file (init_str,f);
201 do_one_file (init_str, "");
204 return exit_status_i_;
207 /// make input file name: add default extension. "" is stdin.
209 destill_inname (String &name_str_r)
211 if (name_str_r.length_i())
213 if (name_str_r[ 0 ] != '-')
216 split_path (name_str_r,a,b,c,d);
218 // add extension if not present.
221 name_str_r = a+b+c+d;
224 else name_str_r = "";