pacemaker  2.0.4-2deceaa
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
options_internal.h
Go to the documentation of this file.
1 /*
2  * Copyright 2006-2020 the Pacemaker project contributors
3  *
4  * The version control history for this file may have further details.
5  *
6  * This source code is licensed under the GNU Lesser General Public License
7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
8  */
9 
10 #ifndef OPTIONS_INTERNAL__H
11 # define OPTIONS_INTERNAL__H
12 
13 # include <config.h> // HAVE_GETOPT, _Noreturn
14 # include <glib.h> // GHashTable
15 # include <stdbool.h> // bool
16 
17 /*
18  * Command-line option handling
19  *
20  * This will all eventually go away as everything is converted to use GOption
21  */
22 
23 # ifdef HAVE_GETOPT_H
24 # include <getopt.h>
25 # else
26 # define no_argument 0
27 # define required_argument 1
28 # endif
29 
32  pcmk__option_hidden = (1 << 1),
35 };
36 
37 typedef struct pcmk__cli_option_s {
38  /* Fields from 'struct option' in getopt.h */
39  /* name of long option */
40  const char *name;
41  /*
42  * one of no_argument, required_argument, and optional_argument:
43  * whether option takes an argument
44  */
45  int has_arg;
46  /* if not NULL, set *flag to val when option found */
47  int *flag;
48  /* if flag not NULL, value to set *flag to; else return value */
49  int val;
50 
51  /* Custom fields */
52  const char *desc;
53  long flags;
55 
56 void pcmk__set_cli_options(const char *short_options, const char *usage,
57  pcmk__cli_option_t *long_options,
58  const char *app_desc);
59 int pcmk__next_cli_option(int argc, char **argv, int *index,
60  const char **longname);
61 _Noreturn void pcmk__cli_help(char cmd, crm_exit_t exit_code);
62 void pcmk__cli_option_cleanup(void);
63 
64 
65 /*
66  * Environment variable option handling
67  */
68 
69 const char *pcmk__env_option(const char *option);
70 void pcmk__set_env_option(const char *option, const char *value);
71 bool pcmk__env_option_enabled(const char *daemon, const char *option);
72 
73 
74 /*
75  * Cluster option handling
76  */
77 
78 typedef struct pcmk__cluster_option_s {
79  const char *name;
80  const char *alt_name;
81  const char *type;
82  const char *values;
83  const char *default_value;
84 
85  bool (*is_valid)(const char *);
86 
87  const char *description_short;
88  const char *description_long;
89 
91 
92 const char *pcmk__cluster_option(GHashTable *options,
93  pcmk__cluster_option_t *option_list, int len,
94  const char *name);
95 
96 void pcmk__print_option_metadata(const char *name, const char *version,
97  const char *desc_short, const char *desc_long,
98  pcmk__cluster_option_t *option_list, int len);
99 
100 void pcmk__validate_cluster_options(GHashTable *options,
101  pcmk__cluster_option_t *option_list,
102  int len);
103 
104 bool pcmk__valid_interval_spec(const char *value);
105 bool pcmk__valid_boolean(const char *value);
106 bool pcmk__valid_number(const char *value);
107 bool pcmk__valid_positive_number(const char *value);
108 bool pcmk__valid_quorum(const char *value);
109 bool pcmk__valid_script(const char *value);
110 bool pcmk__valid_utilization(const char *value);
111 
112 // from watchdog.c
113 long pcmk__get_sbd_timeout(void);
114 long pcmk__auto_watchdog_timeout(void);
115 bool pcmk__valid_sbd_timeout(const char *value);
116 
117 #endif // OPTIONS_INTERNAL__H
bool pcmk__valid_script(const char *value)
Definition: options.c:414
bool pcmk__valid_sbd_timeout(const char *value)
Definition: watchdog.c:239
enum crm_exit_e crm_exit_t
void pcmk__set_env_option(const char *option, const char *value)
Set or unset a Pacemaker environment variable option.
Definition: options.c:317
struct pcmk__cli_option_s pcmk__cli_option_t
#define _Noreturn
Definition: config.h:661
_Noreturn void pcmk__cli_help(char cmd, crm_exit_t exit_code)
Definition: options.c:191
const char * pcmk__env_option(const char *option)
Definition: options.c:284
struct pcmk__cluster_option_s pcmk__cluster_option_t
bool pcmk__valid_positive_number(const char *value)
Definition: options.c:398
pcmk__cli_option_flags
bool pcmk__valid_quorum(const char *value)
Definition: options.c:405
bool pcmk__valid_interval_spec(const char *value)
Definition: options.c:367
int daemon(int nochdir, int noclose)
long pcmk__auto_watchdog_timeout(void)
Definition: watchdog.c:231
void pcmk__set_cli_options(const char *short_options, const char *usage, pcmk__cli_option_t *long_options, const char *app_desc)
Definition: options.c:105
const char * pcmk__cluster_option(GHashTable *options, pcmk__cluster_option_t *option_list, int len, const char *name)
Definition: options.c:539
void pcmk__print_option_metadata(const char *name, const char *version, const char *desc_short, const char *desc_long, pcmk__cluster_option_t *option_list, int len)
Definition: options.c:558
bool pcmk__valid_utilization(const char *value)
Definition: options.c:441
bool(* is_valid)(const char *)
bool pcmk__valid_boolean(const char *value)
Definition: options.c:374
void pcmk__cli_option_cleanup(void)
Definition: options.c:39
int pcmk__next_cli_option(int argc, char **argv, int *index, const char **longname)
Definition: options.c:146
bool pcmk__valid_number(const char *value)
Definition: options.c:382
const char * description_short
void pcmk__validate_cluster_options(GHashTable *options, pcmk__cluster_option_t *option_list, int len)
Definition: options.c:596
char * name
Definition: pcmk_fence.c:30
long pcmk__get_sbd_timeout(void)
Definition: watchdog.c:220
uint32_t version
Definition: remote.c:147
bool pcmk__env_option_enabled(const char *daemon, const char *option)
Definition: options.c:354
const char * description_long