Make some environ naming changes. This was motivated by a Windows
naming conflict. This commit was SVN r5371.
Этот коммит содержится в:
родитель
280122e4a6
Коммит
2b25046781
@ -19,9 +19,7 @@
|
||||
#include "orte_config.h"
|
||||
#include "include/orte_constants.h"
|
||||
#include "util/proc_info.h"
|
||||
#ifndef WIN32
|
||||
#include "util/environ.h"
|
||||
#endif
|
||||
#include "util/ompi_environ.h"
|
||||
#include "mca/base/mca_base_param.h"
|
||||
#include "mca/ns/ns.h"
|
||||
#include "mca/errmgr/errmgr.h"
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include "util/argv.h"
|
||||
#include "util/output.h"
|
||||
#include "util/environ.h"
|
||||
#include "util/ompi_environ.h"
|
||||
#include "util/proc_info.h"
|
||||
#include "event/event.h"
|
||||
#include "runtime/orte_wait.h"
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include "util/argv.h"
|
||||
#include "util/output.h"
|
||||
#include "util/sys_info.h"
|
||||
#include "util/environ.h"
|
||||
#include "util/ompi_environ.h"
|
||||
#include "runtime/orte_wait.h"
|
||||
#include "mca/errmgr/errmgr.h"
|
||||
#include "mca/iof/iof.h"
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "include/orte_types.h"
|
||||
#include "util/argv.h"
|
||||
#include "util/output.h"
|
||||
#include "util/environ.h"
|
||||
#include "util/ompi_environ.h"
|
||||
#include "runtime/runtime.h"
|
||||
#include "runtime/orte_wait.h"
|
||||
#include "mca/base/mca_base_param.h"
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "include/orte_types.h"
|
||||
#include "util/argv.h"
|
||||
#include "util/output.h"
|
||||
#include "util/environ.h"
|
||||
#include "util/ompi_environ.h"
|
||||
#include "runtime/runtime.h"
|
||||
#include "runtime/orte_wait.h"
|
||||
#include "mca/base/mca_base_param.h"
|
||||
|
@ -31,7 +31,7 @@ headers = \
|
||||
basename.h \
|
||||
bit_ops.h \
|
||||
cmd_line.h \
|
||||
environ.h \
|
||||
ompi_environ.h \
|
||||
few.h \
|
||||
if.h \
|
||||
malloc.h \
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "include/constants.h"
|
||||
#include "util/printf.h"
|
||||
#include "util/argv.h"
|
||||
#include "util/environ.h"
|
||||
#include "util/ompi_environ.h"
|
||||
|
||||
|
||||
/*
|
||||
|
@ -1,133 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2004-2005 The Trustees of Indiana University.
|
||||
All rights reserved.
|
||||
Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
||||
All rights reserved.
|
||||
Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
||||
University of Stuttgart. All rights reserved.
|
||||
Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
$COPYRIGHT$
|
||||
|
||||
Additional copyrights may follow
|
||||
|
||||
$HEADER$
|
||||
*/
|
||||
|
||||
#include "ompi_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "include/constants.h"
|
||||
#include "util/printf.h"
|
||||
#include "util/argv.h"
|
||||
|
||||
#include "win32/ompi_environ.h"
|
||||
|
||||
int ompi_setenv(const char *name, const char *value, bool overwrite,
|
||||
char ***env)
|
||||
{
|
||||
int i;
|
||||
char *newvalue, *compare;
|
||||
size_t len;
|
||||
|
||||
/* Make the new value */
|
||||
|
||||
if (NULL == value) {
|
||||
asprintf(&newvalue, "%s=", name);
|
||||
} else {
|
||||
asprintf(&newvalue, "%s=%s", name, value);
|
||||
}
|
||||
if (NULL == newvalue) {
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
|
||||
/* Check the bozo case */
|
||||
|
||||
if (NULL == env) {
|
||||
return OMPI_ERR_BAD_PARAM;
|
||||
} else if (NULL == *env) {
|
||||
i = 0;
|
||||
ompi_argv_append(&i, env, newvalue);
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
/* Make something easy to compare to */
|
||||
|
||||
asprintf(&compare, "%s=", name);
|
||||
if (NULL == compare) {
|
||||
free(newvalue);
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
len = strlen(compare);
|
||||
|
||||
/* Look for a duplicate that's already set in the env */
|
||||
|
||||
for (i = 0; (*env)[i] != NULL; ++i) {
|
||||
if (0 == strncmp((*env)[i], compare, len)) {
|
||||
if (overwrite) {
|
||||
free((*env)[i]);
|
||||
(*env)[i] = newvalue;
|
||||
free(compare);
|
||||
return OMPI_SUCCESS;
|
||||
} else {
|
||||
free(compare);
|
||||
free(newvalue);
|
||||
return OMPI_EXISTS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If we found no match, append this value */
|
||||
|
||||
i = ompi_argv_count(*env);
|
||||
ompi_argv_append(&i, env, newvalue);
|
||||
|
||||
/* All done */
|
||||
|
||||
free(compare);
|
||||
free(newvalue);
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
int ompi_unsetenv(const char *name, char ***env)
|
||||
{
|
||||
int i;
|
||||
char *compare;
|
||||
size_t len;
|
||||
bool found;
|
||||
|
||||
/* Check for bozo case */
|
||||
|
||||
if (NULL == *env) {
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
/* Make something easy to compare to */
|
||||
|
||||
asprintf(&compare, "%s=", name);
|
||||
if (NULL == compare) {
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
len = strlen(compare);
|
||||
|
||||
/* Look for a duplicate that's already set in the env. If we find
|
||||
it, free it, and then start shifting all elements down one in
|
||||
the array. */
|
||||
found = false;
|
||||
for (i = 0; (*env)[i] != NULL; ++i) {
|
||||
if (found) {
|
||||
(*env)[i] = (*env)[i + 1];
|
||||
} else if (0 == strncmp((*env)[i], compare, len)) {
|
||||
free((*env)[i]);
|
||||
(*env)[i] = (*env)[i + 1];
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* All done */
|
||||
|
||||
return (found) ? OMPI_SUCCESS : OMPI_ERR_NOT_FOUND;
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
*Copyright (c) 2004-2005 The Trustees of Indiana University.
|
||||
* All rights reserved.
|
||||
*Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
||||
* All rights reserved.
|
||||
*Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
||||
* University of Stuttgart. All rights reserved.
|
||||
*Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*$COPYRIGHT$
|
||||
*
|
||||
*Additional copyrights may follow
|
||||
*
|
||||
*$HEADER$
|
||||
*/
|
||||
|
||||
#ifndef OMPI_PROCESS_H
|
||||
#define OMPI_PROCESS_H
|
||||
#include "win32/ompi_declspec.h"
|
||||
#ifdef WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include<windows.h>
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#if defined(c_plusplus) || defined (__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
OMPI_DECLSPEC int ompi_setenv(const char *name, const char *value,
|
||||
bool overwrite, char ***env);
|
||||
|
||||
OMPI_DECLSPEC int ompi_unsetenv(const char *name, char ***env);
|
||||
|
||||
#if defined(c_plusplus) || defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* OMPI_PROCESS_H */
|
Загрузка…
x
Ссылка в новой задаче
Block a user