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