1 /* 2 colortail -- output last part of file(s) in color. 3 Copyright (C) 2009 Joakim Andersson <ja@joakimandersson.se> 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 */ 19 20 #ifndef _OptionsParser_h_ 21 #define _OptionsParser_h_ 22 23 #include <getopt.h> 24 25 #define MAX_FILES 100 26 27 28 static struct option long_options[] = 29 { 30 { 31 "follow", 0, 0, 'f' 32 } 33 , 34 { 35 "config", 1, 0, 'k' 36 } 37 , 38 { 39 "nocolors", 0, 0, 'l' 40 } 41 , 42 { 43 "lines", 1, 0, 'n' 44 } 45 , 46 { 47 "version", 0, 0, 'v' 48 } 49 , 50 { 51 "quiet", 0, 0, 'q' 52 } 53 , 54 { 55 "silent", 0, 0, 'q' 56 } 57 , 58 { 59 "help", 0, 0, 'h' 60 } 61 , 62 { 63 0, 0, 0, 0 64 } 65 }; 66 67 68 class Options 69 { 70 public: 71 // attributes 72 int follow; 73 int color; 74 int rows; 75 int verbose; 76 char *cfg_filenames[MAX_FILES]; 77 int nr_cfg_files; 78 int global_cfg_file; 79 80 // methods 81 Options(); 82 ~Options(); 83 }; 84 85 class OptionsParser 86 { 87 private: 88 int check_digits(char *str); 89 char m_error[512]; 90 91 public: 92 OptionsParser(); 93 ~OptionsParser(); 94 95 Options* parse(int argc, char **argv); 96 97 char* get_error_msg(); 98 }; 99 100 #endif 101