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;
27 destill_inname( String &name_str_r);
28 Long_option_init theopts[] = {
43 "Usage: lilypond [options] [mudela-file]\n"
44 "Typeset and or produce midi output from mudela-file or stdin\n"
47 " -d, --debug enable debugging output\n"
48 " -I, --include=DIR add DIR to search path\n"
49 " -i, --init=FILE use FILE as init file\n"
50 " -h, --help this help\n"
51 " -w, --warranty show warranty and copyright\n"
52 " -o, --output=FILE set FILE as default output\n"
53 " -M, --midi produce midi output only\n"
55 "LilyPond was compiled with the following settings:\n"
62 #ifdef STRING_UTILS_INLINED
63 "STRING_UTILS_INLINED "
65 "datadir= " DIR_DATADIR "\n"
76 "LilyPond, a music typesetter.\n"
77 "Copyright (C) 1996,97 by\n"
78 " Han-Wen Nienhuys <hanwen@stack.nl>\n"
79 " Jan Nieuwenhuizen <jan@digicash.com>\n"
81 " Mats Bengtsson <matsb@s3.kth.se>\n"
83 " This program is free software; you can redistribute it and/or\n"
84 "modify it under the terms of the GNU General Public License version 2\n"
85 "as published by the Free Software Foundation.\n"
87 " This program is distributed in the hope that it will be useful,\n"
88 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
89 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
90 "General Public License for more details.\n"
92 " You should have received a copy (refer to the file COPYING) of the\n"
93 "GNU General Public License along with this program; if not, write to\n"
94 "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
98 static File_path * path_l =0;
101 do_one_file(String init_str, String file_str)
104 source_l_g = &sources;
105 source_l_g->set_path(path_l);
107 My_lily_parser parser(source_l_g);
108 parser.parse_file(init_str, file_str);
115 main (int argc, char **argv)
117 debug_init(); // should be first
118 File_path path(String(DIR_DATADIR)+"/init/") ;
120 path_l->push(DIR_DATADIR );
122 char const * env_l=getenv("LILYINCLUDE");
127 Getopt_long oparser(argc, argv,theopts);
128 cout << get_version_str() << endl;
129 String init_str("symbol.ini");
131 while (Long_option_init * opt = oparser()) {
132 switch ( opt->shortname){
134 set_default_output(oparser.optarg);
141 path.push(oparser.optarg);
144 init_str = oparser.optarg;
164 while ( (arg= oparser.get_next_arg()) ) {
167 do_one_file(init_str,f);
171 do_one_file(init_str, "");
177 /// make input file name: add default extension. "" is stdin.
179 destill_inname( String &name_str_r)
181 if ( name_str_r.length_i() )
183 if( name_str_r[ 0 ] != '-' )
186 split_path(name_str_r,a,b,c,d);
188 // add extension if not present.
191 name_str_r = a+b+c+d;
193 } else name_str_r = "";