int option_index = 0; static struct option long_options[] = {  {"daemon", 0, 0, 0}, {CRM_OPERATION_ERASE, 0, 0, 0}, {CRM_OPERATION_QUERY, 0, 0, 0}, {CRM_OPERATION_CREATE, 0, 0, 0}, {CRM_OPERATION_REPLACE, 0, 0, 0}, {CRM_OPERATION_STORE, 0, 0, 0}, {CRM_OPERATION_UPDATE, 0, 0, 0}, {CRM_OPERATION_DELETE, 0, 0, 0}, {"verbose", 0, 0, 'V'}, {"help", 0, 0, '?'}, {"reference", 1, 0, 0},   {"id", 1, 0, 'i'}, {"obj_type", 1, 0, 'o'},   {"reset", 1, 0, 'C'}, {"status", 1, 0, 'S'}, {"health", 0, 0, 'H'}, {"disconnect", 1, 0, 'A'}, {"unload_ha", 1, 0, 'U'}, {"migrate_from", 1, 0, 'M'}, {"migrate_res", 1, 0, 'I'}, {"elect_dc", 0, 0, 'E'}, {"whois_dc", 0, 0, 'W'}, {"recalc_tree", 0, 0, 'R'}, {"flush_recalc_tree", 0, 0, 'F'},  {0, 0, 0, 0} };
main(int argc, char **argv){	cl_log_set_entity(crm_system_name);	cl_log_enable_stderr(TRUE);	cl_log_set_facility(LOG_USER);	int argerr = 0;	int flag;	while (1) {		int option_index = 0;		static struct option long_options[] = {			// Top-level Options			{"daemon", 0, 0, 0},			{CRM_OPERATION_ERASE, 0, 0, 0},			{CRM_OPERATION_QUERY, 0, 0, 0},			{CRM_OPERATION_CREATE, 0, 0, 0},			{CRM_OPERATION_REPLACE, 0, 0, 0},			{CRM_OPERATION_STORE, 0, 0, 0},			{CRM_OPERATION_UPDATE, 0, 0, 0},			{CRM_OPERATION_DELETE, 0, 0, 0},			{"verbose", 0, 0, 'V'},			{"help", 0, 0, '?'},			{"reference", 1, 0, 0},			// common options			{"id", 1, 0, 'i'},			{"obj_type", 1, 0, 'o'},			// daemon options			{"reset", 1, 0, 'C'},			{"status", 1, 0, 'S'},			{"health", 0, 0, 'H'},			{"disconnect", 1, 0, 'A'},			{"unload_ha", 1, 0, 'U'},			{"migrate_from", 1, 0, 'M'},			{"migrate_res", 1, 0, 'I'},			{"elect_dc", 0, 0, 'E'},			{"whois_dc", 0, 0, 'W'},			{"recalc_tree", 0, 0, 'R'},			{"flush_recalc_tree", 0, 0, 'F'},			{0, 0, 0, 0}		};		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 (strcmp("daemon", long_options[option_index].name) == 0)					DO_DAEMON = TRUE;				else if (strcmp(CRM_OPERATION_ERASE,						long_options[option_index].name) == 0					 || strcmp(CRM_OPERATION_CREATE,						   long_options[option_index].name) == 0					 || strcmp(CRM_OPERATION_UPDATE,						   long_options[option_index].name) == 0					 || strcmp(CRM_OPERATION_DELETE,						   long_options[option_index].name) == 0					 || strcmp(CRM_OPERATION_REPLACE,						   long_options[option_index].name) == 0					 || strcmp(CRM_OPERATION_STORE,						   long_options[option_index].name) == 0					 || strcmp(CRM_OPERATION_QUERY,						   long_options[option_index].name) == 0){										cib_action = cl_strdup(long_options[option_index].name);				} else if (strcmp("reference",						  long_options[option_index].name) == 0) {					this_msg_reference =						cl_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 'V':				BE_VERBOSE = TRUE;				verbose = "true";				break;			case '?':				usage(crm_system_name, LSB_EXIT_OK);				break;			case 'i':				CRM_DEBUG3("Option %c => %s", flag, optarg);				id = cl_strdup(optarg);				break;			case 'o':				CRM_DEBUG3("Option %c => %s", flag, optarg);				obj_type = cl_strdup(optarg);				break;			case 'C':				printf("Option %c is not yet supported\n", flag);				++argerr;				break;			case 'S':				DO_HEALTH = TRUE;				status = cl_strdup(optarg);				break;			case 'H':				DO_HEALTH = TRUE;				break;			case 'A':				printf("Option %c is not yet supported\n", flag);				++argerr;				break;			case 'U':				printf("Option %c is not yet supported\n", flag);				++argerr;				break;			case 'M':				printf("Option %c is not yet supported\n", flag);				++argerr;				break;			case 'I':				printf("Option %c is not yet supported\n", flag);				++argerr;				break;			case 'E':				DO_ELECT_DC = TRUE;				printf("Option %c is not yet supported\n", flag);				++argerr;				break;			case 'W':				DO_WHOIS_DC = TRUE;				printf("Option %c is not yet supported\n", flag);				++argerr;				break;			case 'R':				DO_RECALC_TREE = TRUE;				printf("Option %c is not yet supported\n", flag);				++argerr;				break;			case 'F':				DO_FLUSH_RECALC = TRUE;				printf("Option %c is not yet supported\n", flag);				++argerr;				break;			default:				printf("?? getopt returned character code 0%o ??\n", 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);	}	ll_cluster_t *hb_cluster = do_init();	if (hb_cluster != NULL) {		if (do_work(hb_cluster) > 0) {			/* wait for the reply by creating a mainloop and running it until			 * the callbacks are invoked...			 */			mainloop = g_main_new(FALSE);			cl_log(LOG_INFO,			       "%s waiting for reply from the local CRM",			       crm_system_name);			g_main_run(mainloop);			return_to_orig_privs();		} else {			cl_log(LOG_ERR, "No message to send");			operation_status = -1;		}	} else {		cl_log(LOG_ERR,		       "Init failed, could not perform requested operations");		operation_status = -2;	}	cl_log(LOG_DEBUG, "%s exiting normally", crm_system_name);	return operation_status;}