25 static void get_fname_from_path(
char* fname,
const char* path) {
27 char* p = (
char*)&path[n - 1];
28 while (path < p && (*p !=
'\\') && (*p !=
'/')) p--;
29 if ((*p ==
'\\') || (*p ==
'/')) p++;
36 static int input_block_id() {
41 printf(
"block# ? (h:show selectable block id, e:exit) > ");
43 fgets(buff,
sizeof(buff), stdin);
49 }
else if (c ==
'e') {
52 if (sscanf(buff,
"%d", &block_id) == 1) {
61 printf(
"Not supported block id\n");
63 printf(
"Cannot converting number\n");
84 ccmd_rec(
const char* n,
const char* h,
void (*f)());
113 return (strcmp(a.
name, b.
name) == 0);
128 #define str_cmd_help "h"
129 #define help_cmd_help "show command list"
132 set<ccmd_rec>::iterator iter;
134 printf(
" %8s : %s\n", iter->name, iter->help);
142 #define str_cmd_quit "quit"
143 #define help_cmd_quit "quit"
148 #define str_cmd_save "save"
149 #define help_cmd_save "save"
152 printf(
"save file name >> ");
154 fgets(fname,
sizeof(fname), stdin);
155 fname[strlen(fname) - 1] = 0;
160 printf(
"error in saving..\n");
167 #define str_cmd_open_outfile "open"
168 #define help_cmd_open_outfile "open output file"
171 printf(
"output file? >");
173 fgets(fname,
sizeof(fname), stdin);
174 fname[strlen(fname) - 1] = 0;
176 FILE* fp = fopen(fname,
"w");
178 cout <<
"Cannot open file" << endl;
182 if (
wfp != stdout &&
wfp != stderr) {
184 printf(
"previous output file closed.\n");
188 printf(
"%s is opened.\n", fname);
193 #define str_cmd_close_outfile "close"
194 #define help_cmd_close_outfile "close output file"
196 if (
wfp != stdout &&
wfp != stderr) {
198 printf(
"output file closed.\n");
205 #define str_cmd_write_summary "s"
206 #define help_cmd_write_summary "write summary of loaded neutral data"
211 fprintf(
wfp,
"summary of %s\n", fname);
217 #define str_cmd_write_block "b"
218 #define help_cmd_write_block "write data block"
220 int block_id = input_block_id();
221 if (block_id == 0)
return;
230 #define GENERATE_CODE(x) \
232 ccmd_rec rec(str_##x, help_##x, x); \
233 cmd_list.insert(rec); \
252 set<ccmd_rec>::iterator iter;
255 printf(
"not such command (h:help)\n");
270 printf(
"neu_reporter>");
272 fgets(buff,
sizeof(buff), stdin);
273 buff[strlen(buff) - 1] = 0;
278 printf(
"end of neu reporter\n");
288 cout <<
"Neutral File Reporter Ver.1.0" << endl;
289 cout <<
"Copyright (C) 2005 Noboru Imai" << endl;
290 cout <<
"[usage] " <<
run_name <<
" [NUE file]" << endl;
293 int main(
int argc,
char** argv) {
305 cout << e.
Msg() << endl;
309 cout <<
"command line start..." << endl;