2 main.cc -- implement main: entrypoints
4 source file of the 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 extern void parse_file(String,String);
28 destill_inname( String &name_str_r);
29 Long_option_init theopts[] = {
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"
56 "LilyPond was compiled with the following settings:\n"
63 #ifdef STRING_UTILS_INLINED
64 "STRING_UTILS_INLINED "
66 "datadir= " DIR_DATADIR "\n"
77 "LilyPond, a music typesetter.\n"
78 "Copyright (C) 1996,97 by\n"
79 " Han-Wen Nienhuys <hanwen@stack.nl>\n"
80 " Jan Nieuwenhuizen <jan@digicash.com>\n"
82 " Mats Bengtsson <matsb@s3.kth.se>\n"
84 " This program is free software; you can redistribute it and/or\n"
85 "modify it under the terms of the GNU General Public License version 2\n"
86 "as published by the Free Software Foundation.\n"
88 " This program is distributed in the hope that it will be useful,\n"
89 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
90 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
91 "General Public License for more details.\n"
93 " You should have received a copy (refer to the file COPYING) of the\n"
94 "GNU General Public License along with this program; if not, write to\n"
95 "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
99 static File_path * path =0;
102 path = new File_path(String(DIR_DATADIR)+"/init/");
103 path->push(DIR_DATADIR );
112 do_one_file(String init_str, String file_str)
114 source_l_g = new Sources;
115 source_l_g->set_path(path);
116 My_lily_parser parser(source_l_g);
117 parser.parse_file(init_str, file_str);
124 main (int argc, char **argv)
126 Getopt_long oparser(argc, argv,theopts);
127 cout << get_version_str() << endl;
128 String init_str("symbol.ini");
130 while (Long_option_init * opt = oparser()) {
131 switch ( opt->shortname){
133 set_default_output(oparser.optarg);
140 path->push(oparser.optarg);
143 init_str = oparser.optarg;
163 while ( (arg= oparser.get_next_arg()) ) {
166 do_one_file(init_str,f);
170 do_one_file(init_str, "");
178 return path->find(f);
181 /// make input file name: add default extension. "" is stdin.
183 destill_inname( String &name_str_r)
185 if ( name_str_r.length_i() )
187 if( name_str_r[ 0 ] != '-' )
190 split_path(name_str_r,a,b,c,d);
192 // add extension if not present.
195 name_str_r = a+b+c+d;
197 } else name_str_r = "";