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.
|
2004-11-28 20:09:25 +00:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* 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.
|
2004-11-22 01:38:40 +00:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
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"
|
|
|
|
#include "opal/mca/base/mca_base_param_internal.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;
|
|
|
|
|
2004-08-31 09:49:56 +00:00
|
|
|
int mca_base_parse_paramfile(const char *paramfile)
|
|
|
|
{
|
2008-07-31 20:00:45 +00:00
|
|
|
file_being_read = (char*)paramfile;
|
|
|
|
|
2006-01-16 01:48:03 +00:00
|
|
|
return opal_util_keyval_parse(paramfile, save_value);
|
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
|
|
|
{
|
2005-07-03 16:22:16 +00:00
|
|
|
opal_list_item_t *item;
|
2004-08-31 09:49:56 +00:00
|
|
|
mca_base_param_file_value_t *fv;
|
|
|
|
|
|
|
|
/* 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. */
|
|
|
|
|
2005-07-03 16:22:16 +00:00
|
|
|
for (item = opal_list_get_first(&mca_base_param_file_values);
|
|
|
|
opal_list_get_end(&mca_base_param_file_values) != item;
|
|
|
|
item = opal_list_get_next(item)) {
|
2004-08-31 09:49:56 +00:00
|
|
|
fv = (mca_base_param_file_value_t *) item;
|
|
|
|
if (0 == strcmp(name, fv->mbpfv_param)) {
|
2007-04-21 21:51:18 +00:00
|
|
|
if (NULL != fv->mbpfv_value ) {
|
|
|
|
free(fv->mbpfv_value);
|
|
|
|
}
|
|
|
|
if (NULL != value) {
|
|
|
|
fv->mbpfv_value = strdup(value);
|
|
|
|
} else {
|
|
|
|
fv->mbpfv_value = NULL;
|
|
|
|
}
|
2008-07-31 20:00:45 +00:00
|
|
|
fv->mbpfv_file = strdup(file_being_read);
|
2004-08-31 09:49:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We didn't already have the param, so append it to the list */
|
|
|
|
|
|
|
|
fv = OBJ_NEW(mca_base_param_file_value_t);
|
|
|
|
if (NULL != fv) {
|
2006-01-16 01:48:03 +00:00
|
|
|
fv->mbpfv_param = strdup(name);
|
2005-02-04 16:14:33 +00:00
|
|
|
if (NULL != value) {
|
|
|
|
fv->mbpfv_value = strdup(value);
|
|
|
|
} else {
|
|
|
|
fv->mbpfv_value = NULL;
|
|
|
|
}
|
2008-07-31 20:00:45 +00:00
|
|
|
fv->mbpfv_file = strdup(file_being_read);
|
2005-07-03 16:22:16 +00:00
|
|
|
opal_list_append(&mca_base_param_file_values, (opal_list_item_t*) fv);
|
2004-08-31 09:49:56 +00:00
|
|
|
}
|
|
|
|
}
|