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 <gtkmm.h> 00022 #include <libexplain/program_name.h> 00023 00024 #include <lib/lexer.h> 00025 #include <lib/print_version.h> 00026 00027 #include <canola/calculator/gnome.h> 00028 #include <canola/gui_search_path.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 Gtk::Main kit(argc, argv); 00045 for (;;) 00046 { 00047 int c = getopt(argc, argv, "I:P:V"); 00048 if (c == EOF) 00049 break; 00050 switch (c) 00051 { 00052 case 'I': 00053 lexer::search_path_append(optarg); 00054 break; 00055 00056 case 'P': 00057 // resource path 00058 gui_search_path.append(optarg); 00059 lexer::search_path_append(optarg); 00060 break; 00061 00062 case 'V': 00063 print_version(); 00064 return 0; 00065 00066 default: 00067 usage(); 00068 } 00069 } 00070 00071 calculator::pointer calc = calculator_gnome::create(); 00072 00073 switch (argc - optind) 00074 { 00075 case 0: 00076 break; 00077 00078 case 1: 00079 { 00080 lexer prog(argv[optind], *calc); 00081 prog.read_and_execute(); 00082 } 00083 break; 00084 00085 default: 00086 usage(); 00087 } 00088 00089 calc->run(); 00090 return EXIT_SUCCESS; 00091 }