2 // midi-main.cc -- implement silly main() entry point
3 // should have Root class.
5 // copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
12 Source
* source_l_g
= &source
;
14 Verbose level_ver
= NORMAL_ver
;
17 bool no_triplets_bo_g
= false;
20 char const* defined_ch_c_l
= 0;
22 // ugh, another global
24 find_file( String str
)
29 // ugh, copied from warn.cc, cannot use
31 message( String message_str
, char const* context_ch_c_l
)
34 Source_file
* sourcefile_l
= source_l_g
->sourcefile_l( context_ch_c_l
);
36 str
+= sourcefile_l
->file_line_no_str(context_ch_c_l
) + String(": ");
41 str
+= sourcefile_l
->error_str( context_ch_c_l
);
43 // if ( busy_parsing() )
49 warning( String message_str
, char const* context_ch_c_l
)
51 message( "warning: " + message_str
, context_ch_c_l
);
55 error( String message_str
, char const* context_ch_c_l
)
57 message( message_str
, context_ch_c_l
);
58 // since when exits error again?
59 // i-d say: error: errorlevel |= 1; -> no output upon error
60 // warning: recovery -> output (possibly wrong)
62 midi_lexer_l_g
->errorlevel_i_
|= 1;
69 "--debug, -d be really verbose\n"
70 "--help, -h this help\n"
71 "--include=DIR, -I DIR add DIR to search path\n"
72 "--no-triplets, -n assume no triplets\n"
73 "--output=FILE, -o FILE set FILE as default output\n"
74 "--quiet, -q be quiet\n"
75 "--verbose, -v be verbose\n"
76 "--warranty, -w show warranty & copyright\n"
83 mtor
<< version_str() << endl
;
91 "M2m, translate midi to mudela.\n"
92 "Copyright (C) 1997 by\n"
93 " Han-Wen Nienhuys <hanwen@stack.nl>\n"
95 " Jan Nieuwenhuizen <jan@digicash.com>\n"
96 // " Mats Bengtsson <matsb@s3.kth.se>\n"
98 " This program is free software; you can redistribute it and/or\n"
99 "modify it under the terms of the GNU General Public License version 2\n"
100 "as published by the Free Software Foundation.\n"
102 " This program is distributed in the hope that it will be useful,\n"
103 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
104 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
105 "General Public License for more details.\n"
107 " You should have received a copy (refer to the file COPYING) of the\n"
108 "GNU General Public License along with this program; if not, write to\n"
109 "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
113 // should simply have Root class...
117 return String ( "This is m2m " ) + VERSIONSTR
118 + "/FlowerLib " + FVERSIONSTR
119 + " of " + __DATE__
+ " " + __TIME__
;
123 main( int argc_i
, char* argv_sz_a
[] )
125 Long_option_init long_option_init_a
[] = {
128 // 1, "include", 'I',
129 0, "no-triplets", 'n',
136 Getopt_long
getopt_long( argc_i
, argv_sz_a
, long_option_init_a
);
140 while ( Long_option_init
* long_option_init_p
= getopt_long() )
141 switch ( long_option_init_p
->shortname
) {
143 level_ver
= DEBUG_ver
;
150 // path->push( getopt_long.optarg );
153 no_triplets_bo_g
= true;
156 output_str
= getopt_long
.optarg
;
159 level_ver
= QUIET_ver
;
162 level_ver
= VERBOSE_ver
;
174 while ( ( arg_sz
= getopt_long
.get_next_arg() ) ) {
175 My_midi_parser
midi_parser( arg_sz
);
176 int error_i
= midi_parser
.parse();
179 if ( !output_str
.length_i() ) {
180 output_str
= String( arg_sz
) + ".ly";
181 // i-m sure there-s already some routine for this
182 int name_i
; // too bad we can-t declare local to if
183 if ( ( name_i
= output_str
.index_last_i( '/' ) ) != -1 )
184 output_str
= output_str
.mid_str( name_i
+ 1, INT_MAX
);
186 error_i
= midi_parser
.output_mudela( output_str
);