2004-08-31 13:49:56 +04:00
|
|
|
/*
|
2005-11-05 22:57:48 +03: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.
|
2004-11-28 23:09:25 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2013-03-28 01:09:41 +04:00
|
|
|
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
|
|
|
|
* reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-08-31 13:49:56 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "opal_config.h"
|
2004-08-31 13:49:56 +04:00
|
|
|
|
|
|
|
#include <stdio.h>
|
2004-11-05 10:52:30 +03:00
|
|
|
#include <string.h>
|
2004-08-31 13:49:56 +04:00
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
#include "opal/class/opal_list.h"
|
2005-08-13 00:46:25 +04:00
|
|
|
#include "opal/mca/mca.h"
|
|
|
|
#include "opal/mca/base/base.h"
|
2013-03-28 01:09:41 +04:00
|
|
|
#include "opal/mca/base/mca_base_vari.h"
|
2006-01-16 04:48:03 +03:00
|
|
|
#include "opal/util/keyval_parse.h"
|
2004-08-31 13:49:56 +04:00
|
|
|
|
2006-01-16 04:48:03 +03:00
|
|
|
static void save_value(const char *name, const char *value);
|
2004-08-31 13:49:56 +04:00
|
|
|
|
2008-08-01 00:00:45 +04:00
|
|
|
static char * file_being_read;
|
2013-03-28 01:09:41 +04:00
|
|
|
static opal_list_t * _param_list;
|
2008-08-01 00:00:45 +04:00
|
|
|
|
2013-03-28 01:09:41 +04:00
|
|
|
int mca_base_parse_paramfile(const char *paramfile, opal_list_t *list)
|
2004-08-31 13:49:56 +04:00
|
|
|
{
|
2008-08-01 00:00:45 +04:00
|
|
|
file_being_read = (char*)paramfile;
|
2013-03-28 01:09:41 +04:00
|
|
|
_param_list = list;
|
|
|
|
|
2006-01-16 04:48:03 +03:00
|
|
|
return opal_util_keyval_parse(paramfile, save_value);
|
2004-08-31 13:49:56 +04:00
|
|
|
}
|
|
|
|
|
2006-01-16 04:48:03 +03:00
|
|
|
static void save_value(const char *name, const char *value)
|
2004-08-31 13:49:56 +04:00
|
|
|
{
|
2013-03-28 01:09:41 +04:00
|
|
|
mca_base_var_file_value_t *fv;
|
|
|
|
bool found = false;
|
2004-08-31 13:49:56 +04: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-28 01:09:41 +04: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-22 01:51:18 +04:00
|
|
|
}
|
2013-03-28 01:09:41 +04:00
|
|
|
free (fv->mbvfv_file);
|
|
|
|
found = true;
|
|
|
|
break;
|
2004-08-31 13:49:56 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-28 01:09:41 +04: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 19:14:33 +03:00
|
|
|
}
|
2013-03-28 01:09:41 +04:00
|
|
|
|
|
|
|
fv->mbvfv_var = strdup(name);
|
|
|
|
opal_list_append(_param_list, &fv->super);
|
2004-08-31 13:49:56 +04:00
|
|
|
}
|
2013-03-28 01:09:41 +04:00
|
|
|
|
|
|
|
fv->mbvfv_value = value ? strdup(value) : NULL;
|
|
|
|
fv->mbvfv_file = file_being_read;
|
2004-08-31 13:49:56 +04:00
|
|
|
}
|