Fuzion Logo
fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

fuzion/sys/env_vars.fz


# This file is part of the Fuzion language implementation.
#
# The Fuzion language implementation is free software: you can redistribute it
# and/or modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, version 3 of the License.
#
# The Fuzion language implementation is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
# License for more details.
#
# You should have received a copy of the GNU General Public License along with The
# Fuzion language implementation.  If not, see <https://www.gnu.org/licenses/>.


# -----------------------------------------------------------------------
#
#  Tokiwa Software GmbH, Germany
#
#  Source code of Fuzion standard library feature fuzion.sys.env_var
#
#  Author: Fridtjof Siebert (siebert@tokiwa.software)
#
# -----------------------------------------------------------------------

# fuzion.sys.env_vars -- low-level feature to access environment variables
#
module env_vars is


  # intrinsic to check if env var with given name exists
  #
  # NOTE: parameter s must be 0-terminated char *
  #
  has0(s Array u8) bool => intrinsic


  # intrinsic to get env var with given name
  #
  # NOTE: parameter s must be 0-terminated char *
  #
  get0(s Array u8) String
  => intrinsic

  # check if env var with given name exists
  #
  module has(s String) bool =>
    has0 (c_string s)


  # intrinsic to get env var with given name
  #
  module get(s String) option String =>
    a := c_string s
    if has0 a then
      get0 a
    else
      nil

last changed: 2025-07-10