This source file includes following definitions.
- main
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 
  13 
  14 
  15 
  16 
  17 
  18 
  19 
  20 
  21 
  22 
  23 
  24 
  25 
  26 #include "orte_config.h"
  27 
  28 #include <stdio.h>
  29 #include <string.h>
  30 #include <ctype.h>
  31 #ifdef HAVE_UNISTD_H
  32 #include <unistd.h>
  33 #endif
  34 #ifdef HAVE_NETDB_H
  35 #include <netdb.h>
  36 #endif
  37 #ifdef HAVE_SYS_PARAM_H
  38 #include <sys/param.h>
  39 #endif
  40 #include <errno.h>
  41 #include <signal.h>
  42 
  43 #include "opal/mca/installdirs/installdirs.h"
  44 #include "opal/class/opal_object.h"
  45 #include "opal/class/opal_pointer_array.h"
  46 #include "opal/runtime/opal.h"
  47 #include "opal/runtime/opal_info_support.h"
  48 #include "opal/util/cmd_line.h"
  49 #include "opal/util/error.h"
  50 #include "opal/util/argv.h"
  51 #include "opal/mca/base/base.h"
  52 #include "opal/util/show_help.h"
  53 
  54 #include "orte/constants.h"
  55 #include "orte/util/show_help.h"
  56 #include "orte/runtime/orte_info_support.h"
  57 #include "orte/runtime/orte_locks.h"
  58 
  59 #include "orte/tools/orte-info/orte-info.h"
  60 
  61 
  62 
  63 
  64 
  65 bool orte_info_pretty = true;
  66 opal_cmd_line_t *orte_info_cmd_line = NULL;
  67 
  68 const char *orte_info_type_all = "all";
  69 const char *orte_info_type_opal = "opal";
  70 const char *orte_info_type_base = "base";
  71 
  72 opal_pointer_array_t mca_types = {{0}};
  73 
  74 int main(int argc, char *argv[])
  75 {
  76     int ret = 0;
  77     bool want_help = false;
  78     bool cmd_error = false;
  79     bool acted = false;
  80     bool want_all = false;
  81     char **app_env = NULL, **global_env = NULL;
  82     int i, len;
  83     char *str;
  84 
  85     
  86 
  87     signal(SIGPIPE, SIG_IGN);
  88 
  89     
  90     if (ORTE_SUCCESS != opal_init_util(&argc, &argv)) {
  91         orte_show_help("help-orte-info.txt", "lib-call-fail", true,
  92                        "opal_init_util", __FILE__, __LINE__, NULL);
  93         exit(ret);
  94     }
  95 
  96     orte_info_cmd_line = OBJ_NEW(opal_cmd_line_t);
  97     if (NULL == orte_info_cmd_line) {
  98         ret = errno;
  99         orte_show_help("help-orte-info.txt", "lib-call-fail", true,
 100                        "opal_cmd_line_create", __FILE__, __LINE__, NULL);
 101         opal_finalize_util();
 102         exit(ret);
 103     }
 104 
 105     opal_cmd_line_make_opt3(orte_info_cmd_line, 'v', NULL, "version", 2,
 106                             "Show version of ORTE or a component.  The first parameter can be the keywords \"orte\" or \"all\", a framework name (indicating all components in a framework), or a framework:component string (indicating a specific component).  The second parameter can be one of: full, major, minor, release, greek, svn.");
 107     opal_cmd_line_make_opt3(orte_info_cmd_line, '\0', NULL, "param", 2,
 108                             "Show MCA parameters.  The first parameter is the framework (or the keyword \"all\"); the second parameter is the specific component name (or the keyword \"all\").");
 109     opal_cmd_line_make_opt3(orte_info_cmd_line, '\0', NULL, "internal", 0,
 110                             "Show internal MCA parameters (not meant to be modified by users)");
 111     opal_cmd_line_make_opt3(orte_info_cmd_line, '\0', NULL, "path", 1,
 112                             "Show paths that Open MPI was configured with.  Accepts the following parameters: prefix, bindir, libdir, incdir, mandir, pkglibdir, sysconfdir");
 113     opal_cmd_line_make_opt3(orte_info_cmd_line, '\0', NULL, "arch", 0,
 114                             "Show architecture Open MPI was corteled on");
 115     opal_cmd_line_make_opt3(orte_info_cmd_line, 'c', NULL, "config", 0,
 116                             "Show configuration options");
 117     opal_cmd_line_make_opt3(orte_info_cmd_line, 'h', NULL, "help", 0,
 118                             "Show this help message");
 119     opal_cmd_line_make_opt3(orte_info_cmd_line, '\0', NULL, "orte_info_pretty", 0,
 120                             "When used in conjunction with other parameters, the output is displayed in 'orte_info_prettyprint' format (default)");
 121     opal_cmd_line_make_opt3(orte_info_cmd_line, '\0', NULL, "parsable", 0,
 122                             "When used in conjunction with other parameters, the output is displayed in a machine-parsable format");
 123     opal_cmd_line_make_opt3(orte_info_cmd_line, '\0', NULL, "parseable", 0,
 124                             "Synonym for --parsable");
 125     opal_cmd_line_make_opt3(orte_info_cmd_line, '\0', NULL, "hostname", 0,
 126                             "Show the hostname that Open MPI was configured "
 127                             "and built on");
 128     opal_cmd_line_make_opt3(orte_info_cmd_line, 'a', NULL, "all", 0,
 129                             "Show all configuration options and MCA parameters");
 130 
 131     
 132 
 133 
 134 
 135 
 136     if (ORTE_SUCCESS != orte_locks_init()) {
 137         
 138         ++ret;
 139     } else {
 140         --ret;
 141     }
 142 
 143     
 144     opal_set_using_threads(false);
 145 
 146     
 147 
 148     if( ORTE_SUCCESS != mca_base_open() ) {
 149         orte_show_help("help-orte-info.txt", "lib-call-fail", true, "mca_base_open", __FILE__, __LINE__ );
 150         OBJ_RELEASE(orte_info_cmd_line);
 151         opal_finalize_util();
 152         exit(1);
 153     }
 154     mca_base_cmd_line_setup(orte_info_cmd_line);
 155 
 156     
 157 
 158     ret = opal_cmd_line_parse(orte_info_cmd_line, false, false, argc, argv);
 159     if (OPAL_SUCCESS != ret) {
 160         if (OPAL_ERR_SILENT != ret) {
 161             fprintf(stderr, "%s: command line error (%s)\n", argv[0],
 162                     opal_strerror(ret));
 163         }
 164         cmd_error = true;
 165     }
 166     if (!cmd_error &&
 167         (opal_cmd_line_is_taken(orte_info_cmd_line, "help") ||
 168          opal_cmd_line_is_taken(orte_info_cmd_line, "h"))) {
 169         char *str, *usage;
 170 
 171         want_help = true;
 172         usage = opal_cmd_line_get_usage_msg(orte_info_cmd_line);
 173         str = opal_show_help_string("help-orte-info.txt", "usage", true,
 174                                     usage);
 175         if (NULL != str) {
 176             printf("%s", str);
 177             free(str);
 178         }
 179         free(usage);
 180     }
 181     if (cmd_error || want_help) {
 182         mca_base_close();
 183         OBJ_RELEASE(orte_info_cmd_line);
 184         opal_finalize_util();
 185         exit(cmd_error ? 1 : 0);
 186     }
 187 
 188     mca_base_cmd_line_process_args(orte_info_cmd_line, &app_env, &global_env);
 189 
 190     
 191 
 192 
 193 
 194 
 195 
 196     len = opal_argv_count(app_env);
 197     for (i = 0; i < len; ++i) {
 198         putenv(app_env[i]);
 199     }
 200     len = opal_argv_count(global_env);
 201     for (i = 0; i < len; ++i) {
 202         putenv(global_env[i]);
 203     }
 204 
 205     
 206     OBJ_CONSTRUCT(&mca_types, opal_pointer_array_t);
 207     opal_pointer_array_init(&mca_types, 256, INT_MAX, 128);
 208 
 209     opal_info_register_types(&mca_types);
 210     orte_info_register_types(&mca_types);
 211 
 212     
 213 
 214     if (opal_cmd_line_is_taken(orte_info_cmd_line, "orte_info_pretty")) {
 215         orte_info_pretty = true;
 216     } else if (opal_cmd_line_is_taken(orte_info_cmd_line, "parsable") || opal_cmd_line_is_taken(orte_info_cmd_line, "parseable")) {
 217         orte_info_pretty = false;
 218     }
 219 
 220     want_all = opal_cmd_line_is_taken(orte_info_cmd_line, "all");
 221     if (want_all || opal_cmd_line_is_taken(orte_info_cmd_line, "version")) {
 222         orte_info_do_version(want_all, orte_info_cmd_line);
 223         acted = true;
 224     }
 225     if (want_all || opal_cmd_line_is_taken(orte_info_cmd_line, "path")) {
 226         orte_info_do_path(want_all, orte_info_cmd_line);
 227         acted = true;
 228     }
 229     if (want_all || opal_cmd_line_is_taken(orte_info_cmd_line, "arch")) {
 230         orte_info_do_arch();
 231         acted = true;
 232     }
 233     if (want_all || opal_cmd_line_is_taken(orte_info_cmd_line, "hostname")) {
 234         orte_info_do_hostname();
 235         acted = true;
 236     }
 237     if (want_all || opal_cmd_line_is_taken(orte_info_cmd_line, "config")) {
 238         orte_info_do_config(true);
 239         acted = true;
 240     }
 241     if (want_all || opal_cmd_line_is_taken(orte_info_cmd_line, "param")) {
 242         orte_info_do_params(want_all, opal_cmd_line_is_taken(orte_info_cmd_line, "internal"));
 243         acted = true;
 244     }
 245 
 246     
 247 
 248     if (!acted) {
 249         orte_info_show_orte_version(orte_info_ver_full);
 250         orte_info_show_path(orte_info_path_prefix, opal_install_dirs.prefix);
 251         orte_info_do_arch();
 252         orte_info_do_hostname();
 253         orte_info_do_config(false);
 254         orte_info_components_open();
 255         for (i = 0; i < mca_types.size; ++i) {
 256             if (NULL == (str = (char*)opal_pointer_array_get_item(&mca_types, i))) {
 257                 continue;
 258             }
 259             orte_info_show_component_version(str, orte_info_component_all,
 260                                              orte_info_ver_full, orte_info_type_all);
 261         }
 262     }
 263 
 264     
 265 
 266     if (NULL != app_env) {
 267         opal_argv_free(app_env);
 268     }
 269     if (NULL != global_env) {
 270         opal_argv_free(global_env);
 271     }
 272     orte_info_components_close ();
 273     OBJ_RELEASE(orte_info_cmd_line);
 274     OBJ_DESTRUCT(&mca_types);
 275     mca_base_close();
 276 
 277     opal_finalize_util();
 278 
 279     return 0;
 280 }