Julien Boeuf | 026a417 | 2015-02-02 18:36:37 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 3 | * Copyright 2015 gRPC authors. |
Julien Boeuf | 026a417 | 2015-02-02 18:36:37 -0800 | [diff] [blame] | 4 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
Julien Boeuf | 026a417 | 2015-02-02 18:36:37 -0800 | [diff] [blame] | 8 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
Julien Boeuf | 026a417 | 2015-02-02 18:36:37 -0800 | [diff] [blame] | 10 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
Julien Boeuf | 026a417 | 2015-02-02 18:36:37 -0800 | [diff] [blame] | 16 | * |
| 17 | */ |
| 18 | |
Julien Boeuf | 026a417 | 2015-02-02 18:36:37 -0800 | [diff] [blame] | 19 | #include <grpc/support/port_platform.h> |
| 20 | |
| 21 | #ifdef GPR_POSIX_ENV |
| 22 | |
Craig Tiller | 9533d04 | 2016-03-25 17:11:06 -0700 | [diff] [blame] | 23 | #include "src/core/lib/support/env.h" |
Julien Boeuf | 026a417 | 2015-02-02 18:36:37 -0800 | [diff] [blame] | 24 | |
| 25 | #include <stdlib.h> |
| 26 | |
| 27 | #include <grpc/support/log.h> |
| 28 | |
Masood Malekghassemi | 701af60 | 2015-06-03 15:01:17 -0700 | [diff] [blame] | 29 | #include <grpc/support/string_util.h> |
Craig Tiller | 9533d04 | 2016-03-25 17:11:06 -0700 | [diff] [blame] | 30 | #include "src/core/lib/support/string.h" |
Julien Boeuf | 026a417 | 2015-02-02 18:36:37 -0800 | [diff] [blame] | 31 | |
ncteisen | 139072f | 2017-07-13 23:47:59 -0700 | [diff] [blame] | 32 | const char *gpr_getenv_silent(const char *name, char **dst) { |
ncteisen | 79764a3 | 2017-07-12 07:50:09 -0700 | [diff] [blame] | 33 | *dst = gpr_getenv(name); |
| 34 | return NULL; |
| 35 | } |
| 36 | |
Julien Boeuf | 026a417 | 2015-02-02 18:36:37 -0800 | [diff] [blame] | 37 | char *gpr_getenv(const char *name) { |
Julien Boeuf | 7413f10 | 2015-02-04 17:00:08 -0800 | [diff] [blame] | 38 | char *result = getenv(name); |
Julien Boeuf | 026a417 | 2015-02-02 18:36:37 -0800 | [diff] [blame] | 39 | return result == NULL ? result : gpr_strdup(result); |
| 40 | } |
| 41 | |
| 42 | void gpr_setenv(const char *name, const char *value) { |
Julien Boeuf | 0561896 | 2015-02-03 21:58:53 -0800 | [diff] [blame] | 43 | int res = setenv(name, value, 1); |
| 44 | GPR_ASSERT(res == 0); |
Julien Boeuf | 026a417 | 2015-02-02 18:36:37 -0800 | [diff] [blame] | 45 | } |
| 46 | |
Craig Tiller | 190d360 | 2015-02-18 09:23:38 -0800 | [diff] [blame] | 47 | #endif /* GPR_POSIX_ENV */ |