root/opal/mca/installdirs/env/opal_installdirs_env.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. installdirs_env_open

   1 /*
   2  * Copyright (c) 2006-2007 Los Alamos National Security, LLC.  All rights
   3  *                         reserved.
   4  * Copyright (c) 2007      Cisco Systems, Inc.  All rights reserved.
   5  * $COPYRIGHT$
   6  *
   7  * Additional copyrights may follow
   8  *
   9  * $HEADER$
  10  */
  11 
  12 #include "opal_config.h"
  13 
  14 #include <stdlib.h>
  15 #include <string.h>
  16 
  17 #include "opal/constants.h"
  18 #include "opal/mca/installdirs/installdirs.h"
  19 
  20 static int installdirs_env_open(void);
  21 
  22 
  23 opal_installdirs_base_component_t mca_installdirs_env_component = {
  24     /* First, the mca_component_t struct containing meta information
  25        about the component itself */
  26     {
  27         OPAL_INSTALLDIRS_BASE_VERSION_2_0_0,
  28 
  29         /* Component name and version */
  30         "env",
  31         OPAL_MAJOR_VERSION,
  32         OPAL_MINOR_VERSION,
  33         OPAL_RELEASE_VERSION,
  34 
  35         /* Component open and close functions */
  36         installdirs_env_open,
  37         NULL
  38     },
  39     {
  40         /* This component is checkpointable */
  41         MCA_BASE_METADATA_PARAM_CHECKPOINT
  42     },
  43 
  44     /* Next the opal_install_dirs_t install_dirs_data information */
  45     {
  46         NULL,
  47     },
  48 };
  49 
  50 
  51 #define SET_FIELD(field, envname)                                         \
  52     do {                                                                  \
  53         char *tmp = getenv(envname);                                      \
  54          if (NULL != tmp && 0 == strlen(tmp)) {                           \
  55              tmp = NULL;                                                  \
  56          }                                                                \
  57          mca_installdirs_env_component.install_dirs_data.field = tmp;     \
  58     } while (0)
  59 
  60 
  61 static int
  62 installdirs_env_open(void)
  63 {
  64     SET_FIELD(prefix, "OPAL_PREFIX");
  65     SET_FIELD(exec_prefix, "OPAL_EXEC_PREFIX");
  66     SET_FIELD(bindir, "OPAL_BINDIR");
  67     SET_FIELD(sbindir, "OPAL_SBINDIR");
  68     SET_FIELD(libexecdir, "OPAL_LIBEXECDIR");
  69     SET_FIELD(datarootdir, "OPAL_DATAROOTDIR");
  70     SET_FIELD(datadir, "OPAL_DATADIR");
  71     SET_FIELD(sysconfdir, "OPAL_SYSCONFDIR");
  72     SET_FIELD(sharedstatedir, "OPAL_SHAREDSTATEDIR");
  73     SET_FIELD(localstatedir, "OPAL_LOCALSTATEDIR");
  74     SET_FIELD(libdir, "OPAL_LIBDIR");
  75     SET_FIELD(includedir, "OPAL_INCLUDEDIR");
  76     SET_FIELD(infodir, "OPAL_INFODIR");
  77     SET_FIELD(mandir, "OPAL_MANDIR");
  78     SET_FIELD(opaldatadir, "OPAL_PKGDATADIR");
  79     SET_FIELD(opallibdir, "OPAL_PKGLIBDIR");
  80     SET_FIELD(opalincludedir, "OPAL_PKGINCLUDEDIR");
  81 
  82     return OPAL_SUCCESS;
  83 }

/* [<][>][^][v][top][bottom][index][help] */