您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ IsDefinedClass函数代码示例

51自学网 2021-06-01 21:40:46
  C++
这篇教程C++ IsDefinedClass函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中IsDefinedClass函数的典型用法代码示例。如果您正苦于以下问题:C++ IsDefinedClass函数的具体用法?C++ IsDefinedClass怎么用?C++ IsDefinedClass使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了IsDefinedClass函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: EvalContextHeapAddHard

void EvalContextHeapAddHard(EvalContext *ctx, const char *context){    char context_copy[CF_MAXVARSIZE];    strcpy(context_copy, context);    if (Chop(context_copy, CF_EXPANDSIZE) == -1)    {        CfOut(OUTPUT_LEVEL_ERROR, "", "Chop was called on a string that seemed to have no terminator");    }    CanonifyNameInPlace(context_copy);    CfDebug("EvalContextHeapAddHard(%s)/n", context_copy);    if (strlen(context_copy) == 0)    {        return;    }    if (IsRegexItemIn(ctx, ctx->heap_abort_current_bundle, context_copy))    {        CfOut(OUTPUT_LEVEL_ERROR, "", "Bundle aborted on defined class /"%s/"/n", context_copy);        ABORTBUNDLE = true;    }    if (IsRegexItemIn(ctx, ctx->heap_abort, context_copy))    {        CfOut(OUTPUT_LEVEL_ERROR, "", "cf-agent aborted on defined class /"%s/"/n", context_copy);        exit(1);    }    if (EvalContextHeapContainsHard(ctx, context_copy))    {        return;    }    StringSetAdd(ctx->heap_hard, xstrdup(context_copy));    for (const Item *ip = ctx->heap_abort; ip != NULL; ip = ip->next)    {        if (IsDefinedClass(ctx, ip->name, NULL))        {            CfOut(OUTPUT_LEVEL_ERROR, "", "cf-agent aborted on defined class /"%s/" defined in bundle %s/n", ip->name, StackFrameOwnerName(LastStackFrame(ctx, 0)));            exit(1);        }    }    if (!ABORTBUNDLE)    {        for (const Item *ip = ctx->heap_abort_current_bundle; ip != NULL; ip = ip->next)        {            if (IsDefinedClass(ctx, ip->name, NULL))            {                CfOut(OUTPUT_LEVEL_ERROR, "", " -> Setting abort for /"%s/" when setting /"%s/"", ip->name, context_copy);                ABORTBUNDLE = true;                break;            }        }    }}
开发者ID:shaunamarie,项目名称:core,代码行数:59,


示例2: VarClassExcluded

int VarClassExcluded(EvalContext *ctx, Promise *pp, char **classes){    Constraint *cp = PromiseGetConstraint(ctx, pp, "ifvarclass");    if (cp == NULL)    {        return false;    }    *classes = (char *) ConstraintGetRvalValue(ctx, "ifvarclass", pp, RVAL_TYPE_SCALAR);    if (*classes == NULL)    {        return true;    }    if (strchr(*classes, '$') || strchr(*classes, '@'))    {        CfDebug("Class expression did not evaluate");        return true;    }    if (*classes && IsDefinedClass(ctx, *classes, PromiseGetNamespace(pp)))    {        return false;    }    else    {        return true;    }}
开发者ID:shaunamarie,项目名称:core,代码行数:31,


示例3: KeepServerPromise

static void KeepServerPromise(Promise *pp){    char *sp = NULL;    if (!IsDefinedClass(pp->classes))    {        CfOut(cf_verbose, "", "Skipping whole promise, as context is %s/n", pp->classes);        return;    }    if (VarClassExcluded(pp, &sp))    {        CfOut(cf_verbose, "", "/n");        CfOut(cf_verbose, "", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . /n");        CfOut(cf_verbose, "", "Skipping whole next promise (%s), as var-context %s is not relevant/n", pp->promiser,              sp);        CfOut(cf_verbose, "", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . /n");        return;    }    if (strcmp(pp->agentsubtype, "classes") == 0)    {        KeepClassContextPromise(pp);        return;    }    sp = (char *) GetConstraintValue("resource_type", pp, CF_SCALAR);    if (strcmp(pp->agentsubtype, "access") == 0 && sp && strcmp(sp, "literal") == 0)    {        KeepLiteralAccessPromise(pp, "literal");        return;    }    if (strcmp(pp->agentsubtype, "access") == 0 && sp && strcmp(sp, "query") == 0)    {        KeepQueryAccessPromise(pp, "query");        return;    }    if (strcmp(pp->agentsubtype, "access") == 0 && sp && strcmp(sp, "context") == 0)    {        KeepLiteralAccessPromise(pp, "context");        return;    }/* Default behaviour is file access */    if (strcmp(pp->agentsubtype, "access") == 0)    {        KeepFileAccessPromise(pp);        return;    }    if (strcmp(pp->agentsubtype, "roles") == 0)    {        KeepServerRolePromise(pp);        return;    }}
开发者ID:dnaeon,项目名称:core,代码行数:60,


示例4: IsRegexItemIn

int IsRegexItemIn(EvalContext *ctx, Item *list, char *regex){    Item *ptr;    for (ptr = list; ptr != NULL; ptr = ptr->next)    {        if ((ptr->classes) && (!IsDefinedClass(ctx, ptr->classes)))        {            continue;        }        /* Avoid using regex if possible, due to memory leak */        if (strcmp(regex, ptr->name) == 0)        {            return true;        }        /* Make it commutative */        if ((StringMatchFull(regex, ptr->name)) || (StringMatchFull(ptr->name, regex)))        {            return true;        }    }    return false;}
开发者ID:TheDreamer,项目名称:cfengine-3.5.x,代码行数:28,


示例5: IsRegexItemIn

int IsRegexItemIn(const EvalContext *ctx, const Item *list, const char *regex){    for (const Item *ptr = list; ptr != NULL; ptr = ptr->next)    {        if (ctx != NULL && ptr->classes != NULL &&            !IsDefinedClass(ctx, ptr->classes))        {            continue;        }        /* Cheap pre-test: */        if (strcmp(regex, ptr->name) == 0)        {            return true;        }        /* Make it commutative */        if (StringMatchFull(regex, ptr->name) || StringMatchFull(ptr->name, regex))        {            return true;        }    }    return false;}
开发者ID:cfengine,项目名称:core,代码行数:26,


示例6: ScheduleRun

int ScheduleRun(){ time_t now;  char timekey[64];  struct Item *ip;Verbose("Sleeping.../n");sleep(60);                  /* 1 Minute resolution is enough */ now = time(NULL);snprintf(timekey,63,"%s",ctime(&now)); AddTimeClass(timekey); for (ip = SCHEDULE; ip != NULL; ip = ip->next)   {   Verbose("Checking schedule %s.../n",ip->name);   if (IsDefinedClass(ip->name))      {      Verbose("Waking up the agent at %s ~ %s /n",timekey,ip->name);      DeleteItemList(VHEAP);      VHEAP = NULL;      return true;      }   }DeleteItemList(VHEAP);VHEAP = NULL; return false;}
开发者ID:AsherBond,项目名称:cf22cf3,代码行数:30,


示例7: FnCallEvaluate

FnCallResult FnCallEvaluate(EvalContext *ctx, FnCall *fp, const Promise *caller){    Rlist *expargs;    const FnCallType *fp_type = FnCallTypeGet(fp->name);    if (fp_type)    {        if (DEBUG)        {            printf("EVALUATE FN CALL %s/n", fp->name);            FnCallShow(stdout, fp);            printf("/n");        }    }    else    {        if (caller)        {            CfOut(OUTPUT_LEVEL_ERROR, "", "No such FnCall /"%s()/" in promise @ %s near line %zd/n",                  fp->name, PromiseGetBundle(caller)->source_path, caller->offset.line);        }        else        {            CfOut(OUTPUT_LEVEL_ERROR, "", "No such FnCall /"%s()/" - context info unavailable/n", fp->name);        }        return (FnCallResult) { FNCALL_FAILURE, { FnCallCopy(fp), RVAL_TYPE_FNCALL } };    }/* If the container classes seem not to be defined at this stage, then don't try to expand the function */    if ((caller != NULL) && !IsDefinedClass(ctx, caller->classes, PromiseGetNamespace(caller)))    {        return (FnCallResult) { FNCALL_FAILURE, { FnCallCopy(fp), RVAL_TYPE_FNCALL } };    }    expargs = NewExpArgs(ctx, fp, caller);    if (UnresolvedArgs(expargs))    {        DeleteExpArgs(expargs);        return (FnCallResult) { FNCALL_FAILURE, { FnCallCopy(fp), RVAL_TYPE_FNCALL } };    }    fp->caller = caller;    FnCallResult result = CallFunction(ctx, fp_type, fp, expargs);    if (result.status == FNCALL_FAILURE)    {        /* We do not assign variables to failed function calls */        DeleteExpArgs(expargs);        return (FnCallResult) { FNCALL_FAILURE, { FnCallCopy(fp), RVAL_TYPE_FNCALL } };    }    DeleteExpArgs(expargs);    return result;}
开发者ID:shaunamarie,项目名称:core,代码行数:58,


示例8: EvaluateFunctionCall

FnCallResult EvaluateFunctionCall(FnCall *fp, Promise *pp){    Rlist *expargs;    const FnCallType *this = FindFunction(fp->name);    if (this)    {        if (DEBUG)        {            printf("EVALUATE FN CALL %s/n", fp->name);            ShowFnCall(stdout, fp);            printf("/n");        }    }    else    {        if (pp)        {            CfOut(cf_error, "", "No such FnCall /"%s()/" in promise @ %s near line %zd/n",                  fp->name, pp->audit->filename, pp->offset.line);        }        else        {            CfOut(cf_error, "", "No such FnCall /"%s()/" - context info unavailable/n", fp->name);        }        return (FnCallResult) { FNCALL_FAILURE, { CopyFnCall(fp), CF_FNCALL } };    }/* If the container classes seem not to be defined at this stage, then don't try to expand the function */    if ((pp != NULL) && !IsDefinedClass(pp->classes))    {        return (FnCallResult) { FNCALL_FAILURE, { CopyFnCall(fp), CF_FNCALL } };    }    expargs = NewExpArgs(fp, pp);    if (UnresolvedArgs(expargs))    {        DeleteExpArgs(expargs);        return (FnCallResult) { FNCALL_FAILURE, { CopyFnCall(fp), CF_FNCALL } };    }    FnCallResult result = CallFunction(this, fp, expargs);    if (result.status == FNCALL_FAILURE)    {        /* We do not assign variables to failed function calls */        DeleteExpArgs(expargs);        return (FnCallResult) { FNCALL_FAILURE, { CopyFnCall(fp), CF_FNCALL } };    }    DeleteExpArgs(expargs);    return result;}
开发者ID:joegen,项目名称:sipx-externals,代码行数:56,


示例9: KeepServerRolePromise

/** * The "roles" access promise is for remote class activation by means of * cf-runagent -D: * *     pp->promiser is a regex to match classes. *     pp->conlist  is an slist of usernames. */static void KeepServerRolePromise(EvalContext *ctx, const Promise *pp){    size_t pos = acl_SortedInsert(&roles_acl, pp->promiser);    if (pos == (size_t) -1)    {        /* Should never happen, besides when allocation fails. */        Log(LOG_LEVEL_CRIT, "acl_Insert: %s", GetErrorStr());        exit(255);    }    size_t i = SeqLength(pp->conlist);    while (i > 0)    {        i--;        Constraint *cp = SeqAt(pp->conlist, i);        char const * const authorizer =            CF_REMROLE_BODIES[REMOTE_ROLE_AUTHORIZE].lval;        if (strcmp(cp->lval, authorizer) == 0)        {            if (cp->rval.type != RVAL_TYPE_LIST)            {                Log(LOG_LEVEL_ERR,                    "Right-hand side of authorize promise for '%s' should be a list",                    pp->promiser);            }            else if (IsDefinedClass(ctx, cp->classes))            {                for (const Rlist *rp = cp->rval.item; rp != NULL; rp = rp->next)                {                    /* The "roles" access promise currently only supports                     * listing usernames to admit access to, nothing more. */                    struct resource_acl *racl = &roles_acl->acls[pos];                    size_t zret = StrList_Append(&racl->admit.usernames,                                                 RlistScalarValue(rp));                    if (zret == (size_t) -1)                    {                        /* Should never happen, besides when allocation fails. */                        Log(LOG_LEVEL_CRIT, "StrList_Append: %s", GetErrorStr());                        exit(255);                    }                }            }        }        else if (strcmp(cp->lval, "comment") != 0 &&                 strcmp(cp->lval, "handle") != 0 &&                 /* Are there other known list constraints ? if not, skip this: */                 cp->rval.type != RVAL_TYPE_LIST)        {            Log(LOG_LEVEL_WARNING,                "Unrecognised promise '%s' for %s",                cp->lval, pp->promiser);        }    }}
开发者ID:kacf,项目名称:core,代码行数:62,


示例10: ExpandPromise

PromiseResult ExpandPromise(EvalContext *ctx, const Promise *pp,                            PromiseActuator *ActOnPromise, void *param){    Log(LOG_LEVEL_VERBOSE, "Evaluating promise '%s'", pp->promiser);    if (!IsDefinedClass(ctx, pp->classes))    {        if (LEGACY_OUTPUT)        {            Log(LOG_LEVEL_VERBOSE, ". . . . . . . . . . . . . . . . . . . . . . . . . . . . ");            Log(LOG_LEVEL_VERBOSE, "Skipping whole next promise (%s), as context %s is not relevant", pp->promiser,                  pp->classes);            Log(LOG_LEVEL_VERBOSE, ". . . . . . . . . . . . . . . . . . . . . . . . . . . . ");        }        else        {            Log(LOG_LEVEL_VERBOSE, "Skipping next promise '%s', as context '%s' is not relevant", pp->promiser, pp->classes);        }        return PROMISE_RESULT_SKIPPED;    }    Rlist *lists = NULL;    Rlist *scalars = NULL;    Rlist *containers = NULL;    Promise *pcopy = DeRefCopyPromise(ctx, pp);    MapIteratorsFromRval(ctx, PromiseGetBundle(pp), (Rval) { pcopy->promiser, RVAL_TYPE_SCALAR }, &scalars, &lists, &containers);    if (pcopy->promisee.item != NULL)    {        MapIteratorsFromRval(ctx, PromiseGetBundle(pp), pp->promisee, &scalars, &lists, &containers);    }    for (size_t i = 0; i < SeqLength(pcopy->conlist); i++)    {        Constraint *cp = SeqAt(pcopy->conlist, i);        MapIteratorsFromRval(ctx, PromiseGetBundle(pp), cp->rval, &scalars, &lists, &containers);    }    CopyLocalizedReferencesToBundleScope(ctx, PromiseGetBundle(pp), lists);    CopyLocalizedReferencesToBundleScope(ctx, PromiseGetBundle(pp), scalars);    CopyLocalizedReferencesToBundleScope(ctx, PromiseGetBundle(pp), containers);    PromiseResult result = ExpandPromiseAndDo(ctx, pcopy, lists, containers, ActOnPromise, param);    PromiseDestroy(pcopy);    RlistDestroy(lists);    RlistDestroy(scalars);    RlistDestroy(containers);    return result;}
开发者ID:awsiv,项目名称:core,代码行数:53,


示例11: KeepServerRolePromise

static void KeepServerRolePromise(EvalContext *ctx, Promise *pp){    Rlist *rp;    Auth *ap;    if (!GetAuthPath(pp->promiser, SV.roles))    {        InstallServerAuthPath(pp->promiser, &SV.roles, &SV.rolestop);    }    ap = GetAuthPath(pp->promiser, SV.roles);    for (size_t i = 0; i < SeqLength(pp->conlist); i++)    {        Constraint *cp = SeqAt(pp->conlist, i);        if (!IsDefinedClass(ctx, cp->classes, PromiseGetNamespace(pp)))        {            continue;        }        switch (cp->rval.type)        {        case RVAL_TYPE_LIST:            for (rp = (Rlist *) cp->rval.item; rp != NULL; rp = rp->next)            {                if (strcmp(cp->lval, CF_REMROLE_BODIES[REMOTE_ROLE_AUTHORIZE].lval) == 0)                {                    PrependItem(&(ap->accesslist), rp->item, NULL);                    continue;                }            }            break;        case RVAL_TYPE_FNCALL:            /* Shouldn't happen */            break;        default:            if ((strcmp(cp->lval, "comment") == 0) || (strcmp(cp->lval, "handle") == 0))            {            }            else            {                Log(LOG_LEVEL_ERR, "Right-hand side of authorize promise for '%s' should be a list", pp->promiser);            }            break;        }    }}
开发者ID:nperron,项目名称:core,代码行数:52,


示例12: UpdateDistributions

static void UpdateDistributions(EvalContext *ctx, char *timekey, Averages *av){    int position, day, i;    char filename[CF_BUFSIZE];    FILE *fp;/* Take an interval of 4 standard deviations from -2 to +2, divided into CF_GRAINS   parts. Centre each measurement on CF_GRAINS/2 and scale each measurement by the   std-deviation for the current time.*/    if (IsDefinedClass(ctx, "Min40_45", NULL))    {        day = Day2Number(timekey);        for (i = 0; i < CF_OBSERVABLES; i++)        {            position =                CF_GRAINS / 2 + (int) (0.5 + (CF_THIS[i] - av->Q[i].expect) * CF_GRAINS / (4 * sqrt((av->Q[i].var))));            if ((0 <= position) && (position < CF_GRAINS))            {                HISTOGRAM[i][day][position]++;            }        }        snprintf(filename, CF_BUFSIZE, "%s/state/histograms", CFWORKDIR);        if ((fp = fopen(filename, "w")) == NULL)        {            Log(LOG_LEVEL_ERR, "Unable to save histograms. (fopen: %s)", GetErrorStr());            return;        }        for (position = 0; position < CF_GRAINS; position++)        {            fprintf(fp, "%d ", position);            for (i = 0; i < CF_OBSERVABLES; i++)            {                for (day = 0; day < 7; day++)                {                    fprintf(fp, "%.0lf ", HISTOGRAM[i][day][position]);                }            }            fprintf(fp, "/n");        }        fclose(fp);    }}
开发者ID:arcimboldo,项目名称:cfengine,代码行数:51,


示例13: KeepServerRolePromise

static void KeepServerRolePromise(Promise *pp){    Constraint *cp;    Rlist *rp;    Auth *ap;    if (!GetAuthPath(pp->promiser, ROLES))    {        InstallServerAuthPath(pp->promiser, &ROLES, &ROLESTOP);    }    ap = GetAuthPath(pp->promiser, ROLES);    for (cp = pp->conlist; cp != NULL; cp = cp->next)    {        if (!IsDefinedClass(cp->classes))        {            continue;        }        switch (cp->rval.rtype)        {        case CF_LIST:            for (rp = (Rlist *) cp->rval.item; rp != NULL; rp = rp->next)            {                if (strcmp(cp->lval, CF_REMROLE_BODIES[cfs_authorize].lval) == 0)                {                    PrependItem(&(ap->accesslist), rp->item, NULL);                    continue;                }            }            break;        case CF_FNCALL:            /* Shouldn't happen */            break;        default:            if (strcmp(cp->lval, "comment") == 0 || strcmp(cp->lval, "handle") == 0)            {            }            else            {                CfOut(cf_error, "", "RHS of authorize promise for %s should be a list/n", pp->promiser);            }            break;        }    }}
开发者ID:dnaeon,项目名称:core,代码行数:51,


示例14: ResolvePackageManagerBody

static void ResolvePackageManagerBody(EvalContext *ctx, const Body *pm_body){    PackageModuleBody *new_manager = xcalloc(1, sizeof(PackageModuleBody));    new_manager->name = SafeStringDuplicate(pm_body->name);    for (size_t i = 0; i < SeqLength(pm_body->conlist); i++)    {        Constraint *cp = SeqAt(pm_body->conlist, i);        Rval returnval = {0};        if (IsDefinedClass(ctx, cp->classes))        {            returnval = ExpandPrivateRval(ctx, NULL, "body",                                          cp->rval.item, cp->rval.type);        }        if (returnval.item == NULL || returnval.type == RVAL_TYPE_NOPROMISEE)        {            Log(LOG_LEVEL_VERBOSE, "have invalid constraint while resolving"                    "package promise body: %s", cp->lval);            RvalDestroy(returnval);            continue;        }        if (strcmp(cp->lval, "query_installed_ifelapsed") == 0)        {            new_manager->installed_ifelapsed =                    (int)IntFromString(RvalScalarValue(returnval));        }        else if (strcmp(cp->lval, "query_updates_ifelapsed") == 0)        {            new_manager->updates_ifelapsed =                    (int)IntFromString(RvalScalarValue(returnval));        }        else if (strcmp(cp->lval, "default_options") == 0)        {            new_manager->options = RlistCopy(RvalRlistValue(returnval));        }        else        {            /* This should be handled by the parser. */            assert(0);        }        RvalDestroy(returnval);    }    AddPackageModuleToContext(ctx, new_manager);}
开发者ID:kkaempf,项目名称:core,代码行数:49,


示例15: KeepServerRolePromise

static void KeepServerRolePromise(EvalContext *ctx, const Promise *pp){    Rlist *rp;    Auth *ap;    ap = GetOrCreateAuth(pp->promiser, &SV.roles, &SV.rolestail);    for (size_t i = 0; i < SeqLength(pp->conlist); i++)    {        Constraint *cp = SeqAt(pp->conlist, i);        if (!IsDefinedClass(ctx, cp->classes))        {            continue;        }        switch (cp->rval.type)        {        case RVAL_TYPE_LIST:            for (rp = (Rlist *) cp->rval.item; rp != NULL; rp = rp->next)            {                /* This is for remote class activation by means of cf-runagent.*/                if (strcmp(cp->lval, CF_REMROLE_BODIES[REMOTE_ROLE_AUTHORIZE].lval) == 0)                {                    PrependItem(&(ap->accesslist), RlistScalarValue(rp), NULL);                    continue;                }            }            break;        case RVAL_TYPE_FNCALL:            UnexpectedError("Constraint of type FNCALL is invalid in this context!");            break;        default:            if ((strcmp(cp->lval, "comment") == 0) || (strcmp(cp->lval, "handle") == 0))            {            }            else            {                Log(LOG_LEVEL_ERR, "Right-hand side of authorize promise for '%s' should be a list", pp->promiser);            }            break;        }    }}
开发者ID:awsiv,项目名称:core,代码行数:48,


示例16: ExpandPromise

PromiseResult ExpandPromise(EvalContext *ctx, const Promise *pp,                            PromiseActuator *act_on_promise, void *param){    if (!IsDefinedClass(ctx, pp->classes))    {        return PROMISE_RESULT_SKIPPED;    }    /* 1. Copy the promise while expanding '@' slists and body arguments     *    (including body inheritance). */    Promise *pcopy = DeRefCopyPromise(ctx, pp);    EvalContextStackPushPromiseFrame(ctx, pcopy, true);    PromiseIterator *iterctx = PromiseIteratorNew(pcopy);    /* 2. Parse all strings (promiser-promisee-constraints), find all          unexpanded variables, mangle them if needed (if they are          namespaced/scoped), and start the iteration engine (iterctx) to          iterate over slists and containers. */    MapIteratorsFromRval(ctx, iterctx,    (Rval) {        pcopy->promiser, RVAL_TYPE_SCALAR    });    if (pcopy->promisee.item != NULL)    {        MapIteratorsFromRval(ctx, iterctx, pcopy->promisee);    }    for (size_t i = 0; i < SeqLength(pcopy->conlist); i++)    {        Constraint *cp = SeqAt(pcopy->conlist, i);        MapIteratorsFromRval(ctx, iterctx, cp->rval);    }    /* 3. GO! */    PutHandleVariable(ctx, pcopy);    PromiseResult result = ExpandPromiseAndDo(ctx, iterctx,                           act_on_promise, param);    EvalContextStackPopFrame(ctx);    PromiseIteratorDestroy(iterctx);    PromiseDestroy(pcopy);    return result;}
开发者ID:kacf,项目名称:core,代码行数:47,


示例17: KeepPromises

static void KeepPromises(EvalContext *ctx, const Policy *policy){    Rval retval;    Seq *constraints = ControlBodyConstraints(policy, AGENT_TYPE_MONITOR);    if (constraints)    {        for (size_t i = 0; i < SeqLength(constraints); i++)        {            Constraint *cp = SeqAt(constraints, i);            if (!IsDefinedClass(ctx, cp->classes, NULL))            {                continue;            }            VarRef *ref = VarRefParseFromScope(cp->lval, "control_monitor");            if (!EvalContextVariableGet(ctx, ref, &retval, NULL))            {                Log(LOG_LEVEL_ERR, "Unknown lval '%s' in monitor control body", cp->lval);                VarRefDestroy(ref);                continue;            }            VarRefDestroy(ref);            if (strcmp(cp->lval, CFM_CONTROLBODY[MONITOR_CONTROL_HISTOGRAMS].lval) == 0)            {                /* Keep accepting this option for backward compatibility. */            }            if (strcmp(cp->lval, CFM_CONTROLBODY[MONITOR_CONTROL_TCP_DUMP].lval) == 0)            {                MonNetworkSnifferEnable(BooleanFromString(retval.item));            }            if (strcmp(cp->lval, CFM_CONTROLBODY[MONITOR_CONTROL_FORGET_RATE].lval) == 0)            {                sscanf(retval.item, "%lf", &FORGETRATE);                Log(LOG_LEVEL_DEBUG, "forget rate %f", FORGETRATE);            }        }    }}
开发者ID:gc3-uzh-ch,项目名称:cfengine,代码行数:45,


示例18: NewClass

void NewClass(const char *oclass){struct Item *ip;char class[CF_MAXVARSIZE];strncpy(class, oclass, CF_MAXVARSIZE);Chop(class);CanonifyNameInPlace(class);Debug("NewClass(%s)/n",class);if (strlen(class) == 0)   {   return;   }if (IsRegexItemIn(ABORTBUNDLEHEAP,class))   {   CfOut(cf_error,"","Bundle aborted on defined class /"%s/"/n",class);   ABORTBUNDLE = true;   }if (IsRegexItemIn(ABORTHEAP,class))   {   CfOut(cf_error,"","cf-agent aborted on defined class /"%s/"/n",class);   exit(1);   }if (InAlphaList(VHEAP,class))   {   return;   }PrependAlphaList(&VHEAP,class);for (ip = ABORTHEAP; ip != NULL; ip = ip->next)   {   if (IsDefinedClass(ip->name))      {      CfOut(cf_error,"","cf-agent aborted on defined class /"%s/" defined in bundle %s/n",class,THIS_BUNDLE);      exit(1);      }   }
开发者ID:Kegeruneku,项目名称:Cfengine-debian,代码行数:44,


示例19: KeepPromises

static void KeepPromises(EvalContext *ctx, Policy *policy){    Rval retval;    Seq *constraints = ControlBodyConstraints(policy, AGENT_TYPE_MONITOR);    if (constraints)    {        for (size_t i = 0; i < SeqLength(constraints); i++)        {            Constraint *cp = SeqAt(constraints, i);            if (!IsDefinedClass(ctx, cp->classes, NULL))            {                continue;            }            if (!EvalContextVariableGet(ctx, (VarRef) { NULL, "control_monitor", cp->lval }, &retval, NULL))            {                CfOut(OUTPUT_LEVEL_ERROR, "", "Unknown lval %s in monitor control body", cp->lval);                continue;            }            if (strcmp(cp->lval, CFM_CONTROLBODY[MONITOR_CONTROL_HISTOGRAMS].lval) == 0)            {                /* Keep accepting this option for backward compatibility. */            }            if (strcmp(cp->lval, CFM_CONTROLBODY[MONITOR_CONTROL_TCP_DUMP].lval) == 0)            {                MonNetworkSnifferEnable(BooleanFromString(retval.item));            }            if (strcmp(cp->lval, CFM_CONTROLBODY[MONITOR_CONTROL_FORGET_RATE].lval) == 0)            {                sscanf(retval.item, "%lf", &FORGETRATE);                CfDebug("forget rate = %f/n", FORGETRATE);            }        }    }}
开发者ID:rpoyner,项目名称:core,代码行数:40,


示例20: KeepServerRolePromise

static void KeepServerRolePromise(EvalContext *ctx, const Promise *pp){    Auth *ap = GetOrCreateAuth(pp->promiser, &SV.roles, &SV.rolestail);    const char *const authorizer = CF_REMROLE_BODIES[REMOTE_ROLE_AUTHORIZE].lval;    size_t i = SeqLength(pp->conlist);    while (i > 0)    {        i--;        Constraint *cp = SeqAt(pp->conlist, i);        if (strcmp(cp->lval, authorizer) == 0)        {            if (cp->rval.type != RVAL_TYPE_LIST)            {                Log(LOG_LEVEL_ERR,                    "Right-hand side of authorize promise for '%s' should be a list",                    pp->promiser);            }            else if (IsDefinedClass(ctx, cp->classes))            {                /* This is for remote class activation by means of cf-runagent.*/                for (const Rlist *rp = cp->rval.item; rp != NULL; rp = rp->next)                {                    PrependItem(&(ap->accesslist), RlistScalarValue(rp), NULL);                }            }        }        else if (strcmp(cp->lval, "comment") != 0 &&                 strcmp(cp->lval, "handle") != 0 &&                 /* Are there other known list constraints ? if not, skip this: */                 cp->rval.type != RVAL_TYPE_LIST)        {            Log(LOG_LEVEL_WARNING,                "Unrecognised promise '%s' for %s",                cp->lval, pp->promiser);        }    }}
开发者ID:johndelay,项目名称:core,代码行数:38,


示例21: VerifyInferencePromise

static void VerifyInferencePromise(Promise *pp){    Attributes a = { {0} };    Rlist *rpp, *rpq;    if (!IsDefinedClass(pp->classes))    {        CfOut(cf_verbose, "", " -> Skipping inference for /"%s/" as class /"%s/" is not defined", pp->promiser,              pp->classes);        return;    }    a = GetInferencesAttributes(pp);    for (rpp = a.precedents; rpp != NULL; rpp = rpp->next)    {        for (rpq = a.qualifiers; rpq != NULL; rpq = rpq->next)        {            CfOut(cf_verbose, "", " -> Add inference: (%s,%s,%s)/n", ScalarValue(rpp), ScalarValue(rpq), pp->promiser);            AddInference(&INFERENCES, pp->promiser, rpp->item, rpq->item);        }    }}
开发者ID:dnaeon,项目名称:core,代码行数:23,


示例22: EvalBoolCombination

static bool EvalBoolCombination(EvalContext *ctx, const Rlist *list,                                enum combine_t logic){    bool result = (logic == c_and);    for (const Rlist *rp = list; rp != NULL; rp = rp->next)    {        // tolerate unexpanded entries here and interpret as "class not set"        bool here = (rp->val.type == RVAL_TYPE_SCALAR &&                     IsDefinedClass(ctx, RlistScalarValue(rp)));        // shortcut "and" and "or"        switch (logic)        {        case c_or:            if (here)            {                return true;            }            break;        case c_and:            if (!here)            {                return false;            }            break;        default:            result ^= here;            break;        }    }    return result;}
开发者ID:markburgess,项目名称:Cellibrium,代码行数:36,


示例23: ScheduleRun

static bool ScheduleRun(EvalContext *ctx, Policy **policy, GenericAgentConfig *config, ExecConfig *exec_config){    CfOut(OUTPUT_LEVEL_VERBOSE, "", "Sleeping for pulse time %d seconds.../n", CFPULSETIME);    sleep(CFPULSETIME);         /* 1 Minute resolution is enough */    /*     * FIXME: this logic duplicates the one from cf-serverd.c. Unify ASAP.     */    if (CheckNewPromises(ctx, config, InputFiles(ctx, *policy)) == RELOAD_FULL)    {        /* Full reload */        CfOut(OUTPUT_LEVEL_INFORM, "", "Re-reading promise file %s../n", config->input_file);        EvalContextHeapClear(ctx);        DeleteItemList(IPADDRESSES);        IPADDRESSES = NULL;        ScopeDeleteAll();        strcpy(VDOMAIN, "undefined.domain");        POLICY_SERVER[0] = '/0';        PolicyDestroy(*policy);        *policy = NULL;        SetPolicyServer(ctx, POLICY_SERVER);        ScopeNewSpecialScalar(ctx, "sys", "policy_hub", POLICY_SERVER, DATA_TYPE_STRING);        GetNameInfo3(ctx, AGENT_TYPE_EXECUTOR);        GetInterfacesInfo(ctx, AGENT_TYPE_EXECUTOR);        Get3Environment(ctx, AGENT_TYPE_EXECUTOR);        BuiltinClasses(ctx);        OSClasses(ctx);        EvalContextHeapAddHard(ctx, CF_AGENTTYPES[AGENT_TYPE_EXECUTOR]);        SetReferenceTime(ctx, true);        GenericAgentConfigSetBundleSequence(config, NULL);        *policy = GenericAgentLoadPolicy(ctx, config);        ExecConfigUpdate(ctx, *policy, exec_config);        SetFacility(exec_config->log_facility);    }    else    {        /* Environment reload */        EvalContextHeapClear(ctx);        DeleteItemList(IPADDRESSES);        IPADDRESSES = NULL;        ScopeClear("this");        ScopeClear("mon");        ScopeClear("sys");        GetInterfacesInfo(ctx, AGENT_TYPE_EXECUTOR);        Get3Environment(ctx, AGENT_TYPE_EXECUTOR);        BuiltinClasses(ctx);        OSClasses(ctx);        SetReferenceTime(ctx, true);    }    {        StringSetIterator it = StringSetIteratorInit(exec_config->schedule);        const char *time_context = NULL;        while ((time_context = StringSetIteratorNext(&it)))        {            if (IsDefinedClass(ctx, time_context, NULL))            {                CfOut(OUTPUT_LEVEL_VERBOSE, "", "Waking up the agent at %s ~ %s /n", cf_ctime(&CFSTARTTIME), time_context);                return true;            }        }    }    CfOut(OUTPUT_LEVEL_VERBOSE, "", "Nothing to do at %s/n", cf_ctime(&CFSTARTTIME));    return false;}
开发者ID:fkoner,项目名称:core,代码行数:84,


示例24: EvalClassExpression

static int EvalClassExpression(EvalContext *ctx, Constraint *cp, Promise *pp){    int result_and = true;    int result_or = false;    int result_xor = 0;    int result = 0, total = 0;    char buffer[CF_MAXVARSIZE];    Rlist *rp;    FnCall *fp;    Rval rval;    if (cp == NULL)    {        Log(LOG_LEVEL_ERR, "EvalClassExpression internal diagnostic discovered an ill-formed condition");    }    if (!IsDefinedClass(ctx, pp->classes, PromiseGetNamespace(pp)))    {        return false;    }    if (EvalContextPromiseIsDone(ctx, pp))    {        return false;    }    if (IsDefinedClass(ctx, pp->promiser, PromiseGetNamespace(pp)))    {        if (PromiseGetConstraintAsInt(ctx, "persistence", pp) == 0)        {            Log(LOG_LEVEL_VERBOSE, " ?> Cancelling cached persistent class %s", pp->promiser);            EvalContextHeapPersistentRemove(pp->promiser);        }        return false;    }    switch (cp->rval.type)    {    case RVAL_TYPE_FNCALL:        fp = (FnCall *) cp->rval.item;  /* Special expansion of functions for control, best effort only */        FnCallResult res = FnCallEvaluate(ctx, fp, pp);        FnCallDestroy(fp);        cp->rval = res.rval;        break;    case RVAL_TYPE_LIST:        for (rp = (Rlist *) cp->rval.item; rp != NULL; rp = rp->next)        {            rval = EvaluateFinalRval(ctx, "this", (Rval) {rp->item, rp->type}, true, pp);            RvalDestroy((Rval) {rp->item, rp->type});            rp->item = rval.item;            rp->type = rval.type;        }        break;    default:        rval = ExpandPrivateRval(ctx, "this", cp->rval);        RvalDestroy(cp->rval);        cp->rval = rval;        break;    }    if (strcmp(cp->lval, "expression") == 0)    {        if (cp->rval.type != RVAL_TYPE_SCALAR)        {            return false;        }        if (IsDefinedClass(ctx, (char *) cp->rval.item, PromiseGetNamespace(pp)))        {            return true;        }        else        {            return false;        }    }    if (strcmp(cp->lval, "not") == 0)    {        if (cp->rval.type != RVAL_TYPE_SCALAR)        {            return false;        }        if (IsDefinedClass(ctx, (char *) cp->rval.item, PromiseGetNamespace(pp)))        {            return false;        }        else        {            return true;        }    }// Class selection//.........这里部分代码省略.........
开发者ID:arcimboldo,项目名称:cfengine,代码行数:101,


示例25: CollectConvergeVariableOptions

/** * @brief Collects variable constraints controlling how the promise should be converged */static ConvergeVariableOptions CollectConvergeVariableOptions(EvalContext *ctx, const Promise *pp, bool allow_redefine){    ConvergeVariableOptions opts = { 0 };    opts.should_converge = false;    opts.drop_undefined = false;    opts.ok_redefine = allow_redefine;    opts.cp_save = NULL;    if (!IsDefinedClass(ctx, pp->classes))    {        return opts;    }    int num_values = 0;    for (size_t i = 0; i < SeqLength(pp->conlist); i++)    {        Constraint *cp = SeqAt(pp->conlist, i);        if (strcmp(cp->lval, "comment") == 0)        {            continue;        }        if (cp->rval.item == NULL)        {            continue;        }        if (strcmp(cp->lval, "ifvarclass") == 0)        {            switch (cp->rval.type)            {            case RVAL_TYPE_SCALAR:                if (!IsDefinedClass(ctx, cp->rval.item))                {                    return opts;                }                break;            case RVAL_TYPE_FNCALL:                {                    bool excluded = false;                    /* eval it: e.g. ifvarclass => not("a_class") */                    Rval res = FnCallEvaluate(ctx, PromiseGetPolicy(pp), cp->rval.item, pp).rval;                    /* Don't continue unless function was evaluated properly */                    if (res.type != RVAL_TYPE_SCALAR)                    {                        RvalDestroy(res);                        return opts;                    }                    excluded = !IsDefinedClass(ctx, res.item);                    RvalDestroy(res);                    if (excluded)                    {                        return opts;                    }                }                break;            default:                Log(LOG_LEVEL_ERR, "Invalid ifvarclass type '%c': should be string or function", cp->rval.type);                continue;            }            continue;        }        if (strcmp(cp->lval, "policy") == 0)        {            if (strcmp(cp->rval.item, "ifdefined") == 0)            {                opts.drop_undefined = true;                opts.ok_redefine = false;            }            else if (strcmp(cp->rval.item, "constant") == 0)            {                opts.ok_redefine = false;            }            else            {                opts.ok_redefine |= true;            }            opts.ok_redefine &= allow_redefine;        }        else if (DataTypeFromString(cp->lval) != CF_DATA_TYPE_NONE)        {            num_values++;            opts.cp_save = cp;        }//.........这里部分代码省略.........
开发者ID:awsiv,项目名称:core,代码行数:101,


示例26: VerifyFilePromise

//.........这里部分代码省略.........    {        if (stat(a.link.source, &dsb) != -1)        {            if (!S_ISDIR(dsb.st_mode))            {                Log(LOG_LEVEL_ERR, "Cannot promise to link the children of '%s' as it is not a directory!",                      a.link.source);                goto exit;            }        }    }/* Phase 1 - */    if (exists && ((a.havedelete) || (a.haverename) || (a.haveperms) || (a.havechange) || (a.transformer)))    {        lstat(path, &oslb);     /* if doesn't exist have to stat again anyway */        DepthSearch(ctx, path, &oslb, 0, a, pp, oslb.st_dev, &result);        /* normally searches do not include the base directory */        if (a.recursion.include_basedir)        {            int save_search = a.havedepthsearch;            /* Handle this node specially */            a.havedepthsearch = false;            DepthSearch(ctx, path, &oslb, 0, a, pp, oslb.st_dev, &result);            a.havedepthsearch = save_search;        }        else        {            /* unless child nodes were repaired, set a promise kept class */            if (!IsDefinedClass(ctx, "repaired" , PromiseGetNamespace(pp)))            {                cfPS(ctx, LOG_LEVEL_VERBOSE, PROMISE_RESULT_NOOP, pp, a, "Basedir '%s' not promising anything", path);            }        }        if (((a.change.report_changes) == FILE_CHANGE_REPORT_CONTENT_CHANGE) || ((a.change.report_changes) == FILE_CHANGE_REPORT_ALL))        {            if (a.havedepthsearch)            {                PurgeHashes(ctx, NULL, a, pp);            }            else            {                PurgeHashes(ctx, path, a, pp);            }        }    }/* Phase 2a - copying is potentially threadable if no followup actions */    if (a.havecopy)    {        result = PromiseResultUpdate(result, ScheduleCopyOperation(ctx, path, a, pp));    }/* Phase 2b link after copy in case need file first */    if ((a.havelink) && (a.link.link_children))    {        result = PromiseResultUpdate(result, ScheduleLinkChildrenOperation(ctx, path, a.link.source, 1, a, pp));    }    else if (a.havelink)    {        result = PromiseResultUpdate(result, ScheduleLinkOperation(ctx, path, a.link.source, a, pp));    }/* Phase 3 - content editing */    if (a.haveedit)    {        result = PromiseResultUpdate(result, ScheduleEditOperation(ctx, path, a, pp));    }// Once more in case a file has been created as a result of editing or copying    exists = (stat(path, &osb) != -1);    if (exists && (S_ISREG(osb.st_mode)))    {        VerifyFileLeaf(ctx, path, &osb, a, pp, &result);    }    if (!exists && a.havechange)    {        cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, a, "Promised to monitor '%s' for changes, but file does not exist", path);        result = PromiseResultUpdate(result, PROMISE_RESULT_FAIL);    }exit:    result = PromiseResultUpdate(result, SaveSetuid(ctx, a, pp));    YieldCurrentLock(thislock);    return result;}
开发者ID:cduclos,项目名称:core,代码行数:101,


示例27: xcalloc

//.........这里部分代码省略.........            }            fp = NULL;            break;        case RVAL_TYPE_FNCALL:            fp = RvalFnCallValue(cp->rval);            SplitScopeName(fp->name, body_ns, body_name);            if (EmptyString(body_ns))            {                strncpy(body_ns, PromiseGetNamespace(pp), CF_MAXVARSIZE);            }            bp = IsBody(bodies, body_ns, body_name);            break;        default:            bp = NULL;            fp = NULL;            break;        }        /* First case is: we have a body template to expand lval = body(args), .. */        if (bp)        {            EvalContextStackPushBodyFrame(ctx, pcopy, bp, fp ? fp->args : NULL);            if (strcmp(bp->type, cp->lval) != 0)            {                Log(LOG_LEVEL_ERR,                    "Body type mismatch for body reference '%s' in promise at line %zu of file '%s', '%s' does not equal '%s'",                      body_name, pp->offset.line, PromiseGetBundle(pp)->source_path, bp->type, cp->lval);            }            /* Keep the referent body type as a boolean for convenience when checking later */            if (IsDefinedClass(ctx, cp->classes, PromiseGetNamespace(pcopy)))            {                Constraint *cp_copy = PromiseAppendConstraint(pcopy, cp->lval, (Rval) {xstrdup("true"), RVAL_TYPE_SCALAR }, false);                cp_copy->offset = cp->offset;            }            if (bp->args != NULL)            {                /* There are arguments to insert */                if (fp == NULL || fp->args == NULL)                {                    Log(LOG_LEVEL_ERR, "Argument mismatch for body reference '%s' in promise at line %zu of file '%s'",                          body_name, pp->offset.line, PromiseGetBundle(pp)->source_path);                }                for (size_t k = 0; k < SeqLength(bp->conlist); k++)                {                    Constraint *scp = SeqAt(bp->conlist, k);                    returnval = ExpandPrivateRval(ctx, NULL, "body", scp->rval.item, scp->rval.type);                    if (IsDefinedClass(ctx, scp->classes, PromiseGetNamespace(pcopy)))                    {                        Constraint *scp_copy = PromiseAppendConstraint(pcopy, scp->lval, returnval, false);                        scp_copy->offset = scp->offset;                    }                }            }            else            {                /* No arguments to deal with or body undeclared */                if (fp != NULL)
开发者ID:embedian,项目名称:core,代码行数:67,


示例28: ScheduleRun

//.........这里部分代码省略.........    if (CheckNewPromises(config->input_file, InputFiles(*policy), report_context) == RELOAD_FULL)    {        /* Full reload */        CfOut(OUTPUT_LEVEL_INFORM, "", "Re-reading promise file %s../n", config->input_file);        DeleteAlphaList(&VHEAP);        InitAlphaList(&VHEAP);        DeleteAlphaList(&VHARDHEAP);        InitAlphaList(&VHARDHEAP);        DeleteAlphaList(&VADDCLASSES);        InitAlphaList(&VADDCLASSES);        DeleteItemList(IPADDRESSES);        IPADDRESSES = NULL;        DeleteItemList(VNEGHEAP);        DeleteAllScope();        strcpy(VDOMAIN, "undefinded.domain");        POLICY_SERVER[0] = '/0';        VNEGHEAP = NULL;        PolicyDestroy(*policy);        *policy = NULL;        ERRORCOUNT = 0;        NewScope("sys");        SetPolicyServer(POLICY_SERVER);        NewScalar("sys", "policy_hub", POLICY_SERVER, DATA_TYPE_STRING);        NewScope("const");        NewScope("this");        NewScope("mon");        NewScope("control_server");        NewScope("control_common");        NewScope("remote_access");        GetNameInfo3();        GetInterfacesInfo(AGENT_TYPE_EXECUTOR);        Get3Environment();        BuiltinClasses();        OSClasses();        HardClass(CF_AGENTTYPES[THIS_AGENT_TYPE]);        SetReferenceTime(true);        GenericAgentConfigSetBundleSequence(config, NULL);        *policy = GenericAgentLoadPolicy(AGENT_TYPE_EXECUTOR, config, report_context);        KeepPromises(*policy, exec_config);    }    else    {        /* Environment reload */        DeleteAlphaList(&VHEAP);        InitAlphaList(&VHEAP);        DeleteAlphaList(&VADDCLASSES);        InitAlphaList(&VADDCLASSES);        DeleteAlphaList(&VHARDHEAP);        InitAlphaList(&VHARDHEAP);        DeleteItemList(IPADDRESSES);        IPADDRESSES = NULL;        DeleteScope("this");        DeleteScope("mon");        DeleteScope("sys");        NewScope("this");        NewScope("mon");        NewScope("sys");        GetInterfacesInfo(AGENT_TYPE_EXECUTOR);        Get3Environment();        BuiltinClasses();        OSClasses();        SetReferenceTime(true);    }    for (ip = SCHEDULE; ip != NULL; ip = ip->next)    {        CfOut(OUTPUT_LEVEL_VERBOSE, "", "Checking schedule %s.../n", ip->name);        if (IsDefinedClass(ip->name, NULL))        {            CfOut(OUTPUT_LEVEL_VERBOSE, "", "Waking up the agent at %s ~ %s /n", cf_ctime(&CFSTARTTIME), ip->name);            return true;        }    }    CfOut(OUTPUT_LEVEL_VERBOSE, "", "Nothing to do at %s/n", cf_ctime(&CFSTARTTIME));    return false;}
开发者ID:FancsalMelinda,项目名称:core,代码行数:101,


示例29: EvalContextStackFrameAddSoft

void EvalContextStackFrameAddSoft(EvalContext *ctx, const char *context){    assert(SeqLength(ctx->stack) > 0);    StackFrameBundle frame;    {        StackFrame *last_frame = LastStackFrameBundle(ctx);        if (!last_frame)        {            ProgrammingError("Attempted to add a soft class on the stack, but stack had no bundle frame");        }        frame = last_frame->data.bundle;    }    char copy[CF_BUFSIZE];    if (strcmp(frame.owner->ns, "default") != 0)    {         snprintf(copy, CF_MAXVARSIZE, "%s:%s", frame.owner->ns, context);    }    else    {         strncpy(copy, context, CF_MAXVARSIZE);    }    if (Chop(copy, CF_EXPANDSIZE) == -1)    {        CfOut(OUTPUT_LEVEL_ERROR, "", "Chop was called on a string that seemed to have no terminator");    }    if (strlen(copy) == 0)    {        return;    }    CfDebug("NewBundleClass(%s)/n", copy);        if (IsRegexItemIn(ctx, ctx->heap_abort_current_bundle, copy))    {        CfOut(OUTPUT_LEVEL_ERROR, "", "Bundle %s aborted on defined class /"%s/"/n", frame.owner->name, copy);        ABORTBUNDLE = true;    }    if (IsRegexItemIn(ctx, ctx->heap_abort, copy))    {        CfOut(OUTPUT_LEVEL_ERROR, "", "cf-agent aborted on defined class /"%s/" defined in bundle %s/n", copy, frame.owner->name);        exit(1);    }    if (EvalContextHeapContainsSoft(ctx, copy))    {        CfOut(OUTPUT_LEVEL_ERROR, "", "WARNING - private class /"%s/" in bundle /"%s/" shadows a global class - you should choose a different name to avoid conflicts",              copy, frame.owner->name);    }    if (EvalContextStackFrameContainsSoft(ctx, copy))    {        return;    }    StringSetAdd(frame.contexts, xstrdup(copy));    for (const Item *ip = ctx->heap_abort; ip != NULL; ip = ip->next)    {        if (IsDefinedClass(ctx, ip->name, frame.owner->ns))        {            CfOut(OUTPUT_LEVEL_ERROR, "", "cf-agent aborted on defined class /"%s/" defined in bundle %s/n", copy, frame.owner->name);            exit(1);        }    }    if (!ABORTBUNDLE)    {        for (const Item *ip = ctx->heap_abort_current_bundle; ip != NULL; ip = ip->next)        {            if (IsDefinedClass(ctx, ip->name, frame.owner->ns))            {                CfOut(OUTPUT_LEVEL_ERROR, "", " -> Setting abort for /"%s/" when setting /"%s/"", ip->name, context);                ABORTBUNDLE = true;                break;            }        }    }}
开发者ID:shaunamarie,项目名称:core,代码行数:83,


示例30: EvalContextHeapAddSoft

void EvalContextHeapAddSoft(EvalContext *ctx, const char *context, const char *ns){    char context_copy[CF_MAXVARSIZE];    char canonified_context[CF_MAXVARSIZE];    strcpy(canonified_context, context);    if (Chop(canonified_context, CF_EXPANDSIZE) == -1)    {        Log(LOG_LEVEL_ERR, "Chop was called on a string that seemed to have no terminator");    }    CanonifyNameInPlace(canonified_context);        if (ns && strcmp(ns, "default") != 0)    {        snprintf(context_copy, CF_MAXVARSIZE, "%s:%s", ns, canonified_context);    }    else    {        strncpy(context_copy, canonified_context, CF_MAXVARSIZE);    }    if (strlen(context_copy) == 0)    {        return;    }    if (IsRegexItemIn(ctx, ctx->heap_abort_current_bundle, context_copy))    {        Log(LOG_LEVEL_ERR, "Bundle aborted on defined class '%s'", context_copy);        ABORTBUNDLE = true;    }    if (IsRegexItemIn(ctx, ctx->heap_abort, context_copy))    {        Log(LOG_LEVEL_ERR, "cf-agent aborted on defined class '%s'", context_copy);        exit(1);    }    if (EvalContextHeapContainsSoft(ctx, context_copy))    {        return;    }    StringSetAdd(ctx->heap_soft, xstrdup(context_copy));    for (const Item *ip = ctx->heap_abort; ip != NULL; ip = ip->next)    {        if (IsDefinedClass(ctx, ip->name, ns))        {            Log(LOG_LEVEL_ERR, "cf-agent aborted on defined class '%s' defined in bundle '%s'", ip->name, StackFrameOwnerName(LastStackFrame(ctx, 0)));            exit(1);        }    }    if (!ABORTBUNDLE)    {        for (const Item *ip = ctx->heap_abort_current_bundle; ip != NULL; ip = ip->next)        {            if (IsDefinedClass(ctx, ip->name, ns))            {                Log(LOG_LEVEL_ERR, "Setting abort for '%s' when setting '%s'", ip->name, context_copy);                ABORTBUNDLE = true;                break;            }        }    }}
开发者ID:jeffali,项目名称:core,代码行数:67,



注:本文中的IsDefinedClass函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ IsDevicePathEnd函数代码示例
C++ IsDefined函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。