root/include/crm/common/options_internal.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   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 #  ifndef PCMK__CONFIG_H
  14 #    define PCMK__CONFIG_H
  15 #    include <config.h>   // HAVE_GETOPT, _Noreturn
  16 #  endif
  17 
  18 #  include <glib.h>     // GHashTable
  19 #  include <stdbool.h>  // bool
  20 
  21 /*
  22  * Command-line option handling
  23  *
  24  * This will all eventually go away as everything is converted to use GOption
  25  */
  26 
  27 #  ifdef HAVE_GETOPT_H
  28 #    include <getopt.h>
  29 #  else
  30 #    define no_argument 0
  31 #    define required_argument 1
  32 #  endif
  33 
  34 enum pcmk__cli_option_flags {
  35     pcmk__option_default    = (1 << 0),
  36     pcmk__option_hidden     = (1 << 1),
  37     pcmk__option_paragraph  = (1 << 2),
  38     pcmk__option_example    = (1 << 3),
  39 };
  40 
  41 typedef struct pcmk__cli_option_s {
  42     /* Fields from 'struct option' in getopt.h */
  43     /* name of long option */
  44     const char *name;
  45     /*
  46      * one of no_argument, required_argument, and optional_argument:
  47      * whether option takes an argument
  48      */
  49     int has_arg;
  50     /* if not NULL, set *flag to val when option found */
  51     int *flag;
  52     /* if flag not NULL, value to set *flag to; else return value */
  53     int val;
  54 
  55     /* Custom fields */
  56     const char *desc;
  57     long flags;
  58 } pcmk__cli_option_t;
  59 
  60 void pcmk__set_cli_options(const char *short_options, const char *usage,
  61                            pcmk__cli_option_t *long_options,
  62                            const char *app_desc);
  63 int pcmk__next_cli_option(int argc, char **argv, int *index,
  64                           const char **longname);
  65 _Noreturn void pcmk__cli_help(char cmd, crm_exit_t exit_code);
  66 void pcmk__cli_option_cleanup(void);
  67 
  68 
  69 /*
  70  * Environment variable option handling
  71  */
  72 
  73 const char *pcmk__env_option(const char *option);
  74 void pcmk__set_env_option(const char *option, const char *value);
  75 bool pcmk__env_option_enabled(const char *daemon, const char *option);
  76 
  77 
  78 /*
  79  * Cluster option handling
  80  */
  81 
  82 typedef struct pcmk__cluster_option_s {
  83     const char *name;
  84     const char *alt_name;
  85     const char *type;
  86     const char *values;
  87     const char *default_value;
  88 
  89     bool (*is_valid)(const char *);
  90 
  91     const char *description_short;
  92     const char *description_long;
  93 
  94 } pcmk__cluster_option_t;
  95 
  96 const char *pcmk__cluster_option(GHashTable *options,
  97                                  pcmk__cluster_option_t *option_list, int len,
  98                                  const char *name);
  99 
 100 void pcmk__print_option_metadata(const char *name, const char *version,
 101                                  const char *desc_short, const char *desc_long,
 102                                  pcmk__cluster_option_t *option_list, int len);
 103 
 104 void pcmk__validate_cluster_options(GHashTable *options,
 105                                     pcmk__cluster_option_t *option_list,
 106                                     int len);
 107 
 108 bool pcmk__valid_interval_spec(const char *value);
 109 bool pcmk__valid_boolean(const char *value);
 110 bool pcmk__valid_number(const char *value);
 111 bool pcmk__valid_positive_number(const char *value);
 112 bool pcmk__valid_quorum(const char *value);
 113 bool pcmk__valid_script(const char *value);
 114 bool pcmk__valid_utilization(const char *value);
 115 
 116 // from watchdog.c
 117 long pcmk__get_sbd_timeout(void);
 118 bool pcmk__get_sbd_sync_resource_startup(void);
 119 long pcmk__auto_watchdog_timeout(void);
 120 bool pcmk__valid_sbd_timeout(const char *value);
 121 
 122 #endif // OPTIONS_INTERNAL__H

/* [previous][next][first][last][top][bottom][index][help] */