Example #1
0
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);
}
Example #2
0
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);
}
Example #3
0
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);
    }
}
Example #4
0
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);
    }
}
Example #5
0
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);
}
Example #6
0
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);
}
Example #7
0
File: scope.c Project: jeffali/core
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);
}
Example #8
0
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);
}
Example #9
0
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);
    }
}
Example #10
0
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);
    }
}
Example #11
0
File: scope.c Project: jeffali/core
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);
    }
}