|
|
|
|
@ -494,7 +494,7 @@ static EfErrCode del_env(const char *key) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set an ENV. If it value is empty, delete it.
|
|
|
|
|
* Set an ENV.
|
|
|
|
|
* If not find it in ENV table, then create it.
|
|
|
|
|
*
|
|
|
|
|
* @param key ENV name
|
|
|
|
|
@ -514,10 +514,6 @@ EfErrCode ef_set_env(const char *key, const char *value) {
|
|
|
|
|
/* lock the ENV cache */
|
|
|
|
|
ef_port_env_lock();
|
|
|
|
|
|
|
|
|
|
/* if ENV value is empty, delete it */
|
|
|
|
|
if ((value == NULL) || (*value == '\0')) {
|
|
|
|
|
result = del_env(key);
|
|
|
|
|
} else {
|
|
|
|
|
old_env = find_env(key);
|
|
|
|
|
/* If find this ENV, then compare the new value and old value. */
|
|
|
|
|
if (old_env) {
|
|
|
|
|
@ -534,7 +530,32 @@ EfErrCode ef_set_env(const char *key, const char *value) {
|
|
|
|
|
} else {
|
|
|
|
|
result = create_env(key, value);
|
|
|
|
|
}
|
|
|
|
|
/* unlock the ENV cache */
|
|
|
|
|
ef_port_env_unlock();
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Del an ENV.
|
|
|
|
|
*
|
|
|
|
|
* @param key ENV name
|
|
|
|
|
*
|
|
|
|
|
* @return result
|
|
|
|
|
*/
|
|
|
|
|
EfErrCode ef_del_env(const char *key) {
|
|
|
|
|
EfErrCode result = EF_NO_ERR;
|
|
|
|
|
|
|
|
|
|
if (!init_ok) {
|
|
|
|
|
EF_INFO("ENV isn't initialize OK.\n");
|
|
|
|
|
return EF_ENV_INIT_FAILED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* lock the ENV cache */
|
|
|
|
|
ef_port_env_lock();
|
|
|
|
|
|
|
|
|
|
result = del_env(key);
|
|
|
|
|
|
|
|
|
|
/* unlock the ENV cache */
|
|
|
|
|
ef_port_env_unlock();
|
|
|
|
|
|
|
|
|
|
@ -989,6 +1010,25 @@ EfErrCode ef_set_and_save_env(const char *key, const char *value) {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Del and save an ENV. If del ENV is success then will save it.
|
|
|
|
|
*
|
|
|
|
|
* @param key ENV name
|
|
|
|
|
*
|
|
|
|
|
* @return result
|
|
|
|
|
*/
|
|
|
|
|
EfErrCode ef_del_and_save_env(const char *key) {
|
|
|
|
|
EfErrCode result = EF_NO_ERR;
|
|
|
|
|
|
|
|
|
|
result = ef_del_env(key);
|
|
|
|
|
|
|
|
|
|
if (result == EF_NO_ERR) {
|
|
|
|
|
result = ef_save_env();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef EF_ENV_AUTO_UPDATE
|
|
|
|
|
/**
|
|
|
|
|
* Auto update ENV to latest default when current EF_ENV_VER is changed.
|
|
|
|
|
|