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 ) ) {
110 error ( "Can not find `" + init_str +"\'");
113 if ( file_str!= "" && path.find( file_str ) == "" ) {
114 error ( "Can not find `" + file_str + "'");
119 source_l_g = &sources;
120 source_l_g->set_path(&path);
122 My_lily_parser parser(source_l_g);
123 parser.set_version_check(version_ignore_b_);
124 parser.parse_file(init_str, file_str);
131 main (int argc, char **argv)
133 debug_init(); // should be first
136 // must override (come before) "/usr/local/share/lilypond"!
137 char const * env_l=getenv("LILYINCLUDE");
142 path.add( String( DIR_DATADIR ) + "/init/" );
144 path.push(DIR_DATADIR );
146 Getopt_long oparser(argc, argv,theopts);
147 cout << get_version_str() << endl;
148 String init_str("symbol.ly");
150 while (Long_option_init const * opt = oparser()) {
151 switch ( opt->shortname){
153 set_default_output(oparser.optional_argument_ch_C_);
160 path.push(oparser.optional_argument_ch_C_);
163 init_str = oparser.optional_argument_ch_C_;
170 version_ignore_b_ = true;
186 while ( (arg= oparser.get_next_arg()) ) {
189 do_one_file(init_str,f);
193 do_one_file(init_str, "");
196 return exit_status_i_;
199 /// make input file name: add default extension. "" is stdin.
201 destill_inname( String &name_str_r)
203 if ( name_str_r.length_i() )
205 if( name_str_r[ 0 ] != '-' )
208 split_path(name_str_r,a,b,c,d);
210 // add extension if not present.
213 name_str_r = a+b+c+d;
215 } else name_str_r = "";