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 bool no_triplets_bo_g = false;
18 char const* defined_ch_c_l = 0;
20 // ugh, another global
22 find_file( String str )
27 // ugh, copied from warn.cc, cannot use
29 message( String message_str, char const* context_ch_c_l )
31 String str = "mi2mu: ";
32 Source_file* sourcefile_l = source_l_g->sourcefile_l( context_ch_c_l );
34 str += sourcefile_l->file_line_no_str(context_ch_c_l) + String(": ");
39 str += sourcefile_l->error_str( context_ch_c_l );
41 // if ( busy_parsing() )
42 cerr << endl; // until we have fine output manager...
47 warning( String message_str, char const* context_ch_c_l )
49 message( "warning: " + message_str, context_ch_c_l );
53 error( String message_str, char const* context_ch_c_l )
55 message( message_str, context_ch_c_l );
56 // since when exits error again?
57 // i-d say: error: errorlevel |= 1; -> no output upon error
58 // warning: recovery -> output (possibly wrong)
60 midi_lexer_l_g->errorlevel_i_ |= 1;
67 "--debug, -d be really verbose\n"
68 "--help, -h this help\n"
69 "--include=DIR, -I DIR add DIR to search path\n"
70 "--no-triplets, -n assume no triplets\n"
71 "--output=FILE, -o FILE set FILE as default output\n"
72 "--quiet, -q be quiet\n"
73 "--verbose, -v be verbose\n"
74 "--warranty, -w show warranty & copyright\n"
81 mtor << version_str() << endl;
89 "Mi2mu, translate midi to mudela.\n"
90 "Copyright (C) 1997 by\n"
91 " Han-Wen Nienhuys <hanwen@stack.nl>\n"
93 " Jan Nieuwenhuizen <jan@digicash.com>\n"
94 // " Mats Bengtsson <matsb@s3.kth.se>\n"
96 " This program is free software; you can redistribute it and/or\n"
97 "modify it under the terms of the GNU General Public License version 2\n"
98 "as published by the Free Software Foundation.\n"
100 " This program is distributed in the hope that it will be useful,\n"
101 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
102 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
103 "General Public License for more details.\n"
105 " You should have received a copy (refer to the file COPYING) of the\n"
106 "GNU General Public License along with this program; if not, write to\n"
107 "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
112 main( int argc_i, char* argv_sz_a[] )
114 Long_option_init long_option_init_a[] = {
117 // 1, "include", 'I',
118 0, "no-triplets", 'n',
125 Getopt_long getopt_long( argc_i, argv_sz_a, long_option_init_a );
129 while ( Long_option_init* long_option_init_p = getopt_long() )
130 switch ( long_option_init_p->shortname ) {
132 level_ver = DEBUG_ver;
139 // path->push( getopt_long.optarg );
142 no_triplets_bo_g = true;
145 output_str = getopt_long.optarg;
148 level_ver = QUIET_ver;
151 level_ver = VERBOSE_ver;
163 while ( ( arg_sz = getopt_long.get_next_arg() ) ) {
164 My_midi_parser midi_parser( arg_sz );
165 int error_i = midi_parser.parse();
168 if ( !output_str.length_i() ) {
169 output_str = String( arg_sz ) + ".ly";
170 // i-m sure there-s already some routine for this
171 int name_i; // too bad we can-t declare local to if
172 if ( ( name_i = output_str.index_last_i( '/' ) ) != -1 )
173 output_str = output_str.mid_str( name_i + 1, INT_MAX );
175 error_i = midi_parser.output_mudela( output_str );