else if (strcmp("erase", long_options[option_index].name) == 0) DO_ERASE  = TRUE;
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;	list_add =(str_list_t *) ha_malloc(sizeof(struct str_list_s));	list_add_last = list_add;	list_del =(str_list_t *) ha_malloc(sizeof(struct str_list_s));	list_del_last = list_del;	list_add->num_items = 0;	list_del->num_items = 0;	while (1) {		int option_index = 0;		static struct option long_options[] = {			// Top-level Options			{"daemon", 0, 0, 0},			{"query", 0, 0, 0},			{"create", 0, 0, 0},			{"modify", 0, 0, 0},			{"delete", 0, 0, 0},			{"instance", 1, 0, 0},	// undocumented, for testing only			{"node", 1, 0, 0},	// undocumented, for testing only			{"reference", 1, 0, 0},	// undocumented, for testing only			{"verbose", 0, 0, 'V'},			{"help", 0, 0, '?'},			// common options			{"id", 1, 0, 'i'},			{"obj_type", 1, 0, 'o'},			{"description", 1, 0, 'D'},			// 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'},			// create_modify options			{"subtype", 1, 0, 's'},			{"max_instances", 1, 0, 'm'},			{"list_add", 1, 0, 'a'},			{"list_del", 1, 0, 'd'},			{"list_wipe", 0, 0, 'w'},			{"clear", 1, 0, 'c'},			{"resource", 1, 0, 'r'},			{"priority", 1, 0, 'p'},			{"res_timeout", 1, 0, 't'},			{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("create",						long_options[option_index].name) == 0)					DO_CREATE = TRUE;				else if (strcmp("modify",						long_options[option_index].name) == 0)					DO_MODIFY = TRUE;				else if (strcmp("delete",						long_options[option_index].name) == 0)					DO_DELETE = TRUE;				else if (strcmp("query",						long_options[option_index].name) == 0)					DO_QUERY = TRUE;				else if (strcmp("instance",						long_options[option_index].name) == 0) {					instance = ha_strdup(optarg);				} else if (strcmp("reference",						  long_options[option_index].name) == 0) {					this_msg_reference =						ha_strdup(optarg);				} else if (strcmp("node",						  long_options[option_index].name) == 0) {					node = ha_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 = ha_strdup(optarg);				break;			case 'o':				CRM_DEBUG3("Option %c => %s", flag, optarg);				obj_type = ha_strdup(optarg);				break;			case 'D':				CRM_DEBUG3("Option %c => %s", flag, optarg);				description = ha_strdup(optarg);				break;			case 'C':				printf("Option %c is not yet supported\n", flag);				++argerr;				break;			case 'S':				DO_HEALTH = TRUE;				status = ha_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;			case 'm':				CRM_DEBUG3("Option %c => %s", flag, optarg);				max_instances = ha_strdup(optarg);				break;			case 'a':				CRM_DEBUG3("Option %c => %s", flag, optarg);				list_add->num_items++;				if (list_add->num_items != 1) {					list_add_last->next =						( str_list_t *) ha_malloc(sizeof(str_list_t));					list_add_last->value = ha_strdup(optarg);				}				list_add_last->next = NULL;				break;			case 'd':				CRM_DEBUG3("Option %c => %s", flag, optarg);				list_del->num_items++;				if (list_del->num_items != 1) {					list_del_last->next =						( str_list_t *) ha_malloc(sizeof(str_list_t));					list_add_last->value = ha_strdup(optarg);				}				list_del_last->next = NULL;				break;			case 'w':				list_wipe = TRUE;				break;			case 'c':				CRM_DEBUG3("Option %c => %s", flag, optarg);				clear = ha_strdup(optarg);				break;			case 'r':				if (num_resources > 1) {					printf("?? too many (> 2) resources ?? \n");					argerr++;					break;				}				resource[num_resources] = ha_strdup(optarg);				if (!resource[num_resources]) {					printf("?? resource[%d] option memory allocation "					       "failed ??\n", num_resources);					argerr++;				} else {					num_resources++;				}				break;			case 't':				CRM_DEBUG3("Option %c => %s", flag, optarg);				res_timeout = ha_strdup(optarg);				break;			case 'p':				CRM_DEBUG3("Option %c => %s", flag, optarg);				priority = ha_strdup(optarg);				break;			case 's':				CRM_DEBUG3("Option %c => %s", flag, optarg);				subtype = ha_strdup(optarg);				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;}