![]() |
|
|||
File indexing completed on 2025-02-22 10:47:27
0001 /* 0002 * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana 0003 * University Research and Technology 0004 * Corporation. All rights reserved. 0005 * Copyright (c) 2004-2005 The University of Tennessee and The University 0006 * of Tennessee Research Foundation. All rights 0007 * reserved. 0008 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 0009 * University of Stuttgart. All rights reserved. 0010 * Copyright (c) 2004-2005 The Regents of the University of California. 0011 * All rights reserved. 0012 * Copyright (c) 2007-2013 Los Alamos National Security, LLC. All rights 0013 * reserved. 0014 * Copyright (c) 2015-2020 Intel, Inc. All rights reserved. 0015 * Copyright (c) 2015 Research Organization for Information Science 0016 * and Technology (RIST). All rights reserved. 0017 * Copyright (c) 2016 IBM Corporation. All rights reserved. 0018 * Copyright (c) 2022 Amazon.com, Inc. or its affiliates. 0019 * All Rights reserved. 0020 * Copyright (c) 2021-2022 Nanook Consulting. All rights reserved. 0021 * $COPYRIGHT$ 0022 * 0023 * Additional copyrights may follow 0024 * 0025 * $HEADER$ 0026 */ 0027 0028 /** 0029 * @file 0030 * 0031 * Generic helper routines for environment manipulation. 0032 */ 0033 0034 #ifndef PMIX_ENVIRON_H 0035 #define PMIX_ENVIRON_H 0036 0037 0038 #include <unistd.h> 0039 #ifdef HAVE_CRT_EXTERNS_H 0040 # include <crt_externs.h> 0041 #endif 0042 0043 #include "pmix_common.h" 0044 #include "src/class/pmix_list.h" 0045 0046 BEGIN_C_DECLS 0047 0048 /** 0049 * Merge two environ-like arrays into a single, new array, ensuring 0050 * that there are no duplicate entries. 0051 * 0052 * @param minor Set 1 of the environ's to merge 0053 * @param major Set 2 of the environ's to merge 0054 * @retval New array of environ 0055 * 0056 * Merge two environ-like arrays into a single, new array, 0057 * ensuring that there are no duplicate entries. If there are 0058 * duplicates, entries in the \em major array are favored over 0059 * those in the \em minor array. 0060 * 0061 * Both \em major and \em minor are expected to be argv-style 0062 * arrays (i.e., terminated with a NULL pointer). 0063 * 0064 * The array that is returned is an unencumbered array that should 0065 * later be freed with a call to PMIx_Argv_free(). 0066 * 0067 * Either (or both) of \em major and \em minor can be NULL. If 0068 * one of the two is NULL, the other list is simply copied to the 0069 * output. If both are NULL, NULL is returned. 0070 */ 0071 PMIX_EXPORT char **pmix_environ_merge(char **minor, 0072 char **major) __pmix_attribute_warn_unused_result__; 0073 0074 /** 0075 * Merge contents of an environ-like array into a second environ-like 0076 * array 0077 * 0078 * @param orig The environment to update 0079 * @param additions The environment to merge into orig 0080 * 0081 * Merge the contents of \em additions into \em orig. If a key from 0082 * \em additions is found in \em orig, then the value in orig is not 0083 * updated (ie, it is an additions-only merge). The original 0084 * environment cannot be environ, because pmix_argv_append is used to 0085 * extend the environment, and PMIx_Argv_append_nosize() may not be 0086 * safe to call on environ (for the same reason that realloc() may 0087 * note be safe to call on environ). 0088 * 0089 * New strings are allocated when copied, so both \em orig and \em 0090 * additions individually maintain their ability to be freed with 0091 * PMIx_Argv_free(). 0092 * 0093 * Note that on error, the \em orig array may be partially updated 0094 * with values from additions, but the array will still be a valid 0095 * argv-style array. 0096 */ 0097 PMIX_EXPORT pmix_status_t pmix_environ_merge_inplace(char ***orig, 0098 char **additions) 0099 __pmix_attribute_warn_unused_result__ __pmix_attribute_nonnull__(1); 0100 0101 /** 0102 * Portable version of getenv(3), allowing searches of any key=value array 0103 * 0104 * @param name String name of the environment variable to look for 0105 * @param env The environment to use 0106 * 0107 * The return value will be a pointer to the start of the value 0108 * string. The string returned should not be free()ed or modified by 0109 * the caller, similar to getenv(). 0110 * 0111 * Unlike getenv(), pmix_getenv() will accept a \em name in key=value 0112 * format. In that case, only the key portion of \em name is used for 0113 * the search, and the return value of pmix_getenv() is the value of 0114 * the same key in \em env. 0115 */ 0116 PMIX_EXPORT char * pmix_getenv(const char *name, char **env) __pmix_attribute_nonnull__(1); 0117 0118 /** 0119 * Portable version of unsetenv(3), allowing editing of any 0120 * environ-like array. 0121 * 0122 * @param name String name of the environment variable to look for 0123 * @param env The environment to use 0124 * 0125 * @retval PMIX_ERR_OUT_OF_RESOURCE If an internal malloc fails. 0126 * @retval PMIX_ERR_NOT_FOUND If \em name is not found in \em env. 0127 * @retval PMIX_SUCCESS If \em name is found and successfully deleted. 0128 * 0129 * If \em name is found in \em env, the string corresponding to 0130 * that entry is freed and its entry is eliminated from the array. 0131 */ 0132 PMIX_EXPORT pmix_status_t pmix_unsetenv(const char *name, char ***env) 0133 __pmix_attribute_nonnull__(1); 0134 0135 /* A consistent way to retrieve the home and tmp directory on all supported 0136 * platforms. 0137 */ 0138 PMIX_EXPORT const char *pmix_home_directory(uid_t uid); 0139 PMIX_EXPORT const char *pmix_tmp_directory(void); 0140 0141 /* Provide a utility for harvesting envars */ 0142 PMIX_EXPORT pmix_status_t pmix_util_harvest_envars(char **incvars, char **excvars, 0143 pmix_list_t *ilist); 0144 0145 /* Some care is needed with environ on OS X when dealing with shared 0146 libraries. Handle that care here... */ 0147 #ifdef HAVE__NSGETENVIRON 0148 # define environ (*_NSGetEnviron()) 0149 #else 0150 extern char **environ; 0151 #endif 0152 0153 END_C_DECLS 0154 0155 #endif /* PMIX_ENVIRON */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |