diff --git a/crm/pengine/ptest.c b/crm/pengine/ptest.c index b14ec55fb2..ea24f26a93 100644 --- a/crm/pengine/ptest.c +++ b/crm/pengine/ptest.c @@ -1,171 +1,175 @@ -/* $Id: ptest.c,v 1.56 2005/06/13 13:32:10 andrew Exp $ */ +/* $Id: ptest.c,v 1.57 2005/06/14 11:25:54 davidlee Exp $ */ /* * Copyright (C) 2004 Andrew Beekhof * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include #include #define OPTARGS "V?X:w" #ifdef HAVE_GETOPT_H # include #endif #include #include #include gboolean inhibit_exit = FALSE; extern crm_data_t * do_calculations( pe_working_set_t *data_set, crm_data_t *xml_input); extern void cleanup_calculations(pe_working_set_t *data_set); int main(int argc, char **argv) { pe_working_set_t data_set; crm_data_t * cib_object = NULL; int argerr = 0; int flag; char *msg_buffer = NULL; const char *xml_file = NULL; cl_log_set_entity("ptest"); cl_log_set_facility(LOG_USER); set_crm_log_level(LOG_CRIT-1); while (1) { +#ifdef HAVE_GETOPT_H int option_index = 0; static struct option long_options[] = { /* Top-level Options */ {F_CRM_DATA, 1, 0, 'X'}, {"help", 0, 0, 0}, {0, 0, 0, 0} }; +#endif #ifdef HAVE_GETOPT_H flag = getopt_long(argc, argv, OPTARGS, long_options, &option_index); #else flag = getopt(argc, argv, OPTARGS); #endif if (flag == -1) break; switch(flag) { +#ifdef HAVE_GETOPT_H case 0: printf("option %s", long_options[option_index].name); if (optarg) printf(" with arg %s", optarg); printf("\n"); break; +#endif case 'w': inhibit_exit = TRUE; break; 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_info("=#=#=#=#= Getting XML =#=#=#=#="); if(xml_file != NULL) { FILE *xml_strm = fopen(xml_file, "r"); cib_object = file2xml(xml_strm); } else { cib_object = stdin2xml(); } #ifdef MCHECK mtrace(); #endif CRM_DEV_ASSERT(cib_object != NULL); crm_zero_mem_stats(NULL); do_calculations(&data_set, cib_object); msg_buffer = dump_xml_formatted(data_set.graph); fprintf(stdout, "%s\n", msg_buffer); fflush(stdout); crm_free(msg_buffer); cleanup_calculations(&data_set); crm_mem_stats(NULL); CRM_DEV_ASSERT(crm_mem_stats(NULL) == FALSE); #ifdef MCHECK muntrace(); #endif free_xml(cib_object); /* required for MallocDebug.app */ if(inhibit_exit) { GMainLoop* mainloop = g_main_new(FALSE); g_main_run(mainloop); } return 0; }