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;
27 void destill_inname( String &name_str_r);
29 Long_option_init theopts[] = {
37 {0, "ignore-version", 'V'},
45 "Usage: lilypond [options] [mudela-file]\n"
46 "Typeset and or produce midi output from mudela-file or stdin\n"
49 " -d, --debug enable debugging output\n"
50 " -I, --include=DIR add DIR to search path\n"
51 " -i, --init=FILE use FILE as init file\n"
52 " -h, --help this help\n"
53 " -w, --warranty show warranty and copyright\n"
54 " -o, --output=FILE set FILE as default output\n"
55 " -M, --midi produce midi output only\n"
56 " -V, --ignore-version ignore mudela version\n"
58 "GNU LilyPond was compiled with the following settings:\n"
65 #ifdef STRING_UTILS_INLINED
66 "STRING_UTILS_INLINED "
68 "datadir= " DIR_DATADIR "\n"
79 "GNU LilyPond, a music typesetter.\n"
80 "Copyright (C) 1996,97 by\n"
81 " Han-Wen Nienhuys <hanwen@stack.nl>\n"
82 " Jan Nieuwenhuizen <jan@digicash.com>\n"
84 " Mats Bengtsson <matsb@s3.kth.se>\n"
85 " Werner Lemberg <xlwy01@uxp1.hrz.uni-dortmund.de>\n"
87 " This program is free software; you can redistribute it and/or\n"
88 "modify it under the terms of the GNU General Public License version 2\n"
89 "as published by the Free Software Foundation.\n"
91 " This program is distributed in the hope that it will be useful,\n"
92 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
93 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
94 "General Public License for more details.\n"
96 " You should have received a copy (refer to the file COPYING) of the\n"
97 "GNU General Public License along with this program; if not, write to\n"
98 "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
103 static File_path path;
106 do_one_file(String init_str, String file_str)
108 if ( init_str != "" && "" == path.find( init_str ) ) {
109 error ( "Can not find `" + init_str +"'");
112 if ( file_str!= "" && path.find( file_str ) == "" ) {
113 error ( "Can not find `" + file_str + "'");
118 source_l_g = &sources;
119 source_l_g->set_path(&path);
121 My_lily_parser parser(source_l_g);
122 parser.set_version_check(version_ignore_b_);
123 parser.parse_file(init_str, file_str);
130 main (int argc, char **argv)
132 debug_init(); // should be first
135 // must override (come before) "/usr/local/share/lilypond"!
136 char const * env_l=getenv("LILYINCLUDE");
141 path.add( String( DIR_DATADIR ) + "/init/" );
143 path.push(DIR_DATADIR );
145 Getopt_long oparser(argc, argv,theopts);
146 cout << get_version_str() << endl;
147 String init_str("symbol.ly");
149 while (Long_option_init * opt = oparser()) {
150 switch ( opt->shortname){
152 set_default_output(oparser.optarg);
159 path.push(oparser.optarg);
162 init_str = oparser.optarg;
169 version_ignore_b_ = true;
185 while ( (arg= oparser.get_next_arg()) ) {
188 do_one_file(init_str,f);
192 do_one_file(init_str, "");
198 /// make input file name: add default extension. "" is stdin.
200 destill_inname( String &name_str_r)
202 if ( name_str_r.length_i() )
204 if( name_str_r[ 0 ] != '-' )
207 split_path(name_str_r,a,b,c,d);
209 // add extension if not present.
212 name_str_r = a+b+c+d;
214 } else name_str_r = "";