summaryrefslogtreecommitdiffstats
path: root/pcilib/env.c
blob: 16444dbcf86319895488dd3d31c05670b9bada15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <stdio.h>
#include <stdlib.h>
#include "env.h"


static const char *pcilib_env_cache[PCILIB_MAX_ENV] = {0};

const char *pcilib_getenv(pcilib_env_t env, const char *var) {
    if (!pcilib_env_cache[env]) {
	const char *var_env = getenv(var);
	pcilib_env_cache[env] = var_env?var_env:(void*)-1;
	return var_env;
    }

    return (pcilib_env_cache[env] == (void*)-1)?NULL:pcilib_env_cache[env];
}