diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2023-05-25 22:41:04 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2023-05-25 22:41:04 +0200 |
commit | 6f4af841f6fdd099b97d071ae64c8be60f809456 (patch) | |
tree | d4f9a18b38e1ce3cfc0a5336215d5ce3afe830d2 /env.c | |
download | pcidev-6f4af841f6fdd099b97d071ae64c8be60f809456.tar.gz pcidev-6f4af841f6fdd099b97d071ae64c8be60f809456.tar.bz2 pcidev-6f4af841f6fdd099b97d071ae64c8be60f809456.tar.xz pcidev-6f4af841f6fdd099b97d071ae64c8be60f809456.zip |
A sample event engine for pcitool (not requiring any PCIe hardware). Initial (barely tested and intended only as an example) release
Diffstat (limited to 'env.c')
-rw-r--r-- | env.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -0,0 +1,17 @@ +#include <stdio.h> +#include <stdlib.h> +#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]; +} + |