Canola
0.8.D001
|
00001 // 00002 // canola - canon canola 1614p emulator 00003 // Copyright (C) 2011 Peter Miller 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License, version 3, as 00007 // published by the Free Software Foundation. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License along 00015 // with this program. If not, see <http://www.gnu.org/licenses/>. 00016 // 00017 00018 #include <lib/ac/stdio.h> 00019 #include <lib/ac/stdlib.h> 00020 #include <lib/ac/unistd.h> 00021 #include <libexplain/output.h> 00022 #include <libexplain/program_name.h> 00023 #include <cairomm/surface.h> 00024 00025 #include <lib/calculator/asm.h> 00026 #include <lib/lexer.h> 00027 #include <lib/print_version.h> 00028 #include <lib/program_card/functor/image.h> 00029 00030 00031 static void 00032 usage(void) 00033 { 00034 const char *prog = explain_program_name_get(); 00035 fprintf(stderr, "Usage: %s [ <option>... ]\n", prog); 00036 fprintf(stderr, " %s -V\n", prog); 00037 exit(1); 00038 } 00039 00040 00041 int 00042 main(int argc, char **argv) 00043 { 00044 for (;;) 00045 { 00046 int c = getopt(argc, argv, "I:V"); 00047 if (c == EOF) 00048 break; 00049 switch (c) 00050 { 00051 case 'I': 00052 lexer::search_path_append(optarg); 00053 break; 00054 00055 case 'V': 00056 print_version(); 00057 return 0; 00058 00059 default: 00060 usage(); 00061 } 00062 } 00063 if (optind + 2 != argc) 00064 usage(); 00065 00066 std::string ifn(argv[optind]); 00067 std::string ofn(argv[optind + 1]); 00068 00069 calculator::pointer foo = calculator_asm::create(); 00070 foo->program_mode_set(calculator::program_mode_learn); 00071 foo->load_program(ifn, false); 00072 program_card_functor_image::pointer pcfp = 00073 program_card_functor_image::factory(ofn); 00074 foo->program_card_walk(*pcfp); 00075 00076 return EXIT_SUCCESS; 00077 }