当前位置: 首页>>代码示例>>C++>>正文


C++ RlistScalarValue函数代码示例

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


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

示例1: ParseFlagString

int ParseFlagString(Rlist *bitlist, u_long *plusmask, u_long *minusmask)
{
    if (bitlist == NULL)
    {
        return true;
    }

    *plusmask = 0;
    *minusmask = 0;

    for (const Rlist *rp = bitlist; rp != NULL; rp = rp->next)
    {
        const char *flag = RlistScalarValue(rp);
        char op = *RlistScalarValue(rp);

        switch (op)
        {
        case '-':
            *minusmask |= ConvertBSDBits(flag + 1);
            break;

        case '+':
            *plusmask |= ConvertBSDBits(flag + 1);
            break;

        default:
            *plusmask |= ConvertBSDBits(flag);
            break;

        }
    }

    Log(LOG_LEVEL_DEBUG, "ParseFlagString: [PLUS = %lo] [MINUS = %lo]", *plusmask, *minusmask);
    return true;
}
开发者ID:AsherBond,项目名称:core,代码行数:35,代码来源:chflags.c

示例2: RlistItemMACLess

static bool RlistItemMACLess(void *lhs, void *rhs, ARG_UNUSED void *ctx)
{
    int bytes = 6;
    unsigned char left[bytes], right[bytes];
    int matched_left = 6 == ParseEtherAddress(RlistScalarValue((Rlist*)lhs), left);
    int matched_right = 6 == ParseEtherAddress(RlistScalarValue((Rlist*)rhs), right);

    if (matched_left && matched_right)
    {
        int difference = memcmp(left, right, bytes);
        if (difference != 0) return difference < 0;
    }

    if (matched_left)
    {
        return false;
    }

    if (matched_right)
    {
        return true;
    }

    // neither item matched
    return RlistItemLess(lhs, rhs, ctx);
}
开发者ID:cduclos,项目名称:core,代码行数:26,代码来源:sort.c

示例3: PromiseIteratorUpdateVariable

void PromiseIteratorUpdateVariable(EvalContext *ctx, const PromiseIterator *iter)
{
    for (size_t i = 0; i < SeqLength(iter->vars); i++)
    {
        CfAssoc *iter_var = SeqAt(iter->vars, i);

        const Rlist *state = SeqAt(iter->var_states, i);

        if (!state || state->val.type == RVAL_TYPE_FNCALL)
        {
            continue;
        }

        assert(state->val.type == RVAL_TYPE_SCALAR);

        switch (iter_var->dtype)
        {
        case CF_DATA_TYPE_STRING_LIST:
            EvalContextVariablePutSpecial(ctx, SPECIAL_SCOPE_THIS, iter_var->lval, RlistScalarValue(state), CF_DATA_TYPE_STRING, "source=promise");
            break;
        case CF_DATA_TYPE_INT_LIST:
            EvalContextVariablePutSpecial(ctx, SPECIAL_SCOPE_THIS, iter_var->lval, RlistScalarValue(state), CF_DATA_TYPE_INT, "source=promise");
            break;
        case CF_DATA_TYPE_REAL_LIST:
            EvalContextVariablePutSpecial(ctx, SPECIAL_SCOPE_THIS, iter_var->lval, RlistScalarValue(state), CF_DATA_TYPE_REAL, "source=promise");
            break;
        default:
            assert(false);
            break;
        }
    }
}
开发者ID:Kegeruneku,项目名称:core,代码行数:32,代码来源:iteration.c

示例4: DoAllSignals

int DoAllSignals(EvalContext *ctx, Item *siglist, Attributes a, const Promise *pp, PromiseResult *result)
{
    Item *ip;
    Rlist *rp;
    pid_t pid;
    int killed = false;

    if (siglist == NULL)
    {
        return 0;
    }

    if (a.signals == NULL)
    {
        Log(LOG_LEVEL_VERBOSE, "No signals to send for '%s'", pp->promiser);
        return 0;
    }

    for (ip = siglist; ip != NULL; ip = ip->next)
    {
        pid = ip->counter;

        for (rp = a.signals; rp != NULL; rp = rp->next)
        {
            int signal = SignalFromString(RlistScalarValue(rp));

            if (!DONTDO)
            {
                if ((signal == SIGKILL) || (signal == SIGTERM))
                {
                    killed = true;
                }

                if (kill((pid_t) pid, signal) < 0)
                {
                    cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, a,
                         "Couldn't send promised signal '%s' (%d) to pid %jd (might be dead). (kill: %s)", RlistScalarValue(rp),
                         signal, (intmax_t)pid, GetErrorStr());
                    *result = PromiseResultUpdate(*result, PROMISE_RESULT_FAIL);
                }
                else
                {
                    cfPS(ctx, LOG_LEVEL_INFO, PROMISE_RESULT_CHANGE, pp, a, "Signalled '%s' (%d) to process %jd (%s)",
                         RlistScalarValue(rp), signal, (intmax_t)pid, ip->name);
                    *result = PromiseResultUpdate(*result, PROMISE_RESULT_CHANGE);
                }
            }
            else
            {
                Log(LOG_LEVEL_ERR, "Need to keep signal promise '%s' in process entry '%s'",
                      RlistScalarValue(rp), ip->name);
            }
        }
    }

    return killed;
}
开发者ID:awsiv,项目名称:core,代码行数:57,代码来源:verify_processes.c

示例5: test_split_escaped

static void test_split_escaped(void)
{
    Rlist *list = RlistFromSplitString("a\\,b\\c\\,d,w\\,x\\,y\\,z", ',');
    assert_int_equal(2, RlistLen(list));
    assert_string_equal("a,b\\c,d", RlistScalarValue(list));
    assert_string_equal("w,x,y,z", RlistScalarValue(list->next));

    RlistDestroy(list);
}
开发者ID:awsiv,项目名称:core,代码行数:9,代码来源:rlist_test.c

示例6: DoAllSignals

static int DoAllSignals(Item *siglist, Attributes a, Promise *pp)
{
    Item *ip;
    Rlist *rp;
    pid_t pid;
    int killed = false;

    CfDebug("DoSignals(%s)\n", pp->promiser);

    if (siglist == NULL)
    {
        return 0;
    }

    if (a.signals == NULL)
    {
        CfOut(OUTPUT_LEVEL_VERBOSE, "", " -> No signals to send for %s\n", pp->promiser);
        return 0;
    }

    for (ip = siglist; ip != NULL; ip = ip->next)
    {
        pid = ip->counter;

        for (rp = a.signals; rp != NULL; rp = rp->next)
        {
            int signal = SignalFromString(rp->item);

            if (!DONTDO)
            {
                if ((signal == SIGKILL) || (signal == SIGTERM))
                {
                    killed = true;
                }

                if (kill((pid_t) pid, signal) < 0)
                {
                    cfPS(OUTPUT_LEVEL_VERBOSE, CF_FAIL, "kill", pp, a,
                         " !! Couldn't send promised signal \'%s\' (%d) to pid %jd (might be dead)\n", RlistScalarValue(rp),
                         signal, (intmax_t)pid);
                }
                else
                {
                    cfPS(OUTPUT_LEVEL_INFORM, CF_CHG, "", pp, a, " -> Signalled '%s' (%d) to process %jd (%s)\n",
                         RlistScalarValue(rp), signal, (intmax_t)pid, ip->name);
                }
            }
            else
            {
                CfOut(OUTPUT_LEVEL_ERROR, "", " -> Need to keep signal promise \'%s\' in process entry %s",
                      RlistScalarValue(rp), ip->name);
            }
        }
    }

    return killed;
}
开发者ID:FancsalMelinda,项目名称:core,代码行数:57,代码来源:verify_processes.c

示例7: CheckRegistrySanity

static int CheckRegistrySanity(const Attributes *a, const Promise *pp)
{
    assert(a != NULL);
    bool retval = true;

    ValidateRegistryPromiser(pp->promiser, pp);

    if ((a->database.operation) && (strcmp(a->database.operation, "create") == 0))
    {
        if (a->database.rows == NULL)
        {
            Log(LOG_LEVEL_INFO, "No row values promised for the MS registry database");
        }

        if (a->database.columns != NULL)
        {
            Log(LOG_LEVEL_ERR, "Columns are only used to delete promised values for the MS registry database");
            retval = false;
        }
    }

    if ((a->database.operation)
        && ((strcmp(a->database.operation, "delete") == 0) || (strcmp(a->database.operation, "drop") == 0)))
    {
        if (a->database.columns == NULL)
        {
            Log(LOG_LEVEL_INFO, "No columns were promised deleted in the MS registry database");
        }

        if (a->database.rows != NULL)
        {
            Log(LOG_LEVEL_ERR, "Rows cannot be deleted in the MS registry database, only entire columns");
            retval = false;
        }
    }

    for (Rlist *rp = a->database.rows; rp != NULL; rp = rp->next)
    {
        if (CountChar(RlistScalarValue(rp), ',') != 2)
        {
            Log(LOG_LEVEL_ERR, "Registry row format should be NAME,REG_SZ,VALUE, not '%s'", RlistScalarValue(rp));
            retval = false;
        }
    }

    for (Rlist *rp = a->database.columns; rp != NULL; rp = rp->next)
    {
        if (CountChar(RlistScalarValue(rp), ',') > 0)
        {
            Log(LOG_LEVEL_ERR, "MS registry column format should be NAME only in deletion");
            retval = false;
        }
    }

    return retval;
}
开发者ID:nickanderson,项目名称:core,代码行数:56,代码来源:verify_databases.c

示例8: test_last

static void test_last(void)
{
    Rlist *l = NULL;
    assert_true(RlistLast(l) == NULL);
    RlistAppendScalar(&l, "a");
    assert_string_equal("a", RlistScalarValue(RlistLast(l)));
    RlistAppendScalar(&l, "b");
    assert_string_equal("b", RlistScalarValue(RlistLast(l)));
    RlistDestroy(l);
}
开发者ID:cduclos,项目名称:core,代码行数:10,代码来源:rlist_test.c

示例9: DistributeClass

static bool DistributeClass(EvalContext *ctx, const Rlist *dist, const Promise *pp)
{
    int total = 0;
    const Rlist *rp;

    for (rp = dist; rp != NULL; rp = rp->next)
    {
        int result = IntFromString(RlistScalarValue(rp));

        if (result < 0)
        {
            Log(LOG_LEVEL_ERR, "Negative integer in class distribution");
            PromiseRef(LOG_LEVEL_ERR, pp);
            return false;
        }

        total += result;
    }

    if (total == 0)
    {
        Log(LOG_LEVEL_ERR, "An empty distribution was specified on RHS");
        PromiseRef(LOG_LEVEL_ERR, pp);
        return false;
    }

    double fluct = drand48() * total;
    assert(0 <= fluct && fluct < total);

    for (rp = dist; rp != NULL; rp = rp->next)
    {
        fluct -= IntFromString(RlistScalarValue(rp));
        if (fluct < 0)
        {
            break;
        }
    }
    assert(rp);

    char buffer[CF_MAXVARSIZE];
    snprintf(buffer, CF_MAXVARSIZE, "%s_%s", pp->promiser, RlistScalarValue(rp));

    if (strcmp(PromiseGetBundle(pp)->type, "common") == 0)
    {
        EvalContextClassPutSoft(ctx, buffer, CONTEXT_SCOPE_NAMESPACE,
                                "source=promise");
    }
    else
    {
        EvalContextClassPutSoft(ctx, buffer, CONTEXT_SCOPE_BUNDLE,
                                "source=promise");
    }

    return true;
}
开发者ID:markburgess,项目名称:Cellibrium,代码行数:55,代码来源:verify_classes.c

示例10: RlistIsUnresolved

bool RlistIsUnresolved(const Rlist *list)
{
    for (const Rlist *rp = list; rp != NULL; rp = rp->next)
    {
        if (rp->val.type != RVAL_TYPE_SCALAR)
        {
            return true;
        }

        if (IsCf3Scalar(RlistScalarValue(rp)))
        {
            if (strstr(RlistScalarValue(rp), "$(this)") || strstr(RlistScalarValue(rp), "${this}") ||
                strstr(RlistScalarValue(rp), "$(this.k)") || strstr(RlistScalarValue(rp), "${this.k}") ||
                strstr(RlistScalarValue(rp), "$(this.k[1])") || strstr(RlistScalarValue(rp), "${this.k[1]}") ||
                strstr(RlistScalarValue(rp), "$(this.v)") || strstr(RlistScalarValue(rp), "${this.v}"))
            {
                // We should allow this in function args for substitution in maplist() etc
                // We should allow this.k and this.k[1] and this.v in function args for substitution in maparray() etc
            }
            else
            {
                return true;
            }
        }
    }

    return false;
}
开发者ID:amousset,项目名称:core,代码行数:28,代码来源:vars.c

示例11: SelectOwnerMatch

static int SelectOwnerMatch(EvalContext *ctx, char *path, struct stat *lstatptr, Rlist *crit)
{
    Rlist *rp;
    char ownerName[CF_BUFSIZE];
    int gotOwner;

    StringSet *leafattrib = StringSetNew();

#ifndef __MINGW32__                   // no uids on Windows
    char buffer[CF_SMALLBUF];
    snprintf(buffer, CF_SMALLBUF, "%jd", (uintmax_t) lstatptr->st_uid);
    StringSetAdd(leafattrib, xstrdup(buffer));
#endif /* __MINGW32__ */

    gotOwner = GetOwnerName(path, lstatptr, ownerName, sizeof(ownerName));

    if (gotOwner)
    {
        StringSetAdd(leafattrib, xstrdup(ownerName));
    }
    else
    {
        StringSetAdd(leafattrib, xstrdup("none"));
    }

    for (rp = crit; rp != NULL; rp = rp->next)
    {
        if (EvalFileResult((char *) rp->item, leafattrib))
        {
            Log(LOG_LEVEL_DEBUG, "Select owner match");
            StringSetDestroy(leafattrib);
            return true;
        }

        if (gotOwner && (FullTextMatch(ctx, RlistScalarValue(rp), ownerName)))
        {
            Log(LOG_LEVEL_DEBUG, "Select owner match");
            StringSetDestroy(leafattrib);
            return true;
        }

#ifndef __MINGW32__
        if (FullTextMatch(ctx, RlistScalarValue(rp), buffer))
        {
            Log(LOG_LEVEL_DEBUG, "Select owner match");
            StringSetDestroy(leafattrib);
            return true;
        }
#endif /* !__MINGW32__ */
    }

    StringSetDestroy(leafattrib);
    return false;
}
开发者ID:nperron,项目名称:core,代码行数:54,代码来源:files_select.c

示例12: test_reverse

static void test_reverse(void)
{
    Rlist *list = RlistFromSplitString("a,b,c", ',');

    RlistReverse(&list);
    assert_string_equal("c", RlistScalarValue(list));
    assert_string_equal("b", RlistScalarValue(list->next));
    assert_string_equal("a", RlistScalarValue(list->next->next));

    RlistDestroy(list);
}
开发者ID:cduclos,项目名称:core,代码行数:11,代码来源:rlist_test.c

示例13: test_regex_split_too_few_chunks

static void test_regex_split_too_few_chunks()
{
    Rlist *list = RlistFromRegexSplitNoOverflow("one:two:three", ":", 2);

    assert_int_equal(2, RlistLen(list));

    assert_string_equal(RlistScalarValue(list), "one");
    assert_string_equal(RlistScalarValue(list->next), "two:three");

    RlistDestroy(list);
}
开发者ID:awsiv,项目名称:core,代码行数:11,代码来源:rlist_test.c

示例14: test_regex_split_overlapping_delimiters

static void test_regex_split_overlapping_delimiters()
{
    Rlist *list = RlistFromRegexSplitNoOverflow("-one---two---three", "--", 3);

    assert_int_equal(3, RlistLen(list));

    assert_string_equal(RlistScalarValue(list), "-one");
    assert_string_equal(RlistScalarValue(list->next), "-two");
    assert_string_equal(RlistScalarValue(list->next->next), "-three");

    RlistDestroy(list);
}
开发者ID:awsiv,项目名称:core,代码行数:12,代码来源:rlist_test.c

示例15: test_regex_split

static void test_regex_split()
{
    Rlist *list = RlistFromRegexSplitNoOverflow("one-->two-->three", "-+>", 3);

    assert_int_equal(3, RlistLen(list));

    assert_string_equal(RlistScalarValue(list), "one");
    assert_string_equal(RlistScalarValue(list->next), "two");
    assert_string_equal(RlistScalarValue(list->next->next), "three");

    RlistDestroy(list);
}
开发者ID:awsiv,项目名称:core,代码行数:12,代码来源:rlist_test.c


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