2013-09-21 18:53:36 +00:00
|
|
|
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
2004-08-31 09:49:56 +00:00
|
|
|
/*
|
2005-11-05 19:57:48 +00:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2015-06-23 20:59:57 -07:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
2004-11-28 20:09:25 +00:00
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 12:43:37 +00:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2013-03-27 21:09:41 +00:00
|
|
|
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
|
|
|
|
* reserved.
|
2004-11-22 01:38:40 +00:00
|
|
|
* $COPYRIGHT$
|
2015-06-23 20:59:57 -07:00
|
|
|
*
|
2004-11-22 01:38:40 +00:00
|
|
|
* Additional copyrights may follow
|
2015-06-23 20:59:57 -07:00
|
|
|
*
|
2004-08-31 09:49:56 +00:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2006-02-12 01:33:29 +00:00
|
|
|
#include "opal_config.h"
|
2004-08-31 09:49:56 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
2004-11-05 07:52:30 +00:00
|
|
|
#include <string.h>
|
2004-08-31 09:49:56 +00:00
|
|
|
|
2005-07-03 16:22:16 +00:00
|
|
|
#include "opal/class/opal_list.h"
|
2005-08-12 20:46:25 +00:00
|
|
|
#include "opal/mca/mca.h"
|
|
|
|
#include "opal/mca/base/base.h"
|
2013-03-27 21:09:41 +00:00
|
|
|
#include "opal/mca/base/mca_base_vari.h"
|
2006-01-16 01:48:03 +00:00
|
|
|
#include "opal/util/keyval_parse.h"
|
2004-08-31 09:49:56 +00:00
|
|
|
|
2006-01-16 01:48:03 +00:00
|
|
|
static void save_value(const char *name, const char *value);
|
2004-08-31 09:49:56 +00:00
|
|
|
|
2008-07-31 20:00:45 +00:00
|
|
|
static char * file_being_read;
|
2013-03-27 21:09:41 +00:00
|
|
|
static opal_list_t * _param_list;
|
2008-07-31 20:00:45 +00:00
|
|
|
|
2013-03-27 21:09:41 +00:00
|
|
|
int mca_base_parse_paramfile(const char *paramfile, opal_list_t *list)
|
2004-08-31 09:49:56 +00:00
|
|
|
{
|
2008-07-31 20:00:45 +00:00
|
|
|
file_being_read = (char*)paramfile;
|
2013-03-27 21:09:41 +00:00
|
|
|
_param_list = list;
|
|
|
|
|
2006-01-16 01:48:03 +00:00
|
|
|
return opal_util_keyval_parse(paramfile, save_value);
|
2004-08-31 09:49:56 +00:00
|
|
|
}
|
|
|
|
|
2015-03-16 18:03:55 +02:00
|
|
|
int mca_base_internal_env_store(void)
|
|
|
|
{
|
|
|
|
return opal_util_keyval_save_internal_envars(save_value);
|
|
|
|
}
|
|
|
|
|
2006-01-16 01:48:03 +00:00
|
|
|
static void save_value(const char *name, const char *value)
|
2004-08-31 09:49:56 +00:00
|
|
|
{
|
2013-03-27 21:09:41 +00:00
|
|
|
mca_base_var_file_value_t *fv;
|
|
|
|
bool found = false;
|
2004-08-31 09:49:56 +00:00
|
|
|
|
|
|
|
/* First traverse through the list and ensure that we don't
|
|
|
|
already have a param of this name. If we do, just replace the
|
|
|
|
value. */
|
|
|
|
|
2013-03-27 21:09:41 +00:00
|
|
|
OPAL_LIST_FOREACH(fv, _param_list, mca_base_var_file_value_t) {
|
|
|
|
if (0 == strcmp(name, fv->mbvfv_var)) {
|
|
|
|
if (NULL != fv->mbvfv_value) {
|
|
|
|
free (fv->mbvfv_value);
|
2007-04-21 21:51:18 +00:00
|
|
|
}
|
2013-03-27 21:09:41 +00:00
|
|
|
found = true;
|
|
|
|
break;
|
2004-08-31 09:49:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-27 21:09:41 +00:00
|
|
|
if (!found) {
|
|
|
|
/* We didn't already have the param, so append it to the list */
|
|
|
|
fv = OBJ_NEW(mca_base_var_file_value_t);
|
|
|
|
if (NULL == fv) {
|
|
|
|
return;
|
2005-02-04 16:14:33 +00:00
|
|
|
}
|
2013-03-27 21:09:41 +00:00
|
|
|
|
|
|
|
fv->mbvfv_var = strdup(name);
|
|
|
|
opal_list_append(_param_list, &fv->super);
|
2004-08-31 09:49:56 +00:00
|
|
|
}
|
2013-03-27 21:09:41 +00:00
|
|
|
|
|
|
|
fv->mbvfv_value = value ? strdup(value) : NULL;
|
|
|
|
fv->mbvfv_file = file_being_read;
|
2015-05-12 08:55:47 -06:00
|
|
|
fv->mbvfv_lineno = opal_util_keyval_parse_lineno;
|
2004-08-31 09:49:56 +00:00
|
|
|
}
|