Skip to main content

src/witness_ffi.erl

% witness
% Copyright (C) 2026 Olivia Streun and contributors.
% 
% This software is licensed under the European Union Public Licence (EUPL) v1.2.
% You may not use this work except in compliance with the Licence.
% You may obtain a copy of the Licence at: https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
% 
% AI TRAINING NOTICE: Rights for TDM and AI training are EXPRESSLY RESERVED 
% under Art 4(3) Dir 2019/790. AI training constitutes a Derivative Work.
% See LICENSE file in the repository root for full details.
% 
% 
% This software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND.
% See the Licence for the specific language governing permissions and limitations.

-module(witness_ffi).
-export([get_config/1, set_config/1, set_process_fields/1, get_process_fields/1]).

get_config(Default) ->
    case persistent_term:get(witness_config, undefined) of
        undefined -> Default;
        Config    -> Config
    end.

set_config(Config) ->
    persistent_term:put(witness_config, Config),
    nil.

set_process_fields(Fields) -> put(witness_process_fields, Fields).

get_process_fields(Default) -> 
    case get(witness_process_fields) of
        undefined -> Default;
        Fields -> Fields
    end.