Intel® OpenMP* Runtime Library
 All Classes Functions Variables Typedefs Enumerations Enumerator Groups Pages
kmp_environment.h
1 /*
2  * kmp_environment.h -- Handle environment varoiables OS-independently.
3  * $Revision: 42061 $
4  * $Date: 2013-02-28 16:36:24 -0600 (Thu, 28 Feb 2013) $
5  */
6 
7 /* <copyright>
8  Copyright (c) 1997-2013 Intel Corporation. All Rights Reserved.
9 
10  Redistribution and use in source and binary forms, with or without
11  modification, are permitted provided that the following conditions
12  are met:
13 
14  * Redistributions of source code must retain the above copyright
15  notice, this list of conditions and the following disclaimer.
16  * Redistributions in binary form must reproduce the above copyright
17  notice, this list of conditions and the following disclaimer in the
18  documentation and/or other materials provided with the distribution.
19  * Neither the name of Intel Corporation nor the names of its
20  contributors may be used to endorse or promote products derived
21  from this software without specific prior written permission.
22 
23  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 
35 </copyright> */
36 
37 #ifndef KMP_ENVIRONMENT_H
38 #define KMP_ENVIRONMENT_H
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 // Return a copy of the value of environment variable or NULL if the variable does not exist.
45 // *Note*: Returned pointed *must* be freed after use with __kmp_env_free().
46 char * __kmp_env_get( char const * name );
47 void __kmp_env_free( char const * * value );
48 
49 // Return 1 if the environment variable exists or 0 if does not exist.
50 int __kmp_env_exists( char const * name );
51 
52 // Set the environment variable.
53 void __kmp_env_set( char const * name, char const * value, int overwrite );
54 
55 // Unset (remove) environment variable.
56 void __kmp_env_unset( char const * name );
57 
58 
59 // -------------------------------------------------------------------------------------------------
60 // Working with environment blocks.
61 // -------------------------------------------------------------------------------------------------
62 
63 /*
64  kmp_env_blk_t is read-only collection of environment variables (or environment-like). Usage:
65 
66  kmp_env_blk_t block;
67  __kmp_env_blk_init( & block, NULL ); // Initialize block from process environment.
68  // or
69  __kmp_env_blk_init( & block, "KMP_WARNING=1|KMP_AFFINITY=none" ); // from string.
70  __kmp_env_blk_sort( & block ); // Optionally, sort list.
71  for ( i = 0; i < block.count; ++ i ) {
72  // Process block.vars[ i ].name and block.vars[ i ].value...
73  }; // for i
74  __kmp_env_block_free( & block );
75 */
76 
77 struct __kmp_env_var {
78  char const * name;
79  char const * value;
80 };
81 typedef struct __kmp_env_var kmp_env_var_t;
82 
83 struct __kmp_env_blk {
84  char const * bulk;
85  kmp_env_var_t const * vars;
86  int count;
87 };
88 typedef struct __kmp_env_blk kmp_env_blk_t;
89 
90 void __kmp_env_blk_init( kmp_env_blk_t * block, char const * bulk );
91 void __kmp_env_blk_free( kmp_env_blk_t * block );
92 void __kmp_env_blk_sort( kmp_env_blk_t * block );
93 char const * __kmp_env_blk_var( kmp_env_blk_t * block, char const * name );
94 
95 #ifdef __cplusplus
96 }
97 #endif
98 
99 #endif // KMP_ENVIRONMENT_H
100 
101 // end of file //
102