summaryrefslogtreecommitdiffhomepage
path: root/public/frameworks/LaunchHelpers.fwrk/headers/Foundation.h
blob: b20ca17e9c1a04965abae56f04fb093035dba602 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* ========================================

  Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.

======================================== */

#pragma once

#include <CoreFoundation.fwrk/headers/Foundation.h>
#include <CoreFoundation.fwrk/headers/String.h>

namespace LaunchHelpers {
struct LHLaunchInfo;

inline constexpr auto kMaxPath = 4096;
inline constexpr auto kMaxArgs = 256;

/// @brief Launch information structure.
/// @note This structure is read-only. Modyfing its members wo't have any effect.
struct LHLaunchInfo final {
  CF::CFString    fExecutablePath{kMaxPath};
  CF::CFString    fWorkingDirectory{kMaxPath};
  CF::CFString    fArguments[kMaxArgs];
  CF::CFString    fEnvironment{kMaxPath};
  CF::CFInteger64 fUID{0};
  CF::CFInteger64 fGID{0};

  explicit operator bool() { return fUID && fGID; }
};

using LHLaunchInfoPtr = LHLaunchInfo*;

/// @brief Get launch information.
/// @return the launch information structure.
LHLaunchInfo* LHGetLaunchInfo(Void);
}  // namespace LaunchHelpers