1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
|
/**
* @file thcmdline.cxx
* Command line processing module.
*/
/* Copyright (C) 2000 Stacho Mudrak
*
* $Date: $
* $RCSfile: $
* $Revision: $
*
* --------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* --------------------------------------------------------------------
*/
#include "thcmdline.h"
#include "therion.h"
#include "thlogfile.h"
#include "thconfig.h"
//#include <getopt.h>
#include "extern/getopt.h"
#include "thtmpdir.h"
thcmdline::thcmdline()
{
this->version_ds = false;
this->help_ds = false;
this->extern_libs = false;
this->print_state = THPS_NONE;
}
thcmdline::~thcmdline()
{
}
bool thcmdline::get_version_disp_state()
{
return(this->version_ds);
}
bool thcmdline::get_help_disp_state()
{
return(this->help_ds);
}
void thcmdline::process(int argc, char * argv[])
{
// 1. let's search for options
int oc;
int oindex = 0;
static struct option thlong_options[] =
{
{"help",no_argument,NULL,'h'},
{"print-encodings",no_argument,NULL,THPS_ENCODINGS},
{"print-environment",no_argument,NULL,THPS_PATHS},
{"print-init-file",no_argument,NULL,THPS_INIT_FILE},
{"print-library-src",no_argument,NULL,THPS_LIB_SRC},
{"print-tex-encodings",no_argument,NULL,THPS_TEX_ENCODINGS},
{"print-xtherion-src",no_argument,NULL,THPS_XTHERION_SRC},
{"use-extern-libs",no_argument,NULL,THPS_EXTERN_LIBS},
{"version",no_argument,NULL,'v'},
{NULL, 0, NULL, 0}
};
while(1) {
oc = getopt_long (argc, argv, "gduxs:l:qLvhip:",
thlong_options, &oindex);
// no other options detected
if (oc == -1)
break;
switch (oc)
{
case 'd':
thtmp.debug = true;
thtmp.delete_all = false;
break;
case 'h':
this->help_ds = true;
break;
case 'v':
this->version_ds = true;
break;
case 'q':
thverbose_mode = false;
break;
case 'L':
thlog.logging_off();
break;
case 'l':
thlog.logging_on();
thlog.set_file_name(optarg);
break;
case 'g':
thcfg.set_file_state(THCFG_GENERATE);
break;
case 'x':
thcfg.generate_xthcfg = true;
break;
case 'u':
thcfg.set_file_state(THCFG_UPDATE);
break;
case 'i':
thcfg.comments_skip_on();
break;
case 's':
thcfg.set_source_file_name(optarg);
break;
case 'p':
thcfg.set_search_path(optarg);
break;
case THPS_ENCODINGS:
this->print_state = THPS_ENCODINGS;
break;
case THPS_TEX_ENCODINGS:
this->print_state = THPS_TEX_ENCODINGS;
break;
case THPS_XTHERION_SRC:
this->print_state = THPS_XTHERION_SRC;
break;
case THPS_INIT_FILE:
this->print_state = THPS_INIT_FILE;
break;
case THPS_LIB_SRC:
this->print_state = THPS_LIB_SRC;
break;
case THPS_PATHS:
this->print_state = THPS_PATHS;
break;
case THPS_EXTERN_LIBS:
this->extern_libs = true;
break;
}
}
// 2. let's search for program arguments
if (optind < argc)
thcfg.set_file_name(argv[optind++]);
if (optind < argc)
thwarning(("too many input arguments"));
}
int thcmdline::get_print_state()
{
return this->print_state;
}
thcmdline thcmdln;
|