2 // main.cc -- implement silly main() entry point
3 // should have Root class.
5 // copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
10 Sources* source_l_g = &source;
12 Verbose level_ver = NORMAL_ver;
15 char const* defined_ch_C = 0;
17 // ugh, another global
19 find_file( String str )
24 // ugh, copied from warn.cc, cannot use
26 message( String message_str, char const* context_ch_C )
28 String str = "mi2mu: ";
29 Source_file* sourcefile_l = source_l_g->sourcefile_l( context_ch_C );
31 str += sourcefile_l->file_line_no_str(context_ch_C) + String(": ");
36 str += sourcefile_l->error_str( context_ch_C );
38 // if ( busy_parsing() )
39 cerr << endl; // until we have fine output manager...
44 warning( String message_str, char const* context_ch_C )
46 message( "warning: " + message_str, context_ch_C );
50 error( String message_str, char const* context_ch_C )
52 message( message_str, context_ch_C );
53 // since when exits error again?
54 // i-d say: error: errorlevel |= 1; -> no output upon error
55 // warning: recovery -> output (possibly wrong)
57 midi_lexer_l_g->errorlevel_i_ |= 1;
64 "--be-blonde, -b use exact, blonde durations, e.g.: a[385]\n"
65 "--debug, -d be really verbose\n"
66 "--help, -h this help\n"
67 "--include=DIR, -I DIR add DIR to search path\n"
68 "--no-silly, -n assume no triplets and no smaller than 16\n"
69 "--output=FILE, -o FILE set FILE as default output\n"
70 "--quiet, -q be quiet\n"
71 "--verbose, -v be verbose\n"
72 "--warranty, -w show warranty & copyright\n"
79 mtor << mi2mu_version_str() << endl;
87 "Mi2mu, translate midi to mudela.\n"
88 "Copyright (C) 1997 by\n"
89 " Han-Wen Nienhuys <hanwen@stack.nl>\n"
91 " Jan Nieuwenhuizen <jan@digicash.com>\n"
93 " This program is free software; you can redistribute it and/or\n"
94 "modify it under the terms of the GNU General Public License version 2\n"
95 "as published by the Free Software Foundation.\n"
97 " This program is distributed in the hope that it will be useful,\n"
98 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
99 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
100 "General Public License for more details.\n"
102 " You should have received a copy (refer to the file COPYING) of the\n"
103 "GNU General Public License along with this program; if not, write to\n"
104 "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
109 main( int argc_i, char* argv_sz_a[] )
111 Long_option_init long_option_init_a[] = {
122 Getopt_long getopt_long( argc_i, argv_sz_a, long_option_init_a );
126 while ( Long_option_init* long_option_init_p = getopt_long() )
127 switch ( long_option_init_p->shortname ) {
129 Duration_convert::be_blonde_b_s = true;
132 level_ver = DEBUG_ver;
139 Duration_convert::no_double_dots_b_s = false;
140 Duration_convert::no_triplets_b_s = true;
141 Duration_convert::no_smaller_than_i_s = 16;
144 output_str = getopt_long.optarg;
147 level_ver = QUIET_ver;
150 level_ver = VERBOSE_ver;
162 while ( ( arg_sz = getopt_long.get_next_arg() ) ) {
163 My_midi_parser midi_parser( arg_sz, & source );
164 midi_parser_l_g = &midi_parser;
166 int error_i = midi_parser.parse();
169 if ( !output_str.length_i() ) {
170 String d, dir, base, ext;
172 split_path(arg_sz, d, dir, base, ext);
174 output_str = base + ext + ".ly";
176 error_i = midi_parser.output_mudela( output_str );