| 1 |
#line 559 "../../grecs/build-aux/getopt.m4" |
| 2 |
/* -*- buffer-read-only: t -*- vi: set ro: |
| 3 |
THIS FILE IS GENERATED AUTOMATICALLY. PLEASE DO NOT EDIT. |
| 4 |
*/ |
| 5 |
#line 1 "idxgcide-cli.opt" |
| 6 |
/* This file is part of GNU Dico. -*- c -*- |
| 7 |
Copyright (C) 2012-2024 Sergey Poznyakoff |
| 8 |
|
| 9 |
GNU Dico is free software; you can redistribute it and/or modify |
| 10 |
it under the terms of the GNU General Public License as published by |
| 11 |
the Free Software Foundation; either version 3, or (at your option) |
| 12 |
any later version. |
| 13 |
|
| 14 |
GNU Dico is distributed in the hope that it will be useful, |
| 15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 |
GNU General Public License for more details. |
| 18 |
|
| 19 |
You should have received a copy of the GNU General Public License |
| 20 |
along with GNU Dico. If not, see <http://www.gnu.org/licenses/>. */ |
| 21 |
|
| 22 |
#line 77 "idxgcide-cli.opt" |
| 23 |
#ifdef HAVE_CONFIG_H |
| 24 |
#line 77 |
| 25 |
# include <config.h> |
| 26 |
#line 77 |
| 27 |
#endif |
| 28 |
#line 77 |
| 29 |
#ifdef HAVE_GETOPT_H |
| 30 |
#line 77 |
| 31 |
# include <getopt.h> |
| 32 |
#line 77 |
| 33 |
#endif |
| 34 |
#line 77 |
| 35 |
#include <unistd.h> |
| 36 |
#line 77 |
| 37 |
#include <stdlib.h> |
| 38 |
#line 77 |
| 39 |
#include <grecs.h> |
| 40 |
#line 77 |
| 41 |
#include <grecs/opt.h> |
| 42 |
#line 77 |
| 43 |
#ifndef EX_USAGE |
| 44 |
#line 77 |
| 45 |
# define EX_USAGE 64 |
| 46 |
#line 77 |
| 47 |
#endif |
| 48 |
#line 77 |
| 49 |
/* Option codes */ |
| 50 |
#line 77 |
| 51 |
enum { |
| 52 |
#line 77 |
| 53 |
_OPTION_INIT=255, |
| 54 |
#line 77 "idxgcide-cli.opt" |
| 55 |
OPTION_USAGE, |
| 56 |
#line 77 "idxgcide-cli.opt" |
| 57 |
MAX_OPTION |
| 58 |
#line 77 |
| 59 |
}; |
| 60 |
#line 77 |
| 61 |
#ifdef HAVE_GETOPT_LONG |
| 62 |
#line 77 |
| 63 |
static struct option long_options[] = { |
| 64 |
#line 24 "idxgcide-cli.opt" |
| 65 |
{ "debug", optional_argument, 0, 'd' }, |
| 66 |
#line 30 "idxgcide-cli.opt" |
| 67 |
{ "dry-run", no_argument, 0, 'n' }, |
| 68 |
#line 37 "idxgcide-cli.opt" |
| 69 |
{ "verbose", no_argument, 0, 'v' }, |
| 70 |
#line 43 "idxgcide-cli.opt" |
| 71 |
{ "page-size", required_argument, 0, 'p' }, |
| 72 |
#line 67 "idxgcide-cli.opt" |
| 73 |
{ "file-descriptor", required_argument, 0, '#' }, |
| 74 |
#line 77 "idxgcide-cli.opt" |
| 75 |
{ "help", no_argument, 0, 'h' }, |
| 76 |
#line 77 "idxgcide-cli.opt" |
| 77 |
{ "usage", no_argument, 0, OPTION_USAGE }, |
| 78 |
#line 77 "idxgcide-cli.opt" |
| 79 |
{ "version", no_argument, 0, 'V' }, |
| 80 |
#line 77 "idxgcide-cli.opt" |
| 81 |
{0, 0, 0, 0} |
| 82 |
#line 77 |
| 83 |
}; |
| 84 |
#line 77 |
| 85 |
#endif |
| 86 |
#line 77 |
| 87 |
|
| 88 |
#line 77 |
| 89 |
static struct grecs_opthelp opthelp[] = { |
| 90 |
#line 26 "idxgcide-cli.opt" |
| 91 |
{ |
| 92 |
#line 26 |
| 93 |
#ifdef HAVE_GETOPT_LONG |
| 94 |
#line 26 |
| 95 |
"-d, --debug", |
| 96 |
#line 26 |
| 97 |
#else |
| 98 |
#line 26 |
| 99 |
"-d", |
| 100 |
#line 26 |
| 101 |
#endif |
| 102 |
#line 26 |
| 103 |
N_("LETTERS"), 1, N_("debug mode") }, |
| 104 |
#line 32 "idxgcide-cli.opt" |
| 105 |
{ |
| 106 |
#line 32 |
| 107 |
#ifdef HAVE_GETOPT_LONG |
| 108 |
#line 32 |
| 109 |
"-n, --dry-run", |
| 110 |
#line 32 |
| 111 |
#else |
| 112 |
#line 32 |
| 113 |
"-n", |
| 114 |
#line 32 |
| 115 |
#endif |
| 116 |
#line 32 |
| 117 |
NULL, 0, N_("dry run: do nothing, but print everything") }, |
| 118 |
#line 39 "idxgcide-cli.opt" |
| 119 |
{ |
| 120 |
#line 39 |
| 121 |
#ifdef HAVE_GETOPT_LONG |
| 122 |
#line 39 |
| 123 |
"-v, --verbose", |
| 124 |
#line 39 |
| 125 |
#else |
| 126 |
#line 39 |
| 127 |
"-v", |
| 128 |
#line 39 |
| 129 |
#endif |
| 130 |
#line 39 |
| 131 |
NULL, 0, N_("increase verbosity") }, |
| 132 |
#line 45 "idxgcide-cli.opt" |
| 133 |
{ |
| 134 |
#line 45 |
| 135 |
#ifdef HAVE_GETOPT_LONG |
| 136 |
#line 45 |
| 137 |
"-p, --page-size", |
| 138 |
#line 45 |
| 139 |
#else |
| 140 |
#line 45 |
| 141 |
"-p", |
| 142 |
#line 45 |
| 143 |
#endif |
| 144 |
#line 45 |
| 145 |
N_("NUMBER"), 0, N_("set index page size") }, |
| 146 |
#line 69 "idxgcide-cli.opt" |
| 147 |
{ |
| 148 |
#line 69 |
| 149 |
#ifdef HAVE_GETOPT_LONG |
| 150 |
#line 69 |
| 151 |
"-#, --file-descriptor", |
| 152 |
#line 69 |
| 153 |
#else |
| 154 |
#line 69 |
| 155 |
"-#", |
| 156 |
#line 69 |
| 157 |
#endif |
| 158 |
#line 69 |
| 159 |
N_("DESCR"), 0, N_("modify file at the supplied descriptor") }, |
| 160 |
#line 77 "idxgcide-cli.opt" |
| 161 |
{ NULL, NULL, 0, N_("Other options") }, |
| 162 |
#line 77 "idxgcide-cli.opt" |
| 163 |
{ |
| 164 |
#line 77 |
| 165 |
#ifdef HAVE_GETOPT_LONG |
| 166 |
#line 77 |
| 167 |
"-h, --help", |
| 168 |
#line 77 |
| 169 |
#else |
| 170 |
#line 77 |
| 171 |
"-h", |
| 172 |
#line 77 |
| 173 |
#endif |
| 174 |
#line 77 |
| 175 |
NULL, 0, N_("Give this help list") }, |
| 176 |
#line 77 "idxgcide-cli.opt" |
| 177 |
{ |
| 178 |
#line 77 |
| 179 |
#ifdef HAVE_GETOPT_LONG |
| 180 |
#line 77 |
| 181 |
"--usage", |
| 182 |
#line 77 |
| 183 |
#else |
| 184 |
#line 77 |
| 185 |
"", |
| 186 |
#line 77 |
| 187 |
#endif |
| 188 |
#line 77 |
| 189 |
NULL, 0, N_("Give a short usage message") }, |
| 190 |
#line 77 "idxgcide-cli.opt" |
| 191 |
{ |
| 192 |
#line 77 |
| 193 |
#ifdef HAVE_GETOPT_LONG |
| 194 |
#line 77 |
| 195 |
"-V, --version", |
| 196 |
#line 77 |
| 197 |
#else |
| 198 |
#line 77 |
| 199 |
"-V", |
| 200 |
#line 77 |
| 201 |
#endif |
| 202 |
#line 77 |
| 203 |
NULL, 0, N_("Print program version") }, |
| 204 |
#line 77 "idxgcide-cli.opt" |
| 205 |
}; |
| 206 |
#line 17 "idxgcide-cli.opt" |
| 207 |
|
| 208 |
#line 17 |
| 209 |
|
| 210 |
#line 17 |
| 211 |
#ifndef PACKAGE_URL |
| 212 |
#line 17 |
| 213 |
# define PACKAGE_URL NULL |
| 214 |
#line 17 |
| 215 |
#endif |
| 216 |
#line 17 |
| 217 |
static struct grecs_proginfo proginfo = { |
| 218 |
#line 17 |
| 219 |
"idxgcide", /* progname */ |
| 220 |
#line 17 |
| 221 |
NULL, /* subcommands */ |
| 222 |
#line 17 |
| 223 |
N_("standalone indexer for GCIDE dictionaries"), /* docstring */ |
| 224 |
#line 17 |
| 225 |
N_("DICTDIR [IDXDIR]"), /* args_doc */ |
| 226 |
#line 17 |
| 227 |
opthelp, /* opthelp */ |
| 228 |
#line 17 |
| 229 |
sizeof(opthelp)/sizeof(opthelp[0]), /* optcount */ |
| 230 |
#line 17 |
| 231 |
NULL, /* print_help_hook */ |
| 232 |
#line 17 |
| 233 |
NULL, /* print_version_hook */ |
| 234 |
#line 17 |
| 235 |
PACKAGE_NAME, /* package */ |
| 236 |
#line 17 |
| 237 |
PACKAGE_VERSION, /* version */ |
| 238 |
#line 17 |
| 239 |
NULL, /* license */ |
| 240 |
#line 17 |
| 241 |
"2012-2024",/* copyright_year */ |
| 242 |
#line 17 |
| 243 |
"Free Software Foundation, Inc.", /* copyright_holder */ |
| 244 |
#line 17 |
| 245 |
NULL, /* *authors */ |
| 246 |
#line 17 |
| 247 |
"<" PACKAGE_BUGREPORT ">", /* bug_address */ |
| 248 |
#line 17 |
| 249 |
PACKAGE_URL, /* url */ |
| 250 |
#line 17 |
| 251 |
NULL /* epilogue */ |
| 252 |
#line 17 |
| 253 |
}; |
| 254 |
#line 17 |
| 255 |
|
| 256 |
#line 77 "idxgcide-cli.opt" |
| 257 |
|
| 258 |
#line 77 |
| 259 |
|
| 260 |
|
| 261 |
void |
| 262 |
get_options(int argc, char *argv[], int *index) |
| 263 |
{ |
| 264 |
|
| 265 |
#line 82 |
| 266 |
{ |
| 267 |
#line 82 |
| 268 |
int c; |
| 269 |
#line 82 |
| 270 |
|
| 271 |
#line 82 |
| 272 |
optind = 0; |
| 273 |
#line 82 |
| 274 |
#ifdef HAVE_GETOPT_LONG |
| 275 |
#line 82 |
| 276 |
while ((c = getopt_long(argc, argv, "d::nvp:#:hV", |
| 277 |
#line 82 |
| 278 |
long_options, NULL)) != EOF) |
| 279 |
#line 82 |
| 280 |
#else |
| 281 |
#line 82 |
| 282 |
while ((c = getopt(argc, argv, "d::nvp:#:hV")) != EOF) |
| 283 |
#line 82 |
| 284 |
#endif |
| 285 |
#line 82 |
| 286 |
{ |
| 287 |
#line 82 |
| 288 |
switch (c) |
| 289 |
#line 82 |
| 290 |
{ |
| 291 |
#line 82 |
| 292 |
default: |
| 293 |
#line 82 |
| 294 |
exit(EX_USAGE); exit(EX_USAGE); |
| 295 |
#line 82 |
| 296 |
#line 26 "idxgcide-cli.opt" |
| 297 |
case 'd': |
| 298 |
#line 26 |
| 299 |
{ |
| 300 |
#line 26 |
| 301 |
|
| 302 |
debug_letters = optarg ? optarg : letters; |
| 303 |
|
| 304 |
#line 28 |
| 305 |
break; |
| 306 |
#line 28 |
| 307 |
} |
| 308 |
#line 32 "idxgcide-cli.opt" |
| 309 |
case 'n': |
| 310 |
#line 32 |
| 311 |
{ |
| 312 |
#line 32 |
| 313 |
|
| 314 |
dry_run_option = 1; |
| 315 |
verbose_option++; |
| 316 |
|
| 317 |
#line 35 |
| 318 |
break; |
| 319 |
#line 35 |
| 320 |
} |
| 321 |
#line 39 "idxgcide-cli.opt" |
| 322 |
case 'v': |
| 323 |
#line 39 |
| 324 |
{ |
| 325 |
#line 39 |
| 326 |
|
| 327 |
verbose_option++; |
| 328 |
|
| 329 |
#line 41 |
| 330 |
break; |
| 331 |
#line 41 |
| 332 |
} |
| 333 |
#line 45 "idxgcide-cli.opt" |
| 334 |
case 'p': |
| 335 |
#line 45 |
| 336 |
{ |
| 337 |
#line 45 |
| 338 |
|
| 339 |
char *p; |
| 340 |
idx_header.ihdr_pagesize = strtoul(optarg, &p, 10); |
| 341 |
switch (*p) { |
| 342 |
case 0: |
| 343 |
break; |
| 344 |
case 'g': |
| 345 |
case 'G': |
| 346 |
idx_header.ihdr_pagesize <<= 10; |
| 347 |
case 'm': |
| 348 |
case 'M': |
| 349 |
idx_header.ihdr_pagesize <<= 10; |
| 350 |
case 'k': |
| 351 |
case 'K': |
| 352 |
idx_header.ihdr_pagesize <<= 10; |
| 353 |
break; |
| 354 |
default: |
| 355 |
dico_log(L_ERR, 0, _("not a valid size: %s"), optarg); |
| 356 |
exit(EX_USAGE); |
| 357 |
} |
| 358 |
|
| 359 |
#line 65 |
| 360 |
break; |
| 361 |
#line 65 |
| 362 |
} |
| 363 |
#line 69 "idxgcide-cli.opt" |
| 364 |
case '#': |
| 365 |
#line 69 |
| 366 |
{ |
| 367 |
#line 69 |
| 368 |
|
| 369 |
inherit_fd = atoi(optarg); |
| 370 |
if (inherit_fd <= 0) { |
| 371 |
dico_log(L_ERR, 0, _("bad file descriptor: %s"), optarg); |
| 372 |
exit(EX_USAGE); |
| 373 |
} |
| 374 |
|
| 375 |
#line 75 |
| 376 |
break; |
| 377 |
#line 75 |
| 378 |
} |
| 379 |
#line 77 "idxgcide-cli.opt" |
| 380 |
case 'h': |
| 381 |
#line 77 |
| 382 |
{ |
| 383 |
#line 77 |
| 384 |
|
| 385 |
#line 77 |
| 386 |
grecs_print_help(&proginfo); |
| 387 |
#line 77 |
| 388 |
exit(0); |
| 389 |
#line 77 |
| 390 |
|
| 391 |
#line 77 |
| 392 |
break; |
| 393 |
#line 77 |
| 394 |
} |
| 395 |
#line 77 "idxgcide-cli.opt" |
| 396 |
case OPTION_USAGE: |
| 397 |
#line 77 |
| 398 |
{ |
| 399 |
#line 77 |
| 400 |
|
| 401 |
#line 77 |
| 402 |
grecs_print_usage(&proginfo); |
| 403 |
#line 77 |
| 404 |
exit(0); |
| 405 |
#line 77 |
| 406 |
|
| 407 |
#line 77 |
| 408 |
break; |
| 409 |
#line 77 |
| 410 |
} |
| 411 |
#line 77 "idxgcide-cli.opt" |
| 412 |
case 'V': |
| 413 |
#line 77 |
| 414 |
{ |
| 415 |
#line 77 |
| 416 |
|
| 417 |
#line 77 |
| 418 |
/* Give version */ |
| 419 |
#line 77 |
| 420 |
grecs_print_version(&proginfo, stdout); |
| 421 |
#line 77 |
| 422 |
exit(0); |
| 423 |
#line 77 |
| 424 |
|
| 425 |
#line 77 |
| 426 |
break; |
| 427 |
#line 77 |
| 428 |
} |
| 429 |
|
| 430 |
#line 82 "idxgcide-cli.opt" |
| 431 |
} |
| 432 |
#line 82 |
| 433 |
} |
| 434 |
#line 82 |
| 435 |
*index = optind; |
| 436 |
#line 82 |
| 437 |
} |
| 438 |
#line 82 |
| 439 |
|
| 440 |
} |