GTRIGSource* G_main_add_tempproc_trigger(int priority , int (*triggerfun) (gpointer p) , const char * procname , gpointer userdata , void (*prefork)(gpointer p) , void (*postfork)(gpointer p) , void (*complete)(gpointer userdata, int status, int signo, int exitcode)) { struct tempproc_track* p; GTRIGSource* ret; p = (struct tempproc_track *) malloc(sizeof(struct tempproc_track)); if (p == NULL) { return NULL; } memset(p, 0, sizeof(*p)); p->procname = procname; p->fun = triggerfun; p->userdata = userdata; p->prefork = prefork; p->postfork = postfork; p->complete = complete; ret = G_main_add_TriggerHandler(priority , TempProcessTrigger, p, tempproc_destroy_notify); if (ret == NULL) { free(p); p = NULL; }else{ p->trigger = ret; } return ret; }
int main(int argc, char **argv) { int flag; int argerr = 0; const char *xml_file = NULL; crm_data_t *xml_graph = NULL; set_crm_log_level(0); /* crm_log_init("ttest"); */ 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... - this enum is a bit field (!) */ g_log_set_always_fatal((GLogLevelFlags)0); /*value out of range*/ set_crm_log_level(LOG_WARNING); transition_trigger = G_main_add_TriggerHandler( G_PRIORITY_LOW, te_graph_trigger, NULL, NULL); set_graph_functions(&ttest_graph_fns); while (1) { flag = getopt(argc, argv, OPTARGS); if (flag == -1) break; switch(flag) { case 'X': xml_file = crm_strdup(optarg); break; case 'V': cl_log_enable_stderr(TRUE); alter_debug(DEBUG_INC); 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) { crm_err("%d errors in option parsing", argerr); } crm_debug("=#=#=#=#= Getting XML =#=#=#=#="); if(xml_file != NULL) { FILE *xml_strm = fopen(xml_file, "r"); if(xml_strm) { xml_graph = file2xml(xml_strm, FALSE); fclose(xml_strm); } else { cl_perror("Could not open %s for reading", xml_file); xml_file = NULL; } } if(xml_file == NULL) { xml_graph = stdin2xml(); } #ifdef MTRACE mtrace(); #endif transition_graph = unpack_graph(xml_graph); trigger_graph(); print_graph(LOG_DEBUG, transition_graph); transition_graph->completion_action = tg_shutdown; mainloop = g_main_new(FALSE); g_main_run(mainloop); crm_info("Exiting ttest"); #ifdef MTRACE muntrace(); #endif crm_debug_4("Transition complete..."); return 0; }