mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-30 11:21:15 -03:00
Migrate global functions out of env_universal. Have env operate directly
on an env_universal_t.
This commit is contained in:
@@ -40,88 +40,3 @@
|
||||
#include "env.h"
|
||||
|
||||
|
||||
/**
|
||||
Set to true after initialization has been performed
|
||||
*/
|
||||
static bool s_env_univeral_inited = false;
|
||||
static void (*external_callback)(fish_message_type_t type, const wchar_t *name, const wchar_t *val);
|
||||
|
||||
void env_universal_barrier();
|
||||
|
||||
/**
|
||||
Callback function used whenever a new fishd message is recieved
|
||||
*/
|
||||
static void callback(fish_message_type_t type, const wchar_t *name, const wchar_t *val)
|
||||
{
|
||||
if (external_callback)
|
||||
external_callback(type, name, val);
|
||||
}
|
||||
|
||||
void env_universal_init(void (*cb)(fish_message_type_t type, const wchar_t *name, const wchar_t *val))
|
||||
{
|
||||
external_callback = cb;
|
||||
env_universal_common_init(&callback);
|
||||
s_env_univeral_inited = true;
|
||||
}
|
||||
|
||||
void env_universal_destroy()
|
||||
{
|
||||
s_env_univeral_inited = false;
|
||||
}
|
||||
|
||||
|
||||
env_var_t env_universal_get(const wcstring &name)
|
||||
{
|
||||
if (!s_env_univeral_inited)
|
||||
return env_var_t::missing_var();
|
||||
|
||||
return env_universal_common_get(name);
|
||||
}
|
||||
|
||||
bool env_universal_get_export(const wcstring &name)
|
||||
{
|
||||
if (!s_env_univeral_inited)
|
||||
return false;
|
||||
|
||||
return env_universal_common_get_export(name);
|
||||
}
|
||||
|
||||
void env_universal_barrier()
|
||||
{
|
||||
ASSERT_IS_MAIN_THREAD();
|
||||
UNIVERSAL_LOG("BARRIER");
|
||||
env_universal_common_sync();
|
||||
}
|
||||
|
||||
|
||||
void env_universal_set(const wcstring &name, const wcstring &value, bool exportv)
|
||||
{
|
||||
if (!s_env_univeral_inited)
|
||||
return;
|
||||
|
||||
debug(3, L"env_universal_set( \"%ls\", \"%ls\" )", name.c_str(), value.c_str());
|
||||
|
||||
env_universal_common_set(name.c_str(), value.c_str(), exportv);
|
||||
env_universal_barrier();
|
||||
}
|
||||
|
||||
bool env_universal_remove(const wcstring &name)
|
||||
{
|
||||
if (!s_env_univeral_inited)
|
||||
return false;
|
||||
|
||||
return env_universal_common_remove(name);
|
||||
}
|
||||
|
||||
void env_universal_get_names(wcstring_list_t &lst,
|
||||
bool show_exported,
|
||||
bool show_unexported)
|
||||
{
|
||||
if (!s_env_univeral_inited)
|
||||
return;
|
||||
|
||||
env_universal_common_get_names(lst,
|
||||
show_exported,
|
||||
show_unexported);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user