summaryrefslogtreecommitdiffstats
path: root/env.c
blob: fa754088da0626891467c13b3e615501e562c976 (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 *env_cache[IPECAMERA_MAX_ENV] = {0};

const char *ipecamera_getenv(ipecamera_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];
}