Line data Source code
1 : /* -*- buffer-read-only: t -*- vi: set ro:
2 : *
3 : * DO NOT EDIT THIS FILE (rsstats-opts.c)
4 : *
5 : * It has been AutoGen-ed
6 : * From the definitions rsstats-opts.def
7 : * and the template file options
8 : *
9 : * Generated from AutoOpts 42:1:17 templates.
10 : *
11 : * AutoOpts is a copyrighted work. This source file is not encumbered
12 : * by AutoOpts licensing, but is provided under the licensing terms chosen
13 : * by the rsstats author or copyright holder. AutoOpts is
14 : * licensed under the terms of the LGPL. The redistributable library
15 : * (``libopts'') is licensed under the terms of either the LGPL or, at the
16 : * users discretion, the BSD license. See the AutoOpts and/or libopts sources
17 : * for details.
18 : *
19 : * The rsstats program is copyrighted and licensed
20 : * under the following terms:
21 : *
22 : * Copyright (C) 2024 Francois Cerbelle, all rights reserved.
23 : * This is free software. It is licensed for use, modification and
24 : * redistribution under the terms of the GNU General Public License,
25 : * version 3 or later <http://gnu.org/licenses/gpl.html>
26 : *
27 : * rsstats is free software: you can redistribute it and/or modify it
28 : * under the terms of the GNU General Public License as published by the
29 : * Free Software Foundation, either version 3 of the License, or
30 : * (at your option) any later version.
31 : *
32 : * rsstats is distributed in the hope that it will be useful, but
33 : * WITHOUT ANY WARRANTY; without even the implied warranty of
34 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
35 : * See the GNU General Public License for more details.
36 : *
37 : * You should have received a copy of the GNU General Public License along
38 : * with this program. If not, see <http://www.gnu.org/licenses/>.
39 : */
40 :
41 : #ifndef __doxygen__
42 : #define OPTION_CODE_COMPILE 1
43 : #include "rsstats-opts.h"
44 : #include <sys/types.h>
45 : #include <sys/stat.h>
46 :
47 : #include <errno.h>
48 : #include <fcntl.h>
49 : #include <limits.h>
50 : #include <stdio.h>
51 : #include <stdlib.h>
52 : #include <string.h>
53 : #include <unistd.h>
54 :
55 : #ifdef __cplusplus
56 : extern "C" {
57 : #endif
58 : extern FILE * option_usage_fp;
59 : #define zCopyright (rsstats_opt_strs+0)
60 : #define zLicenseDescrip (rsstats_opt_strs+258)
61 :
62 :
63 : #ifndef NULL
64 : # define NULL 0
65 : #endif
66 :
67 : /**
68 : * static const strings for rsstats options
69 : */
70 : static char const rsstats_opt_strs[1873] =
71 : /* 0 */ "rsstats 0.0.1\n"
72 : "Copyright (C) 2024 Francois Cerbelle, all rights reserved.\n"
73 : "This is free software. It is licensed for use, modification and\n"
74 : "redistribution under the terms of the GNU General Public License,\n"
75 : "version 3 or later <http://gnu.org/licenses/gpl.html>\n\0"
76 : /* 258 */ "rsstats is free software: you can redistribute it and/or modify it under\n"
77 : "the terms of the GNU General Public License as published by the Free\n"
78 : "Software Foundation, either version 3 of the License, or (at your option)\n"
79 : "any later version.\n\n"
80 : "rsstats is distributed in the hope that it will be useful, but WITHOUT ANY\n"
81 : "WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n"
82 : "FOR A PARTICULAR PURPOSE. See the GNU General Public License for more\n"
83 : "details.\n\n"
84 : "You should have received a copy of the GNU General Public License along\n"
85 : "with this program. If not, see <http://www.gnu.org/licenses/>.\n\0"
86 : /* 861 */ "input CSV file (default: clusterdef.csv)\0"
87 : /* 902 */ "INPUT\0"
88 : /* 908 */ "input\0"
89 : /* 914 */ "clusterdef.csv\0"
90 : /* 929 */ "output CVS filename for nodes information (default: rsstats.csv)\0"
91 : /* 994 */ "OUTPUT\0"
92 : /* 1001 */ "output\0"
93 : /* 1008 */ "rsstats.csv\0"
94 : /* 1020 */ "comma separated list of clusternames to query (default: all)\0"
95 : /* 1081 */ "CLUSTERS\0"
96 : /* 1090 */ "clusters\0"
97 : /* 1099 */ "all\0"
98 : /* 1103 */ "Comma separated list of reports to generate (default: all)\0"
99 : /* 1162 */ "REPORTS\0"
100 : /* 1170 */ "reports\0"
101 : /* 1178 */ "display extended usage information and exit\0"
102 : /* 1222 */ "help\0"
103 : /* 1227 */ "extended usage information passed thru pager\0"
104 : /* 1272 */ "more-help\0"
105 : /* 1282 */ "output version information and exit\0"
106 : /* 1318 */ "version\0"
107 : /* 1326 */ "save the option state to a config file\0"
108 : /* 1365 */ "save-opts\0"
109 : /* 1375 */ "load options from a config file\0"
110 : /* 1407 */ "LOAD_OPTS\0"
111 : /* 1417 */ "no-load-opts\0"
112 : /* 1430 */ "no\0"
113 : /* 1433 */ "RSSTATS\0"
114 : /* 1441 */ "rsstats - Redis Enterprise Software cluster statistic extraction\n"
115 : "Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n\0"
116 : /* 1564 */ "$HOME\0"
117 : /* 1570 */ ".rsstatsrc\0"
118 : /* 1581 */ "francois@cerbelle.net\0"
119 : /* 1603 */ "additional information given whenever the usage routine is invoked.\n\0"
120 : /* 1672 */ "This string is added to the usage output when the HELP option is selected.\n"
121 : "The contents of the file 'rsstats.details' is added to the usage output\n"
122 : "when the MORE-HELP option is selected.\n\0"
123 : /* 1859 */ "rsstats 0.0.1";
124 :
125 : /**
126 : * input option description:
127 : */
128 : /** Descriptive text for the input option */
129 : #define INPUT_DESC (rsstats_opt_strs+861)
130 : /** Upper-cased name for the input option */
131 : #define INPUT_NAME (rsstats_opt_strs+902)
132 : /** Name string for the input option */
133 : #define INPUT_name (rsstats_opt_strs+908)
134 : /** The compiled in default value for the input option argument */
135 : #define INPUT_DFT_ARG (rsstats_opt_strs+914)
136 : /** Compiled in flag settings for the input option */
137 : #define INPUT_FLAGS (OPTST_DISABLED \
138 : | OPTST_SET_ARGTYPE(OPARG_TYPE_FILE))
139 :
140 : /**
141 : * output option description:
142 : */
143 : /** Descriptive text for the output option */
144 : #define OUTPUT_DESC (rsstats_opt_strs+929)
145 : /** Upper-cased name for the output option */
146 : #define OUTPUT_NAME (rsstats_opt_strs+994)
147 : /** Name string for the output option */
148 : #define OUTPUT_name (rsstats_opt_strs+1001)
149 : /** The compiled in default value for the output option argument */
150 : #define OUTPUT_DFT_ARG (rsstats_opt_strs+1008)
151 : /** Compiled in flag settings for the output option */
152 : #define OUTPUT_FLAGS (OPTST_DISABLED \
153 : | OPTST_SET_ARGTYPE(OPARG_TYPE_FILE))
154 :
155 : /**
156 : * clusters option description:
157 : */
158 : /** Descriptive text for the clusters option */
159 : #define CLUSTERS_DESC (rsstats_opt_strs+1020)
160 : /** Upper-cased name for the clusters option */
161 : #define CLUSTERS_NAME (rsstats_opt_strs+1081)
162 : /** Name string for the clusters option */
163 : #define CLUSTERS_name (rsstats_opt_strs+1090)
164 : /** The compiled in default value for the clusters option argument */
165 : #define CLUSTERS_DFT_ARG (rsstats_opt_strs+1099)
166 : /** Compiled in flag settings for the clusters option */
167 : #define CLUSTERS_FLAGS (OPTST_DISABLED \
168 : | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
169 :
170 : /**
171 : * reports option description:
172 : */
173 : /** Descriptive text for the reports option */
174 : #define REPORTS_DESC (rsstats_opt_strs+1103)
175 : /** Upper-cased name for the reports option */
176 : #define REPORTS_NAME (rsstats_opt_strs+1162)
177 : /** Name string for the reports option */
178 : #define REPORTS_name (rsstats_opt_strs+1170)
179 : /** The compiled in default value for the reports option argument */
180 : #define REPORTS_DFT_ARG (NULL)
181 : #define ReportsCookieBits VOIDP(REPORTS_BDBS|REPORTS_CLUSTER)
182 : /** Compiled in flag settings for the reports option */
183 : #define REPORTS_FLAGS (OPTST_DISABLED \
184 : | OPTST_SET_ARGTYPE(OPARG_TYPE_MEMBERSHIP))
185 :
186 : /*
187 : * Help/More_Help/Version option descriptions:
188 : */
189 : #define HELP_DESC (rsstats_opt_strs+1178)
190 : #define HELP_name (rsstats_opt_strs+1222)
191 : #ifdef HAVE_WORKING_FORK
192 : #define MORE_HELP_DESC (rsstats_opt_strs+1227)
193 : #define MORE_HELP_name (rsstats_opt_strs+1272)
194 : #define MORE_HELP_FLAGS (OPTST_IMM | OPTST_NO_INIT)
195 : #else
196 : #define MORE_HELP_DESC HELP_DESC
197 : #define MORE_HELP_name HELP_name
198 : #define MORE_HELP_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
199 : #endif
200 : #ifdef NO_OPTIONAL_OPT_ARGS
201 : # define VER_FLAGS (OPTST_IMM | OPTST_NO_INIT)
202 : #else
203 : # define VER_FLAGS (OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
204 : OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT)
205 : #endif
206 : #define VER_DESC (rsstats_opt_strs+1282)
207 : #define VER_name (rsstats_opt_strs+1318)
208 : #define SAVE_OPTS_DESC (rsstats_opt_strs+1326)
209 : #define SAVE_OPTS_name (rsstats_opt_strs+1365)
210 : #define LOAD_OPTS_DESC (rsstats_opt_strs+1375)
211 : #define LOAD_OPTS_NAME (rsstats_opt_strs+1407)
212 : #define NO_LOAD_OPTS_name (rsstats_opt_strs+1417)
213 : #define LOAD_OPTS_pfx (rsstats_opt_strs+1430)
214 : #define LOAD_OPTS_name (NO_LOAD_OPTS_name + 3)
215 : /**
216 : * Declare option callback procedures
217 : */
218 : extern tOptProc
219 : optionBooleanVal, optionNestedVal, optionNumericVal,
220 : optionPagedUsage, optionPrintVersion, optionResetOpt,
221 : optionStackArg, optionTimeDate, optionTimeVal,
222 : optionUnstackArg, optionVendorOption;
223 : static tOptProc
224 : doOptInput, doOptOutput, doOptReports, doUsageOpt;
225 : #define VER_PROC optionPrintVersion
226 :
227 : /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
228 : /**
229 : * Define the rsstats Option Descriptions.
230 : * This is an array of OPTION_CT entries, one for each
231 : * option that the rsstats program responds to.
232 : */
233 : static tOptDesc optDesc[OPTION_CT] = {
234 : { /* entry idx, value */ 0, VALUE_OPT_INPUT,
235 : /* equiv idx, value */ 0, VALUE_OPT_INPUT,
236 : /* equivalenced to */ NO_EQUIVALENT,
237 : /* min, max, act ct */ 0, 1, 0,
238 : /* opt state flags */ INPUT_FLAGS, 0,
239 : /* last opt argumnt */ { INPUT_DFT_ARG },
240 : /* arg list/cookie */ NULL,
241 : /* must/cannot opts */ NULL, NULL,
242 : /* option proc */ doOptInput,
243 : /* desc, NAME, name */ INPUT_DESC, INPUT_NAME, INPUT_name,
244 : /* disablement strs */ NULL, NULL },
245 :
246 : { /* entry idx, value */ 1, VALUE_OPT_OUTPUT,
247 : /* equiv idx, value */ 1, VALUE_OPT_OUTPUT,
248 : /* equivalenced to */ NO_EQUIVALENT,
249 : /* min, max, act ct */ 0, 1, 0,
250 : /* opt state flags */ OUTPUT_FLAGS, 0,
251 : /* last opt argumnt */ { OUTPUT_DFT_ARG },
252 : /* arg list/cookie */ NULL,
253 : /* must/cannot opts */ NULL, NULL,
254 : /* option proc */ doOptOutput,
255 : /* desc, NAME, name */ OUTPUT_DESC, OUTPUT_NAME, OUTPUT_name,
256 : /* disablement strs */ NULL, NULL },
257 :
258 : { /* entry idx, value */ 2, VALUE_OPT_CLUSTERS,
259 : /* equiv idx, value */ 2, VALUE_OPT_CLUSTERS,
260 : /* equivalenced to */ NO_EQUIVALENT,
261 : /* min, max, act ct */ 0, 1, 0,
262 : /* opt state flags */ CLUSTERS_FLAGS, 0,
263 : /* last opt argumnt */ { CLUSTERS_DFT_ARG },
264 : /* arg list/cookie */ NULL,
265 : /* must/cannot opts */ NULL, NULL,
266 : /* option proc */ NULL,
267 : /* desc, NAME, name */ CLUSTERS_DESC, CLUSTERS_NAME, CLUSTERS_name,
268 : /* disablement strs */ NULL, NULL },
269 :
270 : { /* entry idx, value */ 3, VALUE_OPT_REPORTS,
271 : /* equiv idx, value */ 3, VALUE_OPT_REPORTS,
272 : /* equivalenced to */ NO_EQUIVALENT,
273 : /* min, max, act ct */ 0, NOLIMIT, 0,
274 : /* opt state flags */ REPORTS_FLAGS, 0,
275 : /* last opt argumnt */ { REPORTS_DFT_ARG },
276 : /* arg list/cookie */ ReportsCookieBits,
277 : /* must/cannot opts */ NULL, NULL,
278 : /* option proc */ doOptReports,
279 : /* desc, NAME, name */ REPORTS_DESC, REPORTS_NAME, REPORTS_name,
280 : /* disablement strs */ NULL, NULL },
281 :
282 : { /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
283 : /* equiv idx value */ NO_EQUIVALENT, VALUE_OPT_VERSION,
284 : /* equivalenced to */ NO_EQUIVALENT,
285 : /* min, max, act ct */ 0, 1, 0,
286 : /* opt state flags */ VER_FLAGS, AOUSE_VERSION,
287 : /* last opt argumnt */ { NULL },
288 : /* arg list/cookie */ NULL,
289 : /* must/cannot opts */ NULL, NULL,
290 : /* option proc */ VER_PROC,
291 : /* desc, NAME, name */ VER_DESC, NULL, VER_name,
292 : /* disablement strs */ NULL, NULL },
293 :
294 :
295 :
296 : { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
297 : /* equiv idx value */ NO_EQUIVALENT, VALUE_OPT_HELP,
298 : /* equivalenced to */ NO_EQUIVALENT,
299 : /* min, max, act ct */ 0, 1, 0,
300 : /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, AOUSE_HELP,
301 : /* last opt argumnt */ { NULL },
302 : /* arg list/cookie */ NULL,
303 : /* must/cannot opts */ NULL, NULL,
304 : /* option proc */ doUsageOpt,
305 : /* desc, NAME, name */ HELP_DESC, NULL, HELP_name,
306 : /* disablement strs */ NULL, NULL },
307 :
308 : { /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
309 : /* equiv idx value */ NO_EQUIVALENT, VALUE_OPT_MORE_HELP,
310 : /* equivalenced to */ NO_EQUIVALENT,
311 : /* min, max, act ct */ 0, 1, 0,
312 : /* opt state flags */ MORE_HELP_FLAGS, AOUSE_MORE_HELP,
313 : /* last opt argumnt */ { NULL },
314 : /* arg list/cookie */ NULL,
315 : /* must/cannot opts */ NULL, NULL,
316 : /* option proc */ optionPagedUsage,
317 : /* desc, NAME, name */ MORE_HELP_DESC, NULL, MORE_HELP_name,
318 : /* disablement strs */ NULL, NULL },
319 :
320 : { /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS,
321 : /* equiv idx value */ NO_EQUIVALENT, VALUE_OPT_SAVE_OPTS,
322 : /* equivalenced to */ NO_EQUIVALENT,
323 : /* min, max, act ct */ 0, 1, 0,
324 : /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
325 : | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, AOUSE_SAVE_OPTS,
326 : /* last opt argumnt */ { NULL },
327 : /* arg list/cookie */ NULL,
328 : /* must/cannot opts */ NULL, NULL,
329 : /* option proc */ NULL,
330 : /* desc, NAME, name */ SAVE_OPTS_DESC, NULL, SAVE_OPTS_name,
331 : /* disablement strs */ NULL, NULL },
332 :
333 : { /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS,
334 : /* equiv idx value */ NO_EQUIVALENT, VALUE_OPT_LOAD_OPTS,
335 : /* equivalenced to */ NO_EQUIVALENT,
336 : /* min, max, act ct */ 0, NOLIMIT, 0,
337 : /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
338 : | OPTST_DISABLE_IMM, AOUSE_LOAD_OPTS,
339 : /* last opt argumnt */ { NULL },
340 : /* arg list/cookie */ NULL,
341 : /* must/cannot opts */ NULL, NULL,
342 : /* option proc */ optionLoadOpt,
343 : /* desc, NAME, name */ LOAD_OPTS_DESC, LOAD_OPTS_NAME, LOAD_OPTS_name,
344 : /* disablement strs */ NO_LOAD_OPTS_name, LOAD_OPTS_pfx }
345 : };
346 :
347 :
348 : /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
349 : /** Reference to the upper cased version of rsstats. */
350 : #define zPROGNAME (rsstats_opt_strs+1433)
351 : /** Reference to the title line for rsstats usage. */
352 : #define zUsageTitle (rsstats_opt_strs+1441)
353 : /** rsstats configuration file name. */
354 : #define zRcName (rsstats_opt_strs+1570)
355 : /** Directories to search for rsstats config files. */
356 : static char const * const apzHomeList[2] = {
357 : rsstats_opt_strs+1564,
358 : NULL };
359 : /** The rsstats program bug email address. */
360 : #define zBugsAddr (rsstats_opt_strs+1581)
361 : /** Clarification/explanation of what rsstats does. */
362 : #define zExplain (rsstats_opt_strs+1603)
363 : /** Extra detail explaining what rsstats does. */
364 : #define zDetail (rsstats_opt_strs+1672)
365 : /** The full version string for rsstats. */
366 : #define zFullVersion (rsstats_opt_strs+1859)
367 : /* extracted from optcode.tlib near line 342 */
368 :
369 : #if defined(ENABLE_NLS)
370 : # define OPTPROC_BASE OPTPROC_TRANSLATE
371 : static tOptionXlateProc translate_option_strings;
372 : #else
373 : # define OPTPROC_BASE OPTPROC_NONE
374 : # define translate_option_strings NULL
375 : #endif /* ENABLE_NLS */
376 :
377 : #define rsstats_full_usage (NULL)
378 : #define rsstats_short_usage (NULL)
379 :
380 : #endif /* not defined __doxygen__ */
381 :
382 : /*
383 : * Create the static procedure(s) declared above.
384 : */
385 : /**
386 : * The callout function that invokes the optionUsage function.
387 : *
388 : * @param[in] opts the AutoOpts option description structure
389 : * @param[in] od the descriptor for the "help" (usage) option.
390 : * @noreturn
391 : */
392 : static void
393 2 : doUsageOpt(tOptions * opts, tOptDesc * od)
394 : {
395 : int ex_code;
396 2 : ex_code = RSSTATS_EXIT_SUCCESS;
397 2 : optionUsage(&rsstatsOptions, ex_code);
398 : /* NOTREACHED */
399 0 : exit(RSSTATS_EXIT_FAILURE);
400 : (void)opts;
401 : (void)od;
402 : }
403 :
404 : /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
405 : /**
406 : * Code to handle the input option.
407 : *
408 : * @param[in] pOptions the rsstats options data structure
409 : * @param[in,out] pOptDesc the option descriptor for this option.
410 : */
411 : static void
412 2 : doOptInput(tOptions* pOptions, tOptDesc* pOptDesc)
413 : {
414 : static teOptFileType const type =
415 : FTYPE_MODE_MAY_EXIST + FTYPE_MODE_NO_OPEN;
416 : static tuFileMode mode;
417 : #ifndef O_CLOEXEC
418 : # define O_CLOEXEC 0
419 : #endif
420 2 : mode.file_flags = O_CLOEXEC;
421 :
422 : /*
423 : * This function handles special invalid values for "pOptions"
424 : */
425 2 : optionFileCheck(pOptions, pOptDesc, type, mode);
426 2 : }
427 :
428 : /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
429 : /**
430 : * Code to handle the output option.
431 : *
432 : * @param[in] pOptions the rsstats options data structure
433 : * @param[in,out] pOptDesc the option descriptor for this option.
434 : */
435 : static void
436 2 : doOptOutput(tOptions* pOptions, tOptDesc* pOptDesc)
437 : {
438 : static teOptFileType const type =
439 : FTYPE_MODE_MAY_EXIST + FTYPE_MODE_NO_OPEN;
440 : static tuFileMode mode;
441 : #ifndef O_CLOEXEC
442 : # define O_CLOEXEC 0
443 : #endif
444 2 : mode.file_flags = O_CLOEXEC;
445 :
446 : /*
447 : * This function handles special invalid values for "pOptions"
448 : */
449 2 : optionFileCheck(pOptions, pOptDesc, type, mode);
450 2 : }
451 :
452 : /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
453 : /**
454 : * Code to handle the reports option.
455 : *
456 : * @param[in] pOptions the rsstats options data structure
457 : * @param[in,out] pOptDesc the option descriptor for this option.
458 : */
459 : static void
460 2 : doOptReports(tOptions* pOptions, tOptDesc* pOptDesc)
461 : {
462 :
463 : /* extracted from optmain.tlib near line 1007 */
464 : static char const * const names[2] = {
465 : "bdbs", "cluster"
466 : };
467 : /*
468 : * This function handles special invalid values for "pOptions"
469 : */
470 2 : optionSetMembers(pOptions, pOptDesc, names, 2);
471 2 : }
472 : /* extracted from optmain.tlib near line 1250 */
473 :
474 : /**
475 : * The directory containing the data associated with rsstats.
476 : */
477 : #ifndef PKGDATADIR
478 : # define PKGDATADIR ""
479 : #endif
480 :
481 : /**
482 : * Information about the person or institution that packaged rsstats
483 : * for the current distribution.
484 : */
485 : #ifndef WITH_PACKAGER
486 : # define rsstats_packager_info NULL
487 : #else
488 : /** Packager information for rsstats. */
489 : static char const rsstats_packager_info[] =
490 : "Packaged by " WITH_PACKAGER
491 :
492 : # ifdef WITH_PACKAGER_VERSION
493 : " ("WITH_PACKAGER_VERSION")"
494 : # endif
495 :
496 : # ifdef WITH_PACKAGER_BUG_REPORTS
497 : "\nReport rsstats bugs to " WITH_PACKAGER_BUG_REPORTS
498 : # endif
499 : "\n";
500 : #endif
501 : #ifndef __doxygen__
502 :
503 : #endif /* __doxygen__ */
504 : /**
505 : * The option definitions for rsstats. The one structure that
506 : * binds them all.
507 : */
508 : tOptions rsstatsOptions = {
509 : OPTIONS_STRUCT_VERSION,
510 : 0, NULL, /* original argc + argv */
511 : ( OPTPROC_BASE
512 : + OPTPROC_ERRSTOP
513 : + OPTPROC_SHORTOPT
514 : + OPTPROC_LONGOPT
515 : + OPTPROC_NO_REQ_OPT
516 : + OPTPROC_ENVIRON
517 : + OPTPROC_NO_ARGS
518 : + OPTPROC_GNUUSAGE ),
519 : 0, NULL, /* current option index, current option */
520 : NULL, NULL, zPROGNAME,
521 : zRcName, zCopyright, zLicenseDescrip,
522 : zFullVersion, apzHomeList, zUsageTitle,
523 : zExplain, zDetail, optDesc,
524 : zBugsAddr, /* address to send bugs to */
525 : NULL, NULL, /* extensions/saved state */
526 : optionUsage, /* usage procedure */
527 : translate_option_strings, /* translation procedure */
528 : /*
529 : * Indexes to special options
530 : */
531 : { INDEX_OPT_MORE_HELP, /* more-help option index */
532 : INDEX_OPT_SAVE_OPTS, /* save option index */
533 : NO_EQUIVALENT, /* '-#' option index */
534 : NO_EQUIVALENT /* index of default opt */
535 : },
536 : 9 /* full option count */, 4 /* user option count */,
537 : rsstats_full_usage, rsstats_short_usage,
538 : NULL, NULL,
539 : PKGDATADIR, rsstats_packager_info
540 : };
541 :
542 : #if ENABLE_NLS
543 : /**
544 : * This code is designed to translate translatable option text for the
545 : * rsstats program. These translations happen upon entry
546 : * to optionProcess().
547 : */
548 : #include <stdio.h>
549 : #include <stdlib.h>
550 : #include <string.h>
551 : #include <unistd.h>
552 : #ifdef HAVE_DCGETTEXT
553 : # include <gettext.h>
554 : #endif
555 : #include <autoopts/usage-txt.h>
556 :
557 : static char * AO_gettext(char const * pz);
558 : static void coerce_it(void ** s);
559 :
560 : /**
561 : * AutoGen specific wrapper function for gettext. It relies on the macro _()
562 : * to convert from English to the target language, then strdup-duplicates the
563 : * result string. It tries the "libopts" domain first, then whatever has been
564 : * set via the \a textdomain(3) call.
565 : *
566 : * @param[in] pz the input text used as a lookup key.
567 : * @returns the translated text (if there is one),
568 : * or the original text (if not).
569 : */
570 : static char *
571 854 : AO_gettext(char const * pz)
572 : {
573 : char * res;
574 854 : if (pz == NULL)
575 0 : return NULL;
576 : #ifdef HAVE_DCGETTEXT
577 : /*
578 : * While processing the option_xlateable_txt data, try to use the
579 : * "libopts" domain. Once we switch to the option descriptor data,
580 : * do *not* use that domain.
581 : */
582 : if (option_xlateable_txt.field_ct != 0) {
583 : res = dgettext("libopts", pz);
584 : if (res == pz)
585 : res = (char *)VOIDP(_(pz));
586 : } else
587 : res = (char *)VOIDP(_(pz));
588 : #else
589 854 : res = (char *)VOIDP(_(pz));
590 : #endif
591 854 : if (res == pz)
592 854 : return res;
593 0 : res = strdup(res);
594 0 : if (res == NULL) {
595 0 : fputs(_("No memory for duping translated strings\n"), stderr);
596 0 : exit(RSSTATS_EXIT_FAILURE);
597 : }
598 0 : return res;
599 : }
600 :
601 : /**
602 : * All the pointers we use are marked "* const", but they are stored in
603 : * writable memory. Coerce the mutability and set the pointer.
604 : */
605 105 : static void coerce_it(void ** s) { *s = AO_gettext(*s);
606 105 : }
607 :
608 : /**
609 : * Translate all the translatable strings in the rsstatsOptions
610 : * structure defined above. This is done only once.
611 : */
612 : static void
613 7 : translate_option_strings(void)
614 : {
615 7 : tOptions * const opts = &rsstatsOptions;
616 :
617 : /*
618 : * Guard against re-translation. It won't work. The strings will have
619 : * been changed by the first pass through this code. One shot only.
620 : */
621 7 : if (option_xlateable_txt.field_ct != 0) {
622 : /*
623 : * Do the translations. The first pointer follows the field count
624 : * field. The field count field is the size of a pointer.
625 : */
626 7 : char ** ppz = (char**)VOIDP(&(option_xlateable_txt));
627 7 : int ix = option_xlateable_txt.field_ct;
628 :
629 : do {
630 749 : ppz++; /* skip over field_ct */
631 749 : *ppz = AO_gettext(*ppz);
632 749 : } while (--ix > 0);
633 : /* prevent re-translation and disable "libopts" domain lookup */
634 7 : option_xlateable_txt.field_ct = 0;
635 :
636 7 : coerce_it(VOIDP(&(opts->pzCopyright)));
637 7 : coerce_it(VOIDP(&(opts->pzCopyNotice)));
638 7 : coerce_it(VOIDP(&(opts->pzFullVersion)));
639 7 : coerce_it(VOIDP(&(opts->pzUsageTitle)));
640 7 : coerce_it(VOIDP(&(opts->pzExplain)));
641 7 : coerce_it(VOIDP(&(opts->pzDetail)));
642 : {
643 7 : tOptDesc * od = opts->pOptDesc;
644 70 : for (ix = opts->optCt; ix > 0; ix--, od++)
645 63 : coerce_it(VOIDP(&(od->pzText)));
646 : }
647 : }
648 7 : }
649 : #endif /* ENABLE_NLS */
650 :
651 : #ifdef DO_NOT_COMPILE_THIS_CODE_IT_IS_FOR_GETTEXT
652 : /** I18N function strictly for xgettext. Do not compile. */
653 : static void bogus_function(void) {
654 : /* TRANSLATORS:
655 :
656 : The following dummy function was crated solely so that xgettext can
657 : extract the correct strings. These strings are actually referenced
658 : by a field name in the rsstatsOptions structure noted in the
659 : comments below. The literal text is defined in rsstats_opt_strs.
660 :
661 : NOTE: the strings below are segmented with respect to the source string
662 : rsstats_opt_strs. The strings above are handed off for translation
663 : at run time a paragraph at a time. Consequently, they are presented here
664 : for translation a paragraph at a time.
665 :
666 : ALSO: often the description for an option will reference another option
667 : by name. These are set off with apostrophe quotes (I hope). Do not
668 : translate option names.
669 : */
670 : /* referenced via rsstatsOptions.pzCopyright */
671 : puts(_("rsstats 0.0.1\n\
672 : Copyright (C) 2024 Francois Cerbelle, all rights reserved.\n\
673 : This is free software. It is licensed for use, modification and\n\
674 : redistribution under the terms of the GNU General Public License,\n\
675 : version 3 or later <http://gnu.org/licenses/gpl.html>\n"));
676 :
677 : /* referenced via rsstatsOptions.pzCopyNotice */
678 : puts(_("rsstats is free software: you can redistribute it and/or modify it under\n\
679 : the terms of the GNU General Public License as published by the Free\n\
680 : Software Foundation, either version 3 of the License, or (at your option)\n\
681 : any later version.\n\n"));
682 : puts(_("rsstats is distributed in the hope that it will be useful, but WITHOUT ANY\n\
683 : WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n\
684 : FOR A PARTICULAR PURPOSE. See the GNU General Public License for more\n\
685 : details.\n\n"));
686 : puts(_("You should have received a copy of the GNU General Public License along\n\
687 : with this program. If not, see <http://www.gnu.org/licenses/>.\n"));
688 :
689 : /* referenced via rsstatsOptions.pOptDesc->pzText */
690 : puts(_("input CSV file (default: clusterdef.csv)"));
691 :
692 : /* referenced via rsstatsOptions.pOptDesc->pzText */
693 : puts(_("output CVS filename for nodes information (default: rsstats.csv)"));
694 :
695 : /* referenced via rsstatsOptions.pOptDesc->pzText */
696 : puts(_("comma separated list of clusternames to query (default: all)"));
697 :
698 : /* referenced via rsstatsOptions.pOptDesc->pzText */
699 : puts(_("Comma separated list of reports to generate (default: all)"));
700 :
701 : /* referenced via rsstatsOptions.pOptDesc->pzText */
702 : puts(_("display extended usage information and exit"));
703 :
704 : /* referenced via rsstatsOptions.pOptDesc->pzText */
705 : puts(_("extended usage information passed thru pager"));
706 :
707 : /* referenced via rsstatsOptions.pOptDesc->pzText */
708 : puts(_("output version information and exit"));
709 :
710 : /* referenced via rsstatsOptions.pOptDesc->pzText */
711 : puts(_("save the option state to a config file"));
712 :
713 : /* referenced via rsstatsOptions.pOptDesc->pzText */
714 : puts(_("load options from a config file"));
715 :
716 : /* referenced via rsstatsOptions.pzUsageTitle */
717 : puts(_("rsstats - Redis Enterprise Software cluster statistic extraction\n\
718 : Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n"));
719 :
720 : /* referenced via rsstatsOptions.pzExplain */
721 : puts(_("additional information given whenever the usage routine is invoked.\n"));
722 :
723 : /* referenced via rsstatsOptions.pzDetail */
724 : puts(_("This string is added to the usage output when the HELP option is selected.\n\
725 : The contents of the file 'rsstats.details' is added to the usage output\n\
726 : when the MORE-HELP option is selected.\n"));
727 :
728 : /* referenced via rsstatsOptions.pzFullVersion */
729 : puts(_("rsstats 0.0.1"));
730 :
731 : /* referenced via rsstatsOptions.pzFullUsage */
732 : puts(_("<<<NOT-FOUND>>>"));
733 :
734 : /* referenced via rsstatsOptions.pzShortUsage */
735 : puts(_("<<<NOT-FOUND>>>"));
736 : /* LIBOPTS-MESSAGES: */
737 : #line 67 "../autoopts.c"
738 : puts(_("allocation of %d bytes failed\n"));
739 : #line 89 "../autoopts.c"
740 : puts(_("allocation of %d bytes failed\n"));
741 : #line 48 "../init.c"
742 : puts(_("AutoOpts function called without option descriptor\n"));
743 : #line 81 "../init.c"
744 : puts(_("\tThis exceeds the compiled library version: "));
745 : #line 79 "../init.c"
746 : puts(_("Automated Options Processing Error!\n"
747 : "\t%s called AutoOpts function with structure version %d:%d:%d.\n"));
748 : #line 78 "../autoopts.c"
749 : puts(_("realloc of %d bytes at 0x%p failed\n"));
750 : #line 83 "../init.c"
751 : puts(_("\tThis is less than the minimum library version: "));
752 : #line 121 "../version.c"
753 : puts(_("Automated Options version %s\n"
754 : "\tCopyright (C) 1999-2017 by Bruce Korb - all rights reserved\n"));
755 : #line 49 "../makeshell.c"
756 : puts(_("(AutoOpts bug): %s.\n"));
757 : #line 90 "../reset.c"
758 : puts(_("optionResetOpt() called, but reset-option not configured"));
759 : #line 241 "../usage.c"
760 : puts(_("could not locate the 'help' option"));
761 : #line 330 "../autoopts.c"
762 : puts(_("optionProcess() was called with invalid data"));
763 : #line 697 "../usage.c"
764 : puts(_("invalid argument type specified"));
765 : #line 568 "../find.c"
766 : puts(_("defaulted to option with optional arg"));
767 : #line 76 "../alias.c"
768 : puts(_("aliasing option is out of range."));
769 : #line 210 "../enum.c"
770 : puts(_("%s error: the keyword '%s' is ambiguous for %s\n"));
771 : #line 78 "../find.c"
772 : puts(_(" The following options match:\n"));
773 : #line 263 "../find.c"
774 : puts(_("%s: ambiguous option name: %s (matches %d options)\n"));
775 : #line 161 "../check.c"
776 : puts(_("%s: Command line arguments required\n"));
777 : #line 43 "../alias.c"
778 : puts(_("%d %s%s options allowed\n"));
779 : #line 56 "../makeshell.c"
780 : puts(_("%s error %d (%s) calling %s for '%s'\n"));
781 : #line 268 "../makeshell.c"
782 : puts(_("interprocess pipe"));
783 : #line 171 "../version.c"
784 : puts(_("error: version option argument '%c' invalid. Use:\n"
785 : "\t'v' - version only\n"
786 : "\t'c' - version and copyright\n"
787 : "\t'n' - version and full copyright notice\n"));
788 : #line 58 "../check.c"
789 : puts(_("%s error: the '%s' and '%s' options conflict\n"));
790 : #line 187 "../find.c"
791 : puts(_("%s: The '%s' option has been disabled."));
792 : #line 400 "../find.c"
793 : puts(_("%s: The '%s' option has been disabled."));
794 : #line 38 "../alias.c"
795 : puts(_("-equivalence"));
796 : #line 439 "../find.c"
797 : puts(_("%s: illegal option -- %c\n"));
798 : #line 110 "../reset.c"
799 : puts(_("%s: illegal option -- %c\n"));
800 : #line 241 "../find.c"
801 : puts(_("%s: illegal option -- %s\n"));
802 : #line 740 "../find.c"
803 : puts(_("%s: illegal option -- %s\n"));
804 : #line 118 "../reset.c"
805 : puts(_("%s: illegal option -- %s\n"));
806 : #line 305 "../find.c"
807 : puts(_("%s: unknown vendor extension option -- %s\n"));
808 : #line 135 "../enum.c"
809 : puts(_(" or an integer from %d through %d\n"));
810 : #line 145 "../enum.c"
811 : puts(_(" or an integer from %d through %d\n"));
812 : #line 696 "../usage.c"
813 : puts(_("%s error: invalid option descriptor for %s\n"));
814 : #line 1030 "../usage.c"
815 : puts(_("%s error: invalid option descriptor for %s\n"));
816 : #line 355 "../find.c"
817 : puts(_("%s: invalid option name: %s\n"));
818 : #line 497 "../find.c"
819 : puts(_("%s: The '%s' option requires an argument.\n"));
820 : #line 150 "../autoopts.c"
821 : puts(_("(AutoOpts bug): Equivalenced option '%s' was equivalenced to both\n"
822 : "\t'%s' and '%s'."));
823 : #line 94 "../check.c"
824 : puts(_("%s error: The %s option is required\n"));
825 : #line 602 "../find.c"
826 : puts(_("%s: The '%s' option cannot have an argument.\n"));
827 : #line 151 "../check.c"
828 : puts(_("%s: Command line arguments are not allowed.\n"));
829 : #line 568 "../save.c"
830 : puts(_("error %d (%s) creating %s\n"));
831 : #line 210 "../enum.c"
832 : puts(_("%s error: '%s' does not match any %s keywords.\n"));
833 : #line 93 "../reset.c"
834 : puts(_("%s error: The '%s' option requires an argument.\n"));
835 : #line 122 "../save.c"
836 : puts(_("error %d (%s) stat-ing %s\n"));
837 : #line 175 "../save.c"
838 : puts(_("error %d (%s) stat-ing %s\n"));
839 : #line 143 "../restore.c"
840 : puts(_("%s error: no saved option state\n"));
841 : #line 225 "../autoopts.c"
842 : puts(_("'%s' is not a command line option.\n"));
843 : #line 113 "../time.c"
844 : puts(_("%s error: '%s' is not a recognizable date/time.\n"));
845 : #line 50 "../time.c"
846 : puts(_("%s error: '%s' is not a recognizable time duration.\n"));
847 : #line 92 "../check.c"
848 : puts(_("%s error: The %s option must appear %d times.\n"));
849 : #line 165 "../numeric.c"
850 : puts(_("%s error: '%s' is not a recognizable number.\n"));
851 : #line 176 "../enum.c"
852 : puts(_("%s error: %s exceeds %s keyword count\n"));
853 : #line 279 "../usage.c"
854 : puts(_("Try '%s %s' for more information.\n"));
855 : #line 45 "../alias.c"
856 : puts(_("one %s%s option allowed\n"));
857 : #line 170 "../makeshell.c"
858 : puts(_("standard output"));
859 : #line 905 "../makeshell.c"
860 : puts(_("standard output"));
861 : #line 223 "../usage.c"
862 : puts(_("standard output"));
863 : #line 364 "../usage.c"
864 : puts(_("standard output"));
865 : #line 574 "../usage.c"
866 : puts(_("standard output"));
867 : #line 178 "../version.c"
868 : puts(_("standard output"));
869 : #line 223 "../usage.c"
870 : puts(_("standard error"));
871 : #line 364 "../usage.c"
872 : puts(_("standard error"));
873 : #line 574 "../usage.c"
874 : puts(_("standard error"));
875 : #line 178 "../version.c"
876 : puts(_("standard error"));
877 : #line 170 "../makeshell.c"
878 : puts(_("write"));
879 : #line 905 "../makeshell.c"
880 : puts(_("write"));
881 : #line 222 "../usage.c"
882 : puts(_("write"));
883 : #line 363 "../usage.c"
884 : puts(_("write"));
885 : #line 573 "../usage.c"
886 : puts(_("write"));
887 : #line 177 "../version.c"
888 : puts(_("write"));
889 : #line 60 "../numeric.c"
890 : puts(_("%s error: %s option value %ld is out of range.\n"));
891 : #line 44 "../check.c"
892 : puts(_("%s error: %s option requires the %s option\n"));
893 : #line 121 "../save.c"
894 : puts(_("%s warning: cannot save options - %s not regular file\n"));
895 : #line 174 "../save.c"
896 : puts(_("%s warning: cannot save options - %s not regular file\n"));
897 : #line 193 "../save.c"
898 : puts(_("%s warning: cannot save options - %s not regular file\n"));
899 : #line 567 "../save.c"
900 : puts(_("%s warning: cannot save options - %s not regular file\n"));
901 : /* END-LIBOPTS-MESSAGES */
902 :
903 : /* USAGE-TEXT: */
904 : #line 822 "../usage.c"
905 : puts(_("\t\t\t\t- an alternate for '%s'\n"));
906 : #line 1097 "../usage.c"
907 : puts(_("Version, usage and configuration options:"));
908 : #line 873 "../usage.c"
909 : puts(_("\t\t\t\t- default option for unnamed options\n"));
910 : #line 786 "../usage.c"
911 : puts(_("\t\t\t\t- disabled as '--%s'\n"));
912 : #line 1066 "../usage.c"
913 : puts(_(" --- %-14s %s\n"));
914 : #line 1064 "../usage.c"
915 : puts(_("This option has been disabled"));
916 : #line 813 "../usage.c"
917 : puts(_("\t\t\t\t- enabled by default\n"));
918 : #line 40 "../alias.c"
919 : puts(_("%s error: only "));
920 : #line 1143 "../usage.c"
921 : puts(_(" - examining environment variables named %s_*\n"));
922 : #line 168 "../file.c"
923 : puts(_("\t\t\t\t- file must not pre-exist\n"));
924 : #line 172 "../file.c"
925 : puts(_("\t\t\t\t- file must pre-exist\n"));
926 : #line 329 "../usage.c"
927 : puts(_("Options are specified by doubled hyphens and their name or by a single\n"
928 : "hyphen and the flag character.\n"));
929 : #line 882 "../makeshell.c"
930 : puts(_("\n"
931 : "= = = = = = = =\n\n"
932 : "This incarnation of genshell will produce\n"
933 : "a shell script to parse the options for %s:\n\n"));
934 : #line 142 "../enum.c"
935 : puts(_(" or an integer mask with any of the lower %d bits set\n"));
936 : #line 846 "../usage.c"
937 : puts(_("\t\t\t\t- is a set membership option\n"));
938 : #line 867 "../usage.c"
939 : puts(_("\t\t\t\t- must appear between %d and %d times\n"));
940 : #line 331 "../usage.c"
941 : puts(_("Options are specified by single or double hyphens and their name.\n"));
942 : #line 853 "../usage.c"
943 : puts(_("\t\t\t\t- may appear multiple times\n"));
944 : #line 840 "../usage.c"
945 : puts(_("\t\t\t\t- may not be preset\n"));
946 : #line 1258 "../usage.c"
947 : puts(_(" Arg Option-Name Description\n"));
948 : #line 1194 "../usage.c"
949 : puts(_(" Flg Arg Option-Name Description\n"));
950 : #line 1252 "../usage.c"
951 : puts(_(" Flg Arg Option-Name Description\n"));
952 : #line 1253 "../usage.c"
953 : puts(_(" %3s %s"));
954 : #line 1259 "../usage.c"
955 : puts(_(" %3s %s"));
956 : #line 336 "../usage.c"
957 : puts(_("The '-#<number>' option may omit the hash char\n"));
958 : #line 332 "../usage.c"
959 : puts(_("All arguments are named options.\n"));
960 : #line 920 "../usage.c"
961 : puts(_(" - reading file %s"));
962 : #line 358 "../usage.c"
963 : puts(_("\n"
964 : "Please send bug reports to: <%s>\n"));
965 : #line 100 "../version.c"
966 : puts(_("\n"
967 : "Please send bug reports to: <%s>\n"));
968 : #line 129 "../version.c"
969 : puts(_("\n"
970 : "Please send bug reports to: <%s>\n"));
971 : #line 852 "../usage.c"
972 : puts(_("\t\t\t\t- may NOT appear - preset only\n"));
973 : #line 893 "../usage.c"
974 : puts(_("\n"
975 : "The following option preset mechanisms are supported:\n"));
976 : #line 1141 "../usage.c"
977 : puts(_("\n"
978 : "The following option preset mechanisms are supported:\n"));
979 : #line 631 "../usage.c"
980 : puts(_("prohibits these options:\n"));
981 : #line 626 "../usage.c"
982 : puts(_("prohibits the option '%s'\n"));
983 : #line 81 "../numeric.c"
984 : puts(_("%s%ld to %ld"));
985 : #line 79 "../numeric.c"
986 : puts(_("%sgreater than or equal to %ld"));
987 : #line 75 "../numeric.c"
988 : puts(_("%s%ld exactly"));
989 : #line 68 "../numeric.c"
990 : puts(_("%sit must lie in one of the ranges:\n"));
991 : #line 68 "../numeric.c"
992 : puts(_("%sit must be in the range:\n"));
993 : #line 88 "../numeric.c"
994 : puts(_(", or\n"));
995 : #line 66 "../numeric.c"
996 : puts(_("%sis scalable with a suffix: k/K/m/M/g/G/t/T\n"));
997 : #line 77 "../numeric.c"
998 : puts(_("%sless than or equal to %ld"));
999 : #line 339 "../usage.c"
1000 : puts(_("Operands and options may be intermixed. They will be reordered.\n"));
1001 : #line 601 "../usage.c"
1002 : puts(_("requires the option '%s'\n"));
1003 : #line 604 "../usage.c"
1004 : puts(_("requires these options:\n"));
1005 : #line 1270 "../usage.c"
1006 : puts(_(" Arg Option-Name Req? Description\n"));
1007 : #line 1264 "../usage.c"
1008 : puts(_(" Flg Arg Option-Name Req? Description\n"));
1009 : #line 143 "../enum.c"
1010 : puts(_("or you may use a numeric representation. Preceding these with a '!'\n"
1011 : "will clear the bits, specifying 'none' will clear all bits, and 'all'\n"
1012 : "will set them all. Multiple entries may be passed as an option\n"
1013 : "argument list.\n"));
1014 : #line 859 "../usage.c"
1015 : puts(_("\t\t\t\t- may appear up to %d times\n"));
1016 : #line 52 "../enum.c"
1017 : puts(_("The valid \"%s\" option keywords are:\n"));
1018 : #line 1101 "../usage.c"
1019 : puts(_("The next option supports vendor supported extra options:"));
1020 : #line 722 "../usage.c"
1021 : puts(_("These additional options are:"));
1022 : /* END-USAGE-TEXT */
1023 : }
1024 : #endif /* uncompilable code */
1025 : #ifdef __cplusplus
1026 : }
1027 : #endif
1028 : /* rsstats-opts.c ends here */
|