message_timer_id = Gmain_timeout_add( message_timeout_ms, admin_message_timeout, NULL);
main(int argc, char **argv){	int option_index = 0;	int argerr = 0;	int flag;	ll_cluster_t *hb_cluster = NULL;	int level = 0;	static struct option long_options[] = {		/* Top-level Options */		{"verbose", 0, 0, 'V'},		{"help", 0, 0, '?'},		{"silent", 0, 0, 's'},		{"reference", 1, 0, 0},		/* daemon options */		{"kill", 1, 0, 'K'},  /* stop a node */		{"crm_debug_inc", 1, 0, 'i'},		{"crm_debug_dec", 1, 0, 'd'},		{"status", 1, 0, 'S'},		{"health", 0, 0, 'H'},		{"election", 0, 0, 'E'},		{"dc_lookup", 0, 0, 'D'},		{"resources", 0, 0, 'R'},		{"nodes", 0, 0, 'N'},		{"whereis", 1, 0, 'W'},		{0, 0, 0, 0}	};	/* 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);    		crm_system_name = basename(argv[0]);	cl_log_set_entity(crm_system_name);	cl_log_set_facility(LOG_USER);	if(argc < 2) {		usage(crm_system_name, LSB_EXIT_EINVAL);	}		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 (strcmp("reference",					   long_options[option_index].name) == 0) {					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 '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 'D':				DO_WHOIS_DC = TRUE;				break;			case 'W':				DO_RESOURCE = TRUE;				crm_verbose("Option %c => %s", flag, optarg);				rsc_name = crm_strdup(optarg);				break;			case 'K':				DO_RESET = TRUE;				crm_verbose("Option %c => %s", flag, optarg);				dest_node = crm_strdup(optarg);				break;			case 's':				BE_SILENT = TRUE;				break;			case 'i':				DO_DEBUG = debug_inc;				crm_verbose("Option %c => %s", flag, optarg);				dest_node = crm_strdup(optarg);				break;			case 'd':				DO_DEBUG = debug_dec;				crm_verbose("Option %c => %s", flag, optarg);				dest_node = crm_strdup(optarg);				break;			case 'S':				DO_HEALTH = TRUE;				crm_verbose("Option %c => %s", flag, optarg);				dest_node = crm_strdup(optarg);				break;			case 'E':				DO_ELECT_DC = TRUE;				break;			case 'N':				DO_NODE_LIST = TRUE;				break;			case 'R':				DO_RESOURCE_LIST = TRUE;				break;			case 'H':				DO_HEALTH = TRUE;				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) {		int res = do_work(hb_cluster);		if (res > 0) {			/* wait for the reply by creating a mainloop and running it until			 * the callbacks are invoked...			 */			mainloop = g_main_new(FALSE);			crm_verbose("%s waiting for reply from the local CRM",				 crm_system_name);			g_main_run(mainloop);			return_to_orig_privs();					} else if(res == 0) {			crm_verbose("%s: no reply expected",				 crm_system_name);					} else {			crm_err("No message to send");			operation_status = -1;		}	} else {		crm_err("Init failed, could not perform requested operations");		operation_status = -2;	}	crm_verbose("%s exiting normally", crm_system_name);	return operation_status;}