2 // midi-main.cc -- implement silly main() entry point
3 // should have Root class.
5 // copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
11 #include "fversion.hh"
15 #include "sourcefile.hh"
16 #include "midi-main.hh"
18 #include "midi-event.hh"
19 #include "midi-track.hh"
20 #include "my-midi-lexer.hh"
21 #include "my-midi-parser.hh"
24 Source* source_l_g = &source;
26 Verbose level_ver = NORMAL_ver;
29 char const* defined_ch_c_l = 0;
31 // ugh, another global
33 find_file( String str )
38 // ugh, copied from warn.cc, cannot use
40 message( String message_str, char const* context_ch_c_l )
43 Source_file* sourcefile_l = source_l_g->sourcefile_l( context_ch_c_l );
45 str += sourcefile_l->file_line_no_str(context_ch_c_l) + String(": ");
50 str += sourcefile_l->error_str( context_ch_c_l );
52 // if ( busy_parsing() )
58 warning( String message_str, char const* context_ch_c_l )
60 message( "warning: " + message_str, context_ch_c_l );
64 error( String message_str, char const* context_ch_c_l )
66 message( message_str, context_ch_c_l );
67 // since when exits error again?
68 // i-d say: error: errorlevel |= 1; -> no output upon error
69 // warning: recovery -> output (possibly wrong)
71 midi_lexer_l_g->errorlevel_i_ |= 1;
78 "--debug, -d be really verbose\n"
79 "--help, -h This help\n"
80 "--include, -I add to file search path.\n"
81 "--output, -o set default output\n"
82 "--quiet, -q be quiet\n"
83 "--verbose, -v be verbose\n"
84 "--warranty, -w show warranty & copyright\n"
91 mtor << "This is m2m " << VERSIONSTR << "/FlowerLib " << FVERSIONSTR
92 << " of " << __DATE__ << " " << __TIME__ << endl;
100 "M2m, translate midi to mudela.\n"
101 "Copyright (C) 1997 by\n"
102 " Han-Wen Nienhuys <hanwen@stack.nl>\n"
104 " Jan Nieuwenhuizen <jan@digicash.com>\n"
105 // " Mats Bengtsson <matsb@s3.kth.se>\n"
107 " This program is free software; you can redistribute it and/or\n"
108 "modify it under the terms of the GNU General Public License version 2\n"
109 "as published by the Free Software Foundation.\n"
111 " This program is distributed in the hope that it will be useful,\n"
112 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
113 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
114 "General Public License for more details.\n"
116 " You should have received a copy (refer to the file COPYING) of the\n"
117 "GNU General Public License along with this program; if not, write to\n"
118 "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
123 main( int argc_i, char* argv_sz_a[] )
125 long_option_init long_option_init_a[] = {
128 // 1, "include", 'I',
135 Getopt_long getopt_long( argc_i, argv_sz_a, long_option_init_a );
139 while ( long_option_init* long_option_init_p = getopt_long() )
140 switch ( long_option_init_p->shortname ) {
142 level_ver = DEBUG_ver;
149 // path->push( getopt_long.optarg );
152 output_str = getopt_long.optarg;
155 level_ver = QUIET_ver;
158 level_ver = VERBOSE_ver;
170 while ( ( arg_sz = getopt_long.get_next_arg() ) ) {
171 My_midi_parser midi_parser( arg_sz );
172 int error_i = midi_parser.parse();
175 error_i = midi_parser.output( output_str );