Nuitka
The Python compiler
Loading...
Searching...
No Matches
environment_variables_system.h
1// Copyright 2025, Kay Hayen, mailto:kay.hayen@gmail.com find license text at end of file
2
3#ifndef __NUITKA_ENVIRONMENT_VARIABLES_SYSTEM_H__
4#define __NUITKA_ENVIRONMENT_VARIABLES_SYSTEM_H__
5
6#ifdef __IDE_ONLY__
7#include "nuitka/prelude.h"
8#endif
9
10#include "nuitka/filesystem_paths.h"
11
12// Helpers for working with environment variables in a portable way. This mainly
13// abstracts the string type differences between Win32 and non-Win32 environment
14// variables.
15#if defined(_WIN32)
16#define environment_char_t wchar_t
17#define native_command_line_argument_t wchar_t
18#define compareEnvironmentString(a, b) wcscmp(a, b)
19#define makeEnvironmentLiteral(x) L##x
20#else
21#define environment_char_t char
22#define native_command_line_argument_t char
23#define compareEnvironmentString(a, b) strcmp(a, b)
24#define makeEnvironmentLiteral(x) x
25#endif
26
27extern environment_char_t const *getEnvironmentVariable(char const *name);
28extern environment_char_t const *getEnvironmentVariableW(wchar_t const *name);
29extern void setEnvironmentVariable(char const *name, environment_char_t const *value);
30extern void setEnvironmentVariableFromLong(char const *name, long value);
31extern void setEnvironmentVariableFromFilename(char const *name, filename_char_t const *value);
32extern void unsetEnvironmentVariable(char const *name);
33
34// Get the original argv0 value.
35extern filename_char_t const *getOriginalArgv0(void);
36
37#endif
38// Part of "Nuitka", an optimizing Python compiler that is compatible and
39// integrates with CPython, but also works on its own.
40//
41// Licensed under the Apache License, Version 2.0 (the "License");
42// you may not use this file except in compliance with the License.
43// You may obtain a copy of the License at
44//
45// http://www.apache.org/licenses/LICENSE-2.0
46//
47// Unless required by applicable law or agreed to in writing, software
48// distributed under the License is distributed on an "AS IS" BASIS,
49// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
50// See the License for the specific language governing permissions and
51// limitations under the License.