1#ifndef AWS_COMMON_ENVIRONMENT_H
2#define AWS_COMMON_ENVIRONMENT_H
3
4/*
5 * Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License").
8 * You may not use this file except in compliance with the License.
9 * A copy of the License is located at
10 *
11 * http://aws.amazon.com/apache2.0
12 *
13 * or in the "license" file accompanying this file. This file is distributed
14 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
15 * express or implied. See the License for the specific language governing
16 * permissions and limitations under the License.
17 */
18
19#include <aws/common/common.h>
20
21struct aws_string;
22
23/*
24 * Simple shims to the appropriate platform calls for environment variable manipulation.
25 *
26 * Not thread safe to use set/unset unsynced with get. Set/unset only used in unit tests.
27 */
28AWS_EXTERN_C_BEGIN
29
30/*
31 * Get the value of an environment variable. If the variable is not set, the output string will be set to NULL.
32 * Not thread-safe
33 */
34AWS_COMMON_API
35int aws_get_environment_value(
36 struct aws_allocator *allocator,
37 const struct aws_string *variable_name,
38 struct aws_string **value_out);
39
40/*
41 * Set the value of an environment variable. On Windows, setting a variable to the empty string will actually unset it.
42 * Not thread-safe
43 */
44AWS_COMMON_API
45int aws_set_environment_value(const struct aws_string *variable_name, const struct aws_string *value);
46
47/*
48 * Unset an environment variable.
49 * Not thread-safe
50 */
51AWS_COMMON_API
52int aws_unset_environment_value(const struct aws_string *variable_name);
53
54AWS_EXTERN_C_END
55
56#endif /* AWS_COMMON_ENVIRONMENT_H */
57