From e6915fb6dd715e39e37702a6d69c220c0f1798bf Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Wed, 31 Jul 2024 17:16:21 -0400 Subject: remove argc, argv; arguments will be passed via environment variables --- kernel/source/application.cpp | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'kernel/source/application.cpp') diff --git a/kernel/source/application.cpp b/kernel/source/application.cpp index 6df49cd..cd76bd9 100644 --- a/kernel/source/application.cpp +++ b/kernel/source/application.cpp @@ -90,9 +90,42 @@ namespace hilbert::kernel::application { delete memory; //:p } - void process::add_environment_variable( + process::string_pair *process::find_environment_variable( + const utility::string &name) { + + for (auto *n = environment_variables.first; n; n = n->next) + if (n->value.a == name) + return &n->value; + + return 0; + + } + + void process::set_environment_variable( utility::string &&name, utility::string &&value) { - environment_variables.insert_end({.a = name, .b = value}); + + auto *sp = find_environment_variable(name); + if (sp) + sp->b = utility::move(value); + else + environment_variables.insert_end({ + .a = utility::move(name), + .b = utility::move(value) + }); + + } + + void process::set_environment_variable( + const utility::string &name, const utility::string &value) { + + auto *sp = find_environment_variable(name); + if (sp) + sp->b = value; + else + environment_variables.insert_end({ + .a = name, .b = value + }); + } utility::string *process::get_environment_variable( -- cgit v1.2.3