2 main.cc -- implement main: entrypoints
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
20 #include "my-lily-parser.hh"
22 Sources* source_l_g = 0;
23 bool only_midi = false;
24 bool version_ignore_b_ = false;
26 void destill_inname( String &name_str_r);
28 Long_option_init theopts[] = {
36 {0, "ignore-version", 'V'},
44 "Usage: lilypond [options] [mudela-file]\n"
45 "Typeset and or produce midi output from mudela-file or stdin\n"
48 " -d, --debug enable debugging output\n"
49 " -I, --include=DIR add DIR to search path\n"
50 " -i, --init=FILE use FILE as init file\n"
51 " -h, --help this help\n"
52 " -w, --warranty show warranty and copyright\n"
53 " -o, --output=FILE set FILE as default output\n"
54 " -M, --midi produce midi output only\n"
55 " -V, --ignore-version ignore mudela version\n"
57 "GNU LilyPond was compiled with the following settings:\n"
64 #ifdef STRING_UTILS_INLINED
65 "STRING_UTILS_INLINED "
67 "datadir= " DIR_DATADIR "\n"
78 "GNU LilyPond, a music typesetter.\n"
79 "Copyright (C) 1996,97 by\n"
80 " Han-Wen Nienhuys <hanwen@stack.nl>\n"
81 " Jan Nieuwenhuizen <jan@digicash.com>\n"
83 " Mats Bengtsson <matsb@s3.kth.se>\n"
85 " This program is free software; you can redistribute it and/or\n"
86 "modify it under the terms of the GNU General Public License version 2\n"
87 "as published by the Free Software Foundation.\n"
89 " This program is distributed in the hope that it will be useful,\n"
90 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
91 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
92 "General Public License for more details.\n"
94 " You should have received a copy (refer to the file COPYING) of the\n"
95 "GNU General Public License along with this program; if not, write to\n"
96 "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
100 static File_path * path_l =0;
103 do_one_file(String init_str, String file_str)
106 source_l_g = &sources;
107 source_l_g->set_path(path_l);
109 My_lily_parser parser(source_l_g);
110 parser.set_version_check(version_ignore_b_);
111 parser.parse_file(init_str, file_str);
118 main (int argc, char **argv)
120 debug_init(); // should be first
125 // must override (come before) "/usr/local/share/lilypond"!
126 char const * env_l=getenv("LILYINCLUDE");
131 path.add( String( DIR_DATADIR ) + "/init/" );
134 path_l->push(DIR_DATADIR );
136 Getopt_long oparser(argc, argv,theopts);
137 cout << get_version_str() << endl;
138 String init_str("symbol.ini");
140 while (Long_option_init * opt = oparser()) {
141 switch ( opt->shortname){
143 set_default_output(oparser.optarg);
150 path.push(oparser.optarg);
153 init_str = oparser.optarg;
160 version_ignore_b_ = true;
176 while ( (arg= oparser.get_next_arg()) ) {
179 do_one_file(init_str,f);
183 do_one_file(init_str, "");
189 /// make input file name: add default extension. "" is stdin.
191 destill_inname( String &name_str_r)
193 if ( name_str_r.length_i() )
195 if( name_str_r[ 0 ] != '-' )
198 split_path(name_str_r,a,b,c,d);
200 // add extension if not present.
203 name_str_r = a+b+c+d;
205 } else name_str_r = "";