From 6f4af841f6fdd099b97d071ae64c8be60f809456 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Thu, 25 May 2023 22:41:04 +0200 Subject: A sample event engine for pcitool (not requiring any PCIe hardware). Initial (barely tested and intended only as an example) release --- env.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 env.c (limited to 'env.c') diff --git a/env.c b/env.c new file mode 100644 index 0000000..a1ebbce --- /dev/null +++ b/env.c @@ -0,0 +1,17 @@ +#include +#include +#include "env.h" + + +static const char *env_cache[PCIDEV_MAX_ENV] = {0}; + +const char *pcidev_getenv(pcidev_env_t env, const char *var) { + if (!env_cache[env]) { + const char *var_env = getenv(var); + env_cache[env] = var_env?var_env:(void*)-1; + return var_env; + } + + return (env_cache[env] == (void*)-1)?NULL:env_cache[env]; +} + -- cgit v1.2.3