2 // main.cc -- implement silly main() entry point
3 // should have Root class.
5 // copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
10 Source* source_l_g = &source;
12 Verbose level_ver = NORMAL_ver;
15 char const* defined_ch_c_l = 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_l )
28 String str = "mi2mu: ";
29 Source_file* sourcefile_l = source_l_g->sourcefile_l( context_ch_c_l );
31 str += sourcefile_l->file_line_no_str(context_ch_c_l) + String(": ");
36 str += sourcefile_l->error_str( context_ch_c_l );
38 // if ( busy_parsing() )
39 cerr << endl; // until we have fine output manager...
44 warning( String message_str, char const* context_ch_c_l )
46 message( "warning: " + message_str, context_ch_c_l );
50 error( String message_str, char const* context_ch_c_l )
52 message( message_str, context_ch_c_l );
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 << 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"
92 // " Mats Bengtsson <matsb@s3.kth.se>\n"
94 " This program is free software; you can redistribute it and/or\n"
95 "modify it under the terms of the GNU General Public License version 2\n"
96 "as published by the Free Software Foundation.\n"
98 " This program is distributed in the hope that it will be useful,\n"
99 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
100 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
101 "General Public License for more details.\n"
103 " You should have received a copy (refer to the file COPYING) of the\n"
104 "GNU General Public License along with this program; if not, write to\n"
105 "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
110 main( int argc_i, char* argv_sz_a[] )
112 Long_option_init long_option_init_a[] = {
116 // 1, "include", 'I',
124 Getopt_long getopt_long( argc_i, argv_sz_a, long_option_init_a );
128 while ( Long_option_init* long_option_init_p = getopt_long() )
129 switch ( long_option_init_p->shortname ) {
131 Duration_convert::be_blonde_b_s = true;
134 level_ver = DEBUG_ver;
141 // path->push( getopt_long.optarg );
144 Duration_convert::no_double_dots_b_s = false;
145 Duration_convert::no_triplets_b_s = true;
146 Duration_convert::no_smaller_than_i_s = 16;
149 output_str = getopt_long.optarg;
152 level_ver = QUIET_ver;
155 level_ver = VERBOSE_ver;
167 while ( ( arg_sz = getopt_long.get_next_arg() ) ) {
168 My_midi_parser midi_parser( arg_sz );
169 int error_i = midi_parser.parse();
172 if ( !output_str.length_i() ) {
173 output_str = String( arg_sz ) + ".ly";
174 // i-m sure there-s already some routine for this
175 int name_i; // too bad we can-t declare local to if
176 if ( ( name_i = output_str.index_last_i( '/' ) ) != -1 )
177 output_str = output_str.mid_str( name_i + 1, INT_MAX );
179 error_i = midi_parser.output_mudela( output_str );