25 static void get_fname_from_path(
char* fname,
size_t fname_size,
28 char* p = (
char*)&path[n - 1];
29 while (path < p && (*p !=
'\\') && (*p !=
'/')) p--;
30 if ((*p ==
'\\') || (*p ==
'/')) p++;
31 snprintf(fname, fname_size,
"%s", p);
37 static int input_block_id() {
42 printf(
"block# ? (h:show selectable block id, e:exit) > ");
44 fgets(buff,
sizeof(buff), stdin);
50 }
else if (c ==
'e') {
53 if (sscanf(buff,
"%d", &block_id) == 1) {
62 printf(
"Not supported block id\n");
64 printf(
"Cannot converting number\n");
85 ccmd_rec(
const char* n,
const char* h,
void (*f)());
97 snprintf(
name,
sizeof(
name),
"%s", n);
102 snprintf(
name,
sizeof(
name),
"%s", n);
103 snprintf(
help,
sizeof(
help),
"%s", h);
114 return (strcmp(a.
name, b.
name) == 0);
129 #define str_cmd_help "h"
130 #define help_cmd_help "show command list"
133 set<ccmd_rec>::iterator iter;
135 printf(
" %8s : %s\n", iter->name, iter->help);
143 #define str_cmd_quit "quit"
144 #define help_cmd_quit "quit"
149 #define str_cmd_save "save"
150 #define help_cmd_save "save"
153 printf(
"save file name >> ");
155 fgets(fname,
sizeof(fname), stdin);
156 fname[strlen(fname) - 1] = 0;
161 printf(
"error in saving..\n");
168 #define str_cmd_open_outfile "open"
169 #define help_cmd_open_outfile "open output file"
172 printf(
"output file? >");
174 fgets(fname,
sizeof(fname), stdin);
175 fname[strlen(fname) - 1] = 0;
177 FILE* fp = fopen(fname,
"w");
179 cout <<
"Cannot open file" << endl;
183 if (
wfp != stdout &&
wfp != stderr) {
185 printf(
"previous output file closed.\n");
189 printf(
"%s is opened.\n", fname);
194 #define str_cmd_close_outfile "close"
195 #define help_cmd_close_outfile "close output file"
197 if (
wfp != stdout &&
wfp != stderr) {
199 printf(
"output file closed.\n");
206 #define str_cmd_write_summary "s"
207 #define help_cmd_write_summary "write summary of loaded neutral data"
210 get_fname_from_path(fname,
sizeof(fname),
data.
neu_file);
212 fprintf(
wfp,
"summary of %s\n", fname);
218 #define str_cmd_write_block "b"
219 #define help_cmd_write_block "write data block"
221 int block_id = input_block_id();
222 if (block_id == 0)
return;
231 #define GENERATE_CODE(x) \
233 ccmd_rec rec(str_##x, help_##x, x); \
234 cmd_list.insert(rec); \
253 set<ccmd_rec>::iterator iter;
256 printf(
"not such command (h:help)\n");
271 printf(
"neu_reporter>");
273 fgets(buff,
sizeof(buff), stdin);
274 buff[strlen(buff) - 1] = 0;
279 printf(
"end of neu reporter\n");
291 cout <<
"Neutral File Reporter Ver.1.0" << endl;
292 cout <<
"Copyright (C) 2005 Noboru Imai" << endl;
293 cout <<
"[usage] " <<
run_name <<
" [NUE file]" << endl;
296 int main(
int argc,
char** argv) {
308 cout << e.
Msg() << endl;
312 cout <<
"command line start..." << endl;
const int NFD_SupportedBlockListSize
const int NFD_SupportedBlockList[]
bool WriteDataBlock(FILE *fp, int id)
virtual void Save(const char *fname)
void WriteSummary(FILE *fp=0)
virtual void Load(const char *fname)
virtual const char * Msg()
int main(int argc, char **argv)
bool operator>(const ccmd_rec &a, const ccmd_rec &b)
bool operator==(const ccmd_rec &a, const ccmd_rec &b)
bool operator<(const ccmd_rec &a, const ccmd_rec &b)
bool execute_command(const char *name)
void set_run_name(char *argv0)