Add some new utilities that support searching an environ string list (not just our own environ) for specific MCA params and returning their value. Helpful when a daemon needs to check an app_context's environ for params that can impact how the daemon launches and/or interacts with it, but don't pertain to the daemon's own environ.
This commit was SVN r23034.
Этот коммит содержится в:
родитель
e3164d2ac1
Коммит
e1b9f400ba
@ -2191,3 +2191,98 @@ static void syn_info_destructor(syn_info_t *si)
|
||||
|
||||
syn_info_constructor(si);
|
||||
}
|
||||
|
||||
int mca_base_param_find_int(const mca_base_component_t *component,
|
||||
const char *param_name,
|
||||
char **env,
|
||||
int *current_value)
|
||||
{
|
||||
char *tmp, *ptr;
|
||||
int len, i;
|
||||
int rc=OPAL_ERR_NOT_FOUND;
|
||||
|
||||
asprintf(&tmp, "%s_%s_%s_%s", mca_prefix, component->mca_type_name,
|
||||
component->mca_component_name, param_name);
|
||||
len = strlen(tmp);
|
||||
for (i=0; NULL != env[i]; i++) {
|
||||
if (0 == strncmp(tmp, env[i], len)) {
|
||||
ptr = &env[i][len];
|
||||
*current_value = strtol(ptr, NULL, 10);
|
||||
rc = OPAL_SUCCESS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(tmp);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int mca_base_param_find_int_name(const char *type,
|
||||
const char *param_name,
|
||||
char **env,
|
||||
int *current_value)
|
||||
{
|
||||
char *tmp, *ptr;
|
||||
int len, i;
|
||||
int rc=OPAL_ERR_NOT_FOUND;
|
||||
|
||||
asprintf(&tmp, "%s_%s_%s", mca_prefix, type, param_name);
|
||||
len = strlen(tmp);
|
||||
for (i=0; NULL != env[i]; i++) {
|
||||
if (0 == strncmp(tmp, env[i], len)) {
|
||||
ptr = &env[i][len];
|
||||
*current_value = strtol(ptr, NULL, 10);
|
||||
rc = OPAL_SUCCESS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(tmp);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int mca_base_param_find_string(const mca_base_component_t *component,
|
||||
const char *param_name,
|
||||
char **env,
|
||||
char **current_value)
|
||||
{
|
||||
char *tmp, *ptr;
|
||||
int len, i;
|
||||
int rc=OPAL_ERR_NOT_FOUND;
|
||||
|
||||
asprintf(&tmp, "%s_%s_%s_%s", mca_prefix, component->mca_type_name,
|
||||
component->mca_component_name, param_name);
|
||||
len = strlen(tmp);
|
||||
for (i=0; NULL != env[i]; i++) {
|
||||
if (0 == strncmp(tmp, env[i], len)) {
|
||||
ptr = &env[i][len];
|
||||
*current_value = ptr;
|
||||
rc = OPAL_SUCCESS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(tmp);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int mca_base_param_find_string_name(const char *type,
|
||||
const char *param_name,
|
||||
char **env,
|
||||
char **current_value)
|
||||
{
|
||||
char *tmp, *ptr;
|
||||
int len, i;
|
||||
int rc=OPAL_ERR_NOT_FOUND;
|
||||
|
||||
asprintf(&tmp, "%s_%s_%s", mca_prefix, type, param_name);
|
||||
len = strlen(tmp);
|
||||
for (i=0; NULL != env[i]; i++) {
|
||||
if (0 == strncmp(tmp, env[i], len)) {
|
||||
ptr = &env[i][len];
|
||||
*current_value = ptr;
|
||||
rc = OPAL_SUCCESS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(tmp);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -636,6 +636,85 @@ BEGIN_C_DECLS
|
||||
const char *component,
|
||||
const char *param);
|
||||
|
||||
/**
|
||||
* Find an MCA parameter in an env array based on its names.
|
||||
*
|
||||
* @param component [in] Pointer to the component for which the
|
||||
* parameter was registered.
|
||||
* @param param_name [in] The name of the parameter being
|
||||
* registered (string).
|
||||
* @param env [in] NULL-terminated list of strings (e.g., from an environment).
|
||||
* @param current_value [out] Return the current value (if found).
|
||||
*
|
||||
* @retval OPAL_ERROR If the parameter was not found.
|
||||
*
|
||||
* Look for a specific MCA parameter in an environment and return its value
|
||||
*/
|
||||
OPAL_DECLSPEC int mca_base_param_find_int(const mca_base_component_t *component,
|
||||
const char *param_name,
|
||||
char **env,
|
||||
int *current_value);
|
||||
|
||||
/**
|
||||
* Find an MCA parameter (in an env array) that is not associated with a
|
||||
* component.
|
||||
*
|
||||
* @param type [in] Although this parameter is not associated with
|
||||
* a component, it still must have a string type name that will
|
||||
* act as a prefix (string).
|
||||
* @param param_name [in] The name of the parameter being
|
||||
* registered (string).
|
||||
* @param env [in] NULL-terminated list of strings (e.g., from an environment).
|
||||
* @param current_value [out] Return the current value (if found).
|
||||
*
|
||||
* @retval OPAL_ERROR If the parameter was not found.
|
||||
*
|
||||
* Look for a specific MCA parameter in an environment and return its value
|
||||
*/
|
||||
OPAL_DECLSPEC int mca_base_param_find_int_name(const char *type,
|
||||
const char *param_name,
|
||||
char **env,
|
||||
int *current_value);
|
||||
/**
|
||||
* Find a string MCA parameter in an env array based on its names.
|
||||
*
|
||||
* @param component [in] Pointer to the component for which the
|
||||
* parameter was registered.
|
||||
* @param param_name [in] The name of the parameter being
|
||||
* registered (string).
|
||||
* @param env [in] NULL-terminated list of strings (e.g., from an environment).
|
||||
* @param current_value [out] Return the current value (if found).
|
||||
*
|
||||
* @retval OPAL_ERROR If the parameter was not found.
|
||||
*
|
||||
* Look for a specific MCA parameter in an environment and return its value
|
||||
*/
|
||||
OPAL_DECLSPEC int mca_base_param_find_string(const mca_base_component_t *component,
|
||||
const char *param_name,
|
||||
char **env,
|
||||
char **current_value);
|
||||
|
||||
/**
|
||||
* Find a string MCA parameter (in an env array) that is not associated with a
|
||||
* component.
|
||||
*
|
||||
* @param type [in] Although this parameter is not associated with
|
||||
* a component, it still must have a string type name that will
|
||||
* act as a prefix (string).
|
||||
* @param param_name [in] The name of the parameter being
|
||||
* registered (string).
|
||||
* @param env [in] NULL-terminated list of strings (e.g., from an environment).
|
||||
* @param current_value [out] Return the current value (if found).
|
||||
*
|
||||
* @retval OPAL_ERROR If the parameter was not found.
|
||||
*
|
||||
* Look for a specific MCA parameter in an environment and return its value
|
||||
*/
|
||||
OPAL_DECLSPEC int mca_base_param_find_string_name(const char *type,
|
||||
const char *param_name,
|
||||
char **env,
|
||||
char **current_value);
|
||||
|
||||
/**
|
||||
* Set the "internal" flag on an MCA parameter to true or false.
|
||||
*
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user