mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-14 18:05:27 +07:00
[platform] native macOS environment reader: sources (IDEA-216133)
GitOrigin-RevId: e713b19c9e4bd6ecd74eeca7cbeb1fcd95b04e4a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d7c1d9b695
commit
a79a4fdfd0
2
native/MacEnvReader/.gitignore
vendored
Normal file
2
native/MacEnvReader/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/.idea/
|
||||
/cmake-build-*/
|
||||
14
native/MacEnvReader/CMakeLists.txt
Normal file
14
native/MacEnvReader/CMakeLists.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(MacEnvReader C)
|
||||
|
||||
if (NOT APPLE)
|
||||
message(FATAL_ERROR "macOS only.")
|
||||
endif ()
|
||||
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64")
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9)
|
||||
|
||||
add_compile_options("-fno-objc-arc" "-flto=full" "-Wall" "-Wextra" "-Wpedantic")
|
||||
|
||||
add_executable(printenv printenv.c)
|
||||
28
native/MacEnvReader/printenv.c
Normal file
28
native/MacEnvReader/printenv.c
Normal file
@@ -0,0 +1,28 @@
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and contributors.
|
||||
// Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, const char **argv, const char **env) {
|
||||
if (argc != 2) {
|
||||
printf("usage: %s output_file\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
FILE *f = fopen(argv[1], "w");
|
||||
if (f == NULL) {
|
||||
perror("fopen");
|
||||
return 2;
|
||||
}
|
||||
|
||||
const char **v = env;
|
||||
while (*v != NULL) {
|
||||
fputs(*v, f);
|
||||
fputc('\0', f);
|
||||
v++;
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user