void ScopeNewList(EvalContext *ctx, VarRef lval, void *rval, DataType dt) { assert(!ScopeIsReserved(lval.scope)); if (ScopeIsReserved(lval.scope)) { ScopeNewSpecialScalar(ctx, lval.scope, lval.lval, rval, dt); } Rval rvald; if (EvalContextVariableGet(ctx, lval, &rvald, NULL)) { ScopeDeleteVariable(lval.scope, lval.lval); } EvalContextVariablePut(ctx, lval, (Rval) {rval, RVAL_TYPE_LIST }, dt); }
void ScopeClear(const char *ns, const char *name) { assert(name); assert(!ScopeIsReserved(name)); if (!ns) { ns = "default"; } if (!ThreadLock(cft_vscope)) { Log(LOG_LEVEL_ERR, "Could not lock VSCOPE"); return; } Scope *scope = ScopeGet(ns, name); if (!scope) { Log(LOG_LEVEL_DEBUG, "No scope '%s' to clear", name); ThreadUnlock(cft_vscope); return; } HashFree(scope->hashtable); scope->hashtable = HashInit(); Log(LOG_LEVEL_DEBUG, "Scope '%s' cleared", name); ThreadUnlock(cft_vscope); }
void ScopeDeleteScalar(VarRef lval) { assert(!ScopeIsReserved(lval.scope)); if (ScopeIsReserved(lval.scope)) { ScopeDeleteSpecialScalar(lval.scope, lval.lval); } Scope *scope = ScopeGet(lval.scope); if (scope == NULL) { return; } if (HashDeleteElement(scope->hashtable, lval.lval) == false) { CfDebug("Attempt to delete non-existent variable %s in scope %s\n", lval.lval, lval.scope); } }
void ScopeDeleteScalar(VarRef lval) { assert(!ScopeIsReserved(lval.scope)); if (ScopeIsReserved(lval.scope)) { ScopeDeleteSpecial(lval.scope, lval.lval); } Scope *scope = ScopeGet(lval.scope); if (scope == NULL) { return; } if (HashDeleteElement(scope->hashtable, lval.lval) == false) { Log(LOG_LEVEL_DEBUG, "Attempt to delete non-existent variable '%s' in scope '%s'", lval.lval, lval.scope); } }
void ScopeNewSpecialScalar(EvalContext *ctx, const char *scope, const char *lval, const char *rval, DataType dt) { assert(ScopeIsReserved(scope)); Rval rvald; if (EvalContextVariableGet(ctx, (VarRef) { NULL, scope, lval }, &rvald, NULL)) { ScopeDeleteSpecialScalar(scope, lval); } EvalContextVariablePut(ctx, (VarRef) { NULL, scope, lval }, (Rval) {(char *) rval, RVAL_TYPE_SCALAR }, dt); }
void ScopeNewScalar(EvalContext *ctx, VarRef lval, const char *rval, DataType dt) { CfDebug("NewScalar(%s,%s,%s)\n", lval.scope, lval.lval, rval); assert(!ScopeIsReserved(lval.scope)); if (ScopeIsReserved(lval.scope)) { ScopeNewSpecialScalar(ctx, lval.scope, lval.lval, rval, dt); } Rval rvald; if (EvalContextVariableGet(ctx, lval, &rvald, NULL)) { ScopeDeleteScalar(lval); } /* * We know AddVariableHash does not change passed Rval structure or its * contents, but we have no easy way to express it in C type system, hence cast. */ EvalContextVariablePut(ctx, lval, (Rval) {(char *) rval, RVAL_TYPE_SCALAR }, dt); }
void ScopeNewSpecial(EvalContext *ctx, const char *scope, const char *lval, const void *rval, DataType dt) { assert(ScopeIsReserved(scope)); Rval rvald; if (EvalContextVariableGet(ctx, (VarRef) { NULL, scope, lval }, &rvald, NULL)) { ScopeDeleteSpecial(scope, lval); } EvalContextVariablePut(ctx, (VarRef) { NULL, scope, lval }, (Rval) { rval, DataTypeToRvalType(dt) }, dt); }
void ScopeNewSpecialList(EvalContext *ctx, const char *scope, const char *lval, void *rval, DataType dt) { assert(ScopeIsReserved(scope)); Rval rvald; if (EvalContextVariableGet(ctx, (VarRef) { NULL, scope, lval }, &rvald, NULL)) { ScopeDeleteVariable(scope, lval); } EvalContextVariablePut(ctx, (VarRef) { NULL, scope, lval }, (Rval) {rval, RVAL_TYPE_LIST }, dt); }
void ScopeDeleteSpecialScalar(const char *scope, const char *lval) { assert(ScopeIsReserved(scope)); Scope *scope_ptr = ScopeGet(scope); if (scope_ptr == NULL) { return; } if (HashDeleteElement(scope_ptr->hashtable, lval) == false) { CfDebug("Attempt to delete non-existent variable %s in scope %s\n", lval, scope); } }
void ScopeDeleteScalar(const VarRef *ref) { assert(!ScopeIsReserved(ref->scope)); Scope *scope = ScopeGet(ref->ns, ref->scope); if (scope == NULL) { return; } if (HashDeleteElement(scope->hashtable, ref->lval) == false) { Log(LOG_LEVEL_DEBUG, "Attempt to delete non-existent variable '%s' in scope '%s'", ref->lval, ref->scope); } }
void ScopeDeleteSpecial(const char *scope, const char *lval) { assert(ScopeIsReserved(scope)); Scope *scope_ptr = ScopeGet(scope); if (scope_ptr == NULL) { return; } if (HashDeleteElement(scope_ptr->hashtable, lval) == false) { Log(LOG_LEVEL_DEBUG, "Attempt to delete non-existent variable '%s' in scope '%s'", lval, scope); } }