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.
|
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"
|
|
|
|
#include "opal/mca/base/mca_base_param_internal.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;
|
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
int mca_base_parse_paramfile(const char *paramfile)
|
|
|
|
{
|
2008-08-01 00:00:45 +04:00
|
|
|
file_being_read = (char*)paramfile;
|
|
|
|
|
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
|
|
|
{
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_item_t *item;
|
2004-08-31 13:49:56 +04: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 20:22:16 +04: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 13:49:56 +04:00
|
|
|
fv = (mca_base_param_file_value_t *) item;
|
|
|
|
if (0 == strcmp(name, fv->mbpfv_param)) {
|
2007-04-22 01:51:18 +04:00
|
|
|
if (NULL != fv->mbpfv_value ) {
|
|
|
|
free(fv->mbpfv_value);
|
|
|
|
}
|
|
|
|
if (NULL != value) {
|
|
|
|
fv->mbpfv_value = strdup(value);
|
|
|
|
} else {
|
|
|
|
fv->mbpfv_value = NULL;
|
|
|
|
}
|
2008-08-01 00:00:45 +04:00
|
|
|
fv->mbpfv_file = strdup(file_being_read);
|
2004-08-31 13:49:56 +04: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 04:48:03 +03:00
|
|
|
fv->mbpfv_param = strdup(name);
|
2005-02-04 19:14:33 +03:00
|
|
|
if (NULL != value) {
|
|
|
|
fv->mbpfv_value = strdup(value);
|
|
|
|
} else {
|
|
|
|
fv->mbpfv_value = NULL;
|
|
|
|
}
|
2008-08-01 00:00:45 +04:00
|
|
|
fv->mbpfv_file = strdup(file_being_read);
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_append(&mca_base_param_file_values, (opal_list_item_t*) fv);
|
2004-08-31 13:49:56 +04:00
|
|
|
}
|
|
|
|
}
|