@@ -111,13 +111,6 @@ struct {
111111 .rsc_cmd = cmd_list_resources , // List all resources if no command given
112112};
113113
114- gboolean attr_set_type_cb (const gchar * option_name , const gchar * optarg , gpointer data , GError * * error );
115- gboolean cmdline_config_cb (const gchar * option_name , const gchar * optarg ,
116- gpointer data , GError * * error );
117- gboolean option_cb (const gchar * option_name , const gchar * optarg ,
118- gpointer data , GError * * error );
119- gboolean timeout_cb (const gchar * option_name , const gchar * optarg , gpointer data , GError * * error );
120-
121114static crm_exit_t exit_code = CRM_EX_OK ;
122115static pcmk__output_t * out = NULL ;
123116static pcmk__common_args_t * args = NULL ;
@@ -262,6 +255,39 @@ validate_opt_list(const gchar *optarg)
262255 return TRUE;
263256}
264257
258+ // GOptionArgFunc callback functions
259+
260+ static gboolean
261+ attr_set_type_cb (const gchar * option_name , const gchar * optarg , gpointer data ,
262+ GError * * error ) {
263+ if (pcmk__str_any_of (option_name , "-m" , "--meta" , NULL )) {
264+ options .attr_set_type = PCMK_XE_META_ATTRIBUTES ;
265+ } else if (pcmk__str_any_of (option_name , "-z" , "--utilization" , NULL )) {
266+ options .attr_set_type = PCMK_XE_UTILIZATION ;
267+ } else if (pcmk__str_eq (option_name , "--element" , pcmk__str_none )) {
268+ options .attr_set_type = ATTR_SET_ELEMENT ;
269+ }
270+ return TRUE;
271+ }
272+
273+ static gboolean
274+ cmdline_config_cb (const gchar * option_name , const gchar * optarg , gpointer data ,
275+ GError * * error )
276+ {
277+ options .cmdline_config = true;
278+
279+ if (pcmk__str_eq (option_name , "--class" , pcmk__str_none )) {
280+ pcmk__str_update (& options .v_class , optarg );
281+
282+ } else if (pcmk__str_eq (option_name , "--provider" , pcmk__str_none )) {
283+ pcmk__str_update (& options .v_provider , optarg );
284+
285+ } else { // --agent
286+ pcmk__str_update (& options .v_agent , optarg );
287+ }
288+ return TRUE;
289+ }
290+
265291/*!
266292 * \internal
267293 * \brief Process options that set the command
@@ -414,6 +440,46 @@ command_cb(const gchar *option_name, const gchar *optarg, gpointer data,
414440 return TRUE;
415441}
416442
443+ static gboolean
444+ option_cb (const gchar * option_name , const gchar * optarg , gpointer data ,
445+ GError * * error )
446+ {
447+ gchar * name = NULL ;
448+ gchar * value = NULL ;
449+
450+ if (pcmk__scan_nvpair (optarg , & name , & value ) != pcmk_rc_ok ) {
451+ return FALSE;
452+ }
453+
454+ /* services__create_resource_action() ultimately takes ownership of
455+ * options.cmdline_params. It's not worth trying to ensure that the entire
456+ * call path uses (gchar *) strings and g_free(). So create the table for
457+ * (char *) strings, and duplicate the (gchar *) strings when inserting.
458+ */
459+ if (options .cmdline_params == NULL ) {
460+ options .cmdline_params = pcmk__strkey_table (free , free );
461+ }
462+ pcmk__insert_dup (options .cmdline_params , name , value );
463+ g_free (name );
464+ g_free (value );
465+ return TRUE;
466+ }
467+
468+ static gboolean
469+ timeout_cb (const gchar * option_name , const gchar * optarg , gpointer data ,
470+ GError * * error )
471+ {
472+ long long timeout_ms = crm_get_msec (optarg );
473+
474+ if (timeout_ms < 0 ) {
475+ return FALSE;
476+ }
477+ options .timeout_ms = (guint ) QB_MIN (timeout_ms , UINT_MAX );
478+ return TRUE;
479+ }
480+
481+ // Command line option specification
482+
417483/* short option letters still available: eEJkKXyYZ */
418484
419485static GOptionEntry query_entries [] = {
@@ -732,72 +798,6 @@ static GOptionEntry addl_entries[] = {
732798 { NULL }
733799};
734800
735- gboolean
736- attr_set_type_cb (const gchar * option_name , const gchar * optarg , gpointer data , GError * * error ) {
737- if (pcmk__str_any_of (option_name , "-m" , "--meta" , NULL )) {
738- options .attr_set_type = PCMK_XE_META_ATTRIBUTES ;
739- } else if (pcmk__str_any_of (option_name , "-z" , "--utilization" , NULL )) {
740- options .attr_set_type = PCMK_XE_UTILIZATION ;
741- } else if (pcmk__str_eq (option_name , "--element" , pcmk__str_none )) {
742- options .attr_set_type = ATTR_SET_ELEMENT ;
743- }
744- return TRUE;
745- }
746-
747- gboolean
748- cmdline_config_cb (const gchar * option_name , const gchar * optarg , gpointer data ,
749- GError * * error )
750- {
751- options .cmdline_config = true;
752-
753- if (pcmk__str_eq (option_name , "--class" , pcmk__str_none )) {
754- pcmk__str_update (& options .v_class , optarg );
755-
756- } else if (pcmk__str_eq (option_name , "--provider" , pcmk__str_none )) {
757- pcmk__str_update (& options .v_provider , optarg );
758-
759- } else { // --agent
760- pcmk__str_update (& options .v_agent , optarg );
761- }
762- return TRUE;
763- }
764-
765- gboolean
766- option_cb (const gchar * option_name , const gchar * optarg , gpointer data ,
767- GError * * error )
768- {
769- gchar * name = NULL ;
770- gchar * value = NULL ;
771-
772- if (pcmk__scan_nvpair (optarg , & name , & value ) != pcmk_rc_ok ) {
773- return FALSE;
774- }
775-
776- /* services__create_resource_action() ultimately takes ownership of
777- * options.cmdline_params. It's not worth trying to ensure that the entire
778- * call path uses (gchar *) strings and g_free(). So create the table for
779- * (char *) strings, and duplicate the (gchar *) strings when inserting.
780- */
781- if (options .cmdline_params == NULL ) {
782- options .cmdline_params = pcmk__strkey_table (free , free );
783- }
784- pcmk__insert_dup (options .cmdline_params , name , value );
785- g_free (name );
786- g_free (value );
787- return TRUE;
788- }
789-
790- gboolean
791- timeout_cb (const gchar * option_name , const gchar * optarg , gpointer data , GError * * error ) {
792- long long timeout_ms = crm_get_msec (optarg );
793-
794- if (timeout_ms < 0 ) {
795- return FALSE;
796- }
797- options .timeout_ms = (guint ) QB_MIN (timeout_ms , UINT_MAX );
798- return TRUE;
799- }
800-
801801static int
802802ban_or_move (pcmk__output_t * out , pcmk_resource_t * rsc ,
803803 const char * move_lifetime )
0 commit comments