cib_action = crm_strdup(CRM_OP_QUERY);
cib_action = crm_strdup(CRM_OP_CIB_QUERY); break; case 's': cib_action = crm_strdup(CRM_OP_CIB_SYNC);
main(int argc, char **argv){	int option_index = 0;	int argerr = 0;	int flag;	ll_cluster_t *hb_cluster = NULL;	int level = 0;	char *xml_text = NULL;		static struct option long_options[] = {		/* Top-level Options */		{CRM_OP_ERASE,   0, 0, 'E'},		{CRM_OP_QUERY,   0, 0, 'Q'},		{CRM_OP_CREATE,  0, 0, 'C'},		{CRM_OP_REPLACE, 0, 0, 'R'},		{CRM_OP_UPDATE,  0, 0, 'U'},		{CRM_OP_DELETE,  0, 0, 'D'},		{"xml",          1, 0, 'X'},		{"verbose",      0, 0, 'V'},		{"help",         0, 0, '?'},		{"reference",    1, 0, 0},		{"timeout", 1, 0, 't'},		/* common options */		{XML_ATTR_ID, 1, 0, 'i'},		{"obj_type", 1, 0, 'o'},		{0, 0, 0, 0}	};	if(argc < 2) {		usage(crm_system_name, LSB_EXIT_EINVAL);	}	/* Redirect messages from glib functions to our handler */	g_log_set_handler(NULL,			  G_LOG_LEVEL_ERROR      | G_LOG_LEVEL_CRITICAL			  | G_LOG_LEVEL_WARNING  | G_LOG_LEVEL_MESSAGE			  | G_LOG_LEVEL_INFO     | G_LOG_LEVEL_DEBUG			  | G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL,			  cl_glib_msg_handler, NULL);	/* and for good measure... */	g_log_set_always_fatal((GLogLevelFlags)0);    		cl_log_set_entity(crm_system_name);	cl_log_set_facility(LOG_USER);	while (1) {		flag = getopt_long(argc, argv, OPTARGS,				   long_options, &option_index);		if (flag == -1)			break;		switch(flag) {			case 0:				printf("option %s",				       long_options[option_index].name);				if (optarg)					printf(" with arg %s", optarg);				printf("\n");				if ((safe_str_eq(CRM_OP_ERASE,      long_options[option_index].name))	    || (safe_str_eq(CRM_OP_CREATE,  long_options[option_index].name))	    || (safe_str_eq(CRM_OP_UPDATE,  long_options[option_index].name))	    || (safe_str_eq(CRM_OP_DELETE,  long_options[option_index].name))	    || (safe_str_eq(CRM_OP_REPLACE, long_options[option_index].name))	    || (safe_str_eq(CRM_OP_QUERY,   long_options[option_index].name))){		cib_action = crm_strdup(long_options[option_index].name);						} else if (safe_str_eq("reference", long_options[option_index].name)) {		this_msg_reference = crm_strdup(optarg);	} else {		printf("Long option (--%s) is not (yet?) properly supported\n",		       long_options[option_index].name);		++argerr;	}	break;			/* a sample test for multiple instance   if (digit_optind != 0 && digit_optind != this_option_optind)   printf ("digits occur in two different argv-elements.\n");   digit_optind = this_option_optind;   printf ("option %c\n", c);*/							case 't':				message_timeout_ms = atoi(optarg);				if(message_timeout_ms < 1) {					message_timeout_ms = 30*1000;				}				break;							case 'E':				cib_action = crm_strdup(CRM_OP_ERASE);				break;			case 'Q':				cib_action = crm_strdup(CRM_OP_QUERY);				break;			case 'U':				cib_action = crm_strdup(CRM_OP_UPDATE);				break;			case 'R':				cib_action = crm_strdup(CRM_OP_REPLACE);				break;			case 'C':				cib_action = crm_strdup(CRM_OP_CREATE);				break;			case 'D':				cib_action = crm_strdup(CRM_OP_DELETE);				break;			case 'V':				level = get_crm_log_level();				BE_VERBOSE = TRUE;				verbose = XML_BOOLEAN_TRUE;				cl_log_enable_stderr(TRUE);				set_crm_log_level(level+1);				break;			case '?':				usage(crm_system_name, LSB_EXIT_OK);				break;			case 'i':				crm_verbose("Option %c => %s", flag, optarg);				id = crm_strdup(optarg);				break;			case 'o':				crm_verbose("Option %c => %s", flag, optarg);				obj_type = crm_strdup(optarg);				break;			case 'X':				xml_text = crm_strdup(optarg);				break;			default:				printf("Argument code 0%o (%c)"				       " is not (?yet?) supported\n",				       flag, flag);				++argerr;				break;		}	}	if (optind < argc) {		printf("non-option ARGV-elements: ");		while (optind < argc)			printf("%s ", argv[optind++]);		printf("\n");	}	if (optind > argc) {		++argerr;	}	if (argerr) {		usage(crm_system_name, LSB_EXIT_GENERIC);	}	hb_cluster = do_init();	if (hb_cluster != NULL) {		if (do_work(hb_cluster, xml_text) > 0) {			/* wait for the reply by creating a mainloop and running it until			 * the callbacks are invoked...			 */			mainloop = g_main_new(FALSE);			crm_info("%s waiting for reply from the local CRM",				 crm_system_name);			message_timer_id = Gmain_timeout_add(				message_timeout_ms, admin_message_timeout, NULL);						g_main_run(mainloop);			return_to_orig_privs();		} else {			crm_err("No message to send");			operation_status = -1;		}	} else {		crm_err("Init failed, could not perform requested operations");		operation_status = -2;	}	crm_debug("%s exiting normally", crm_system_name);	return operation_status;}