blob: b88822ca025f07c8144efa19a42a338db9489e53 [file] [log] [blame]
Julien Boeuf026a4172015-02-02 18:36:37 -08001/*
2 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02003 * Copyright 2015 gRPC authors.
Julien Boeuf026a4172015-02-02 18:36:37 -08004 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02005 * 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 Boeuf026a4172015-02-02 18:36:37 -08008 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02009 * http://www.apache.org/licenses/LICENSE-2.0
Julien Boeuf026a4172015-02-02 18:36:37 -080010 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +020011 * 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 Boeuf026a4172015-02-02 18:36:37 -080016 *
17 */
18
Julien Boeuf026a4172015-02-02 18:36:37 -080019#include <grpc/support/port_platform.h>
20
21#ifdef GPR_POSIX_ENV
22
Craig Tiller9533d042016-03-25 17:11:06 -070023#include "src/core/lib/support/env.h"
Julien Boeuf026a4172015-02-02 18:36:37 -080024
25#include <stdlib.h>
26
27#include <grpc/support/log.h>
28
Masood Malekghassemi701af602015-06-03 15:01:17 -070029#include <grpc/support/string_util.h>
Craig Tiller9533d042016-03-25 17:11:06 -070030#include "src/core/lib/support/string.h"
Julien Boeuf026a4172015-02-02 18:36:37 -080031
ncteisen139072f2017-07-13 23:47:59 -070032const char *gpr_getenv_silent(const char *name, char **dst) {
ncteisen79764a32017-07-12 07:50:09 -070033 *dst = gpr_getenv(name);
34 return NULL;
35}
36
Julien Boeuf026a4172015-02-02 18:36:37 -080037char *gpr_getenv(const char *name) {
Julien Boeuf7413f102015-02-04 17:00:08 -080038 char *result = getenv(name);
Julien Boeuf026a4172015-02-02 18:36:37 -080039 return result == NULL ? result : gpr_strdup(result);
40}
41
42void gpr_setenv(const char *name, const char *value) {
Julien Boeuf05618962015-02-03 21:58:53 -080043 int res = setenv(name, value, 1);
44 GPR_ASSERT(res == 0);
Julien Boeuf026a4172015-02-02 18:36:37 -080045}
46
Craig Tiller190d3602015-02-18 09:23:38 -080047#endif /* GPR_POSIX_ENV */