本文整理汇总了C++中IsCf3VarString函数的典型用法代码示例。如果您正苦于以下问题:C++ IsCf3VarString函数的具体用法?C++ IsCf3VarString怎么用?C++ IsCf3VarString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsCf3VarString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CompareRval
static int CompareRval(Rval rval1, Rval rval2)
{
if (rval1.type != rval2.type)
{
return -1;
}
switch (rval1.type)
{
case RVAL_TYPE_SCALAR:
if (IsCf3VarString((char *) rval1.item) || IsCf3VarString((char *) rval2.item))
{
return -1; // inconclusive
}
if (strcmp(rval1.item, rval2.item) != 0)
{
return false;
}
break;
case RVAL_TYPE_LIST:
return CompareRlist(rval1.item, rval2.item);
case RVAL_TYPE_FNCALL:
return -1;
default:
return -1;
}
return true;
}
示例2: UnresolvedVariables
bool UnresolvedVariables(const CfAssoc *ap, RvalType rtype)
{
if (ap == NULL)
{
return false;
}
switch (rtype)
{
case RVAL_TYPE_SCALAR:
return IsCf3VarString(ap->rval.item);
case RVAL_TYPE_LIST:
{
for (const Rlist *rp = ap->rval.item; rp != NULL; rp = rp->next)
{
if (IsCf3VarString(rp->item))
{
return true;
}
}
}
return false;
default:
return false;
}
}
示例3: UnresolvedVariables
int UnresolvedVariables(CfAssoc *ap, char rtype)
{
Rlist *list, *rp;
if (ap == NULL)
{
return false;
}
switch (rtype)
{
case CF_SCALAR:
return IsCf3VarString(ap->rval.item);
case CF_LIST:
list = (Rlist *) ap->rval.item;
for (rp = list; rp != NULL; rp = rp->next)
{
if (IsCf3VarString(rp->item))
{
return true;
}
}
return false;
default:
return false;
}
}
示例4: RlistEqual
bool RlistEqual(const Rlist *list1, const Rlist *list2)
{
const Rlist *rp1, *rp2;
for (rp1 = list1, rp2 = list2; rp1 != NULL && rp2 != NULL; rp1 = rp1->next, rp2 = rp2->next)
{
if (rp1->val.item != NULL &&
rp2->val.item != NULL)
{
if (rp1->val.type == RVAL_TYPE_FNCALL || rp2->val.type == RVAL_TYPE_FNCALL)
{
return false; // inconclusive
}
const Rlist *rc1 = rp1;
const Rlist *rc2 = rp2;
// Check for list nesting with { fncall(), "x" ... }
if (rp1->val.type == RVAL_TYPE_LIST)
{
rc1 = rp1->val.item;
}
if (rp2->val.type == RVAL_TYPE_LIST)
{
rc2 = rp2->val.item;
}
if (IsCf3VarString(rc1->val.item) || IsCf3VarString(rp2->val.item))
{
return false; // inconclusive
}
if (strcmp(rc1->val.item, rc2->val.item) != 0)
{
return false;
}
}
else if ((rp1->val.item != NULL && rp2->val.item == NULL) ||
(rp1->val.item == NULL && rp2->val.item != NULL))
{
return false;
}
else
{
assert(rp1->val.item == NULL && rp2->val.item == NULL);
}
}
return true;
}
示例5: CompareRlist
// FIX: this function is a mixture of Equal/Compare (boolean/diff).
// somebody is bound to misuse this at some point
static int CompareRlist(const Rlist *list1, const Rlist *list2)
{
const Rlist *rp1, *rp2;
for (rp1 = list1, rp2 = list2; rp1 != NULL && rp2 != NULL; rp1 = rp1->next, rp2 = rp2->next)
{
if (rp1->val.item && rp2->val.item)
{
const Rlist *rc1, *rc2;
if (rp1->val.type == RVAL_TYPE_FNCALL || rp2->val.type == RVAL_TYPE_FNCALL)
{
return -1; // inconclusive
}
rc1 = rp1;
rc2 = rp2;
// Check for list nesting with { fncall(), "x" ... }
if (rp1->val.type == RVAL_TYPE_LIST)
{
rc1 = rp1->val.item;
}
if (rp2->val.type == RVAL_TYPE_LIST)
{
rc2 = rp2->val.item;
}
if (IsCf3VarString(rc1->val.item) || IsCf3VarString(rp2->val.item))
{
return -1; // inconclusive
}
if (strcmp(rc1->val.item, rc2->val.item) != 0)
{
return false;
}
}
else
{
return false;
}
}
return true;
}
示例6: ExpandDanglers
Rval ExpandDanglers(EvalContext *ctx, const char *ns, const char *scope, Rval rval, const Promise *pp)
{
assert(ctx);
assert(pp);
switch (rval.type)
{
case RVAL_TYPE_SCALAR:
if (IsCf3VarString(RvalScalarValue(rval)))
{
return EvaluateFinalRval(ctx, PromiseGetPolicy(pp), ns, scope, rval, false, pp);
}
else
{
return RvalCopy(rval);
}
break;
case RVAL_TYPE_LIST:
{
Rlist *result_list = RlistCopy(RvalRlistValue(rval));
RlistFlatten(ctx, &result_list);
return RvalNew(result_list, RVAL_TYPE_LIST);
}
break;
case RVAL_TYPE_CONTAINER:
case RVAL_TYPE_FNCALL:
case RVAL_TYPE_NOPROMISEE:
return RvalCopy(rval);
}
ProgrammingError("Unhandled Rval type");
}
示例7: Epimenides
static bool Epimenides(EvalContext *ctx, const char *scope, const char *var, Rval rval, int level)
{
Rlist *rp, *list;
char exp[CF_EXPANDSIZE];
switch (rval.type)
{
case RVAL_TYPE_SCALAR:
if (StringContainsVar(rval.item, var))
{
CfOut(OUTPUT_LEVEL_ERROR, "", "Scalar variable \"%s\" contains itself (non-convergent): %s", var, (char *) rval.item);
return true;
}
if (IsCf3VarString(rval.item))
{
ExpandScalar(ctx, scope, rval.item, exp);
if (strcmp(exp, (const char *) rval.item) == 0)
{
return false;
}
CfDebug("bling %d-%s: (look for %s) in \"%s\" => %s \n", level, scope, var, (const char *) rval.item,
exp);
if (level > 3)
{
return false;
}
if (Epimenides(ctx, scope, var, (Rval) {exp, RVAL_TYPE_SCALAR}, level + 1))
{
return true;
}
}
break;
case RVAL_TYPE_LIST:
list = (Rlist *) rval.item;
for (rp = list; rp != NULL; rp = rp->next)
{
if (Epimenides(ctx, scope, var, (Rval) {rp->item, rp->type}, level))
{
return true;
}
}
break;
default:
return false;
}
return false;
}
示例8: Epimenides
static bool Epimenides(EvalContext *ctx, const char *ns, const char *scope, const char *var, Rval rval, int level)
{
switch (rval.type)
{
case RVAL_TYPE_SCALAR:
if (StringContainsVar(RvalScalarValue(rval), var))
{
Log(LOG_LEVEL_ERR, "Scalar variable '%s' contains itself (non-convergent) '%s'", var, RvalScalarValue(rval));
return true;
}
if (IsCf3VarString(RvalScalarValue(rval)))
{
Buffer *exp = BufferNew();
ExpandScalar(ctx, ns, scope, RvalScalarValue(rval), exp);
if (strcmp(BufferData(exp), RvalScalarValue(rval)) == 0)
{
BufferDestroy(exp);
return false;
}
if (level > 3)
{
BufferDestroy(exp);
return false;
}
if (Epimenides(ctx, ns, scope, var, (Rval) { BufferGet(exp), RVAL_TYPE_SCALAR}, level + 1))
{
BufferDestroy(exp);
return true;
}
BufferDestroy(exp);
}
break;
case RVAL_TYPE_LIST:
for (const Rlist *rp = RvalRlistValue(rval); rp != NULL; rp = rp->next)
{
if (Epimenides(ctx, ns, scope, var, rp->val, level))
{
return true;
}
}
break;
case RVAL_TYPE_CONTAINER:
case RVAL_TYPE_FNCALL:
case RVAL_TYPE_NOPROMISEE:
return false;
}
return false;
}
示例9: PolicyNew
static Policy *LoadPolicyInputFiles(EvalContext *ctx, GenericAgentConfig *config, const Rlist *inputs, StringSet *parsed_files_and_checksums, StringSet *failed_files)
{
Policy *policy = PolicyNew();
for (const Rlist *rp = inputs; rp; rp = rp->next)
{
if (rp->val.type != RVAL_TYPE_SCALAR)
{
Log(LOG_LEVEL_ERR, "Non-file object in inputs list");
continue;
}
const char *unresolved_input = RlistScalarValue(rp);
if (strcmp(CF_NULL_VALUE, unresolved_input) == 0)
{
continue;
}
if (IsExpandable(unresolved_input))
{
PolicyResolve(ctx, policy, config);
}
Rval resolved_input = EvaluateFinalRval(ctx, policy, NULL, "sys", rp->val, true, NULL);
Policy *aux_policy = NULL;
switch (resolved_input.type)
{
case RVAL_TYPE_SCALAR:
if (IsCf3VarString(RvalScalarValue(resolved_input)))
{
Log(LOG_LEVEL_ERR, "Unresolved variable '%s' in input list, cannot parse", RvalScalarValue(resolved_input));
break;
}
aux_policy = LoadPolicyFile(ctx, config, GenericAgentResolveInputPath(config, RvalScalarValue(resolved_input)), parsed_files_and_checksums, failed_files);
break;
case RVAL_TYPE_LIST:
aux_policy = LoadPolicyInputFiles(ctx, config, RvalRlistValue(resolved_input), parsed_files_and_checksums, failed_files);
break;
default:
ProgrammingError("Unknown type in input list for parsing: %d", resolved_input.type);
break;
}
if (aux_policy)
{
policy = PolicyMerge(policy, aux_policy);
}
RvalDestroy(resolved_input);
}
return policy;
}
示例10: CheckParseReal
static void CheckParseReal(char *lval, char *s, const char *range)
{
Item *split;
double max = (double) CF_LOWINIT, min = (double) CF_HIGHINIT, val;
int n;
char output[CF_BUFSIZE];
CfDebug("\nCheckParseReal(%s => %s/%s)\n", lval, s, range);
if (s == NULL)
{
return;
}
if (strcmp(s, "inf") == 0)
{
ReportError("keyword \"inf\" has an integer value, cannot be used as real");
return;
}
if (IsCf3VarString(s))
{
CfDebug("Validation: Unable to verify syntax of real %s due to variable expansion at this stage\n", s);
return;
}
/* Numeric types are registered by range separated by comma str "min,max" */
split = SplitString(range, ',');
if ((n = ListLen(split)) != 2)
{
FatalError("INTERN:format specifier for real rvalues is not ok for lval %s - %d items", lval, n);
}
sscanf(split->name, "%lf", &min);
sscanf(split->next->name, "%lf", &max);
DeleteItemList(split);
if (min == CF_HIGHINIT || max == CF_LOWINIT)
{
FatalError("INTERN:could not parse format specifier for int rvalues for lval %s", lval);
}
val = Str2Double(s);
if (val > max || val < min)
{
snprintf(output, CF_BUFSIZE,
"Real item on rhs of lval \'%s\' give as {%s => %.3lf} is out of bounds (should be in [%s])", lval, s,
val, range);
ReportError(output);
}
CfDebug("CheckParseReal - syntax verified\n\n");
}
示例11: CheckParseString
static int CheckParseString(char *lval, char *s, const char *range)
{
char output[CF_BUFSIZE];
CfDebug("\nCheckParseString(%s => %s/%s)\n", lval, s, range);
if (s == NULL)
{
return true;
}
if (strlen(range) == 0)
{
return true;
}
if (IsNakedVar(s, '@') || IsNakedVar(s, '$'))
{
CfDebug("Validation: Unable to verify variable expansion of %s at this stage\n", s);
return false;
}
/* Deal with complex strings as special cases */
if (strcmp(lval, "mode") == 0 || strcmp(lval, "search_mode") == 0)
{
mode_t plus, minus;
if (!ParseModeString(s, &plus, &minus))
{
snprintf(output, CF_BUFSIZE, "Error parsing Unix permission string %s)", s);
ReportError(output);
return false;
}
}
if (FullTextMatch(range, s))
{
return true;
}
if (IsCf3VarString(s))
{
CfDebug("Validation: Unable to verify syntax of %s due to variable expansion at this stage\n", s);
}
else
{
snprintf(output, CF_BUFSIZE,
"Scalar item in %s => { %s } in rvalue is out of bounds (value should match pattern %s)", lval, s,
range);
ReportError(output);
return false;
}
return true;
}
示例12: CheckParseInt
static SyntaxTypeMatch CheckParseInt(const char *lval, const char *s, const char *range)
{
Item *split;
int n;
long max = CF_LOWINIT, min = CF_HIGHINIT, val;
/* Numeric types are registered by range separated by comma str "min,max" */
CfDebug("\nCheckParseInt(%s => %s/%s)\n", lval, s, range);
split = SplitString(range, ',');
if ((n = ListLen(split)) != 2)
{
ProgrammingError("INTERN: format specifier for int rvalues is not ok for lval %s - got %d items", lval, n);
}
sscanf(split->name, "%ld", &min);
if (strcmp(split->next->name, "inf") == 0)
{
max = CF_INFINITY;
}
else
{
sscanf(split->next->name, "%ld", &max);
}
DeleteItemList(split);
if (min == CF_HIGHINIT || max == CF_LOWINIT)
{
ProgrammingError("INTERN: could not parse format specifier for int rvalues for lval %s", lval);
}
if (IsCf3VarString(s))
{
return SYNTAX_TYPE_MATCH_ERROR_UNEXPANDED;
}
val = IntFromString(s);
if (val == CF_NOINT)
{
return SYNTAX_TYPE_MATCH_ERROR_INT_PARSE;
}
if (val > max || val < min)
{
return SYNTAX_TYPE_MATCH_ERROR_INT_OUT_OF_RANGE;
}
CfDebug("CheckParseInt - syntax verified\n\n");
return SYNTAX_TYPE_MATCH_OK;
}
示例13: CheckParseString
static SyntaxTypeMatch CheckParseString(const char *lval, const char *s, const char *range)
{
if (s == NULL)
{
return SYNTAX_TYPE_MATCH_OK;
}
if (strlen(range) == 0)
{
return SYNTAX_TYPE_MATCH_OK;
}
if (IsNakedVar(s, '@') || IsNakedVar(s, '$'))
{
return SYNTAX_TYPE_MATCH_ERROR_UNEXPANDED;
}
/* Deal with complex strings as special cases */
if (strcmp(lval, "mode") == 0 || strcmp(lval, "search_mode") == 0)
{
mode_t plus, minus;
if (!ParseModeString(s, &plus, &minus))
{
return SYNTAX_TYPE_MATCH_ERROR_STRING_UNIX_PERMISSION;
}
}
/* FIXME: review this strcmp. Moved out from StringMatch */
if (!strcmp(range, s) || StringMatchFull(range, s))
{
return SYNTAX_TYPE_MATCH_OK;
}
if (IsCf3VarString(s))
{
return SYNTAX_TYPE_MATCH_ERROR_UNEXPANDED;
}
else if ('\0' == s[0])
{
return SYNTAX_TYPE_MATCH_ERROR_EMPTY_SCALAR_OUT_OF_RANGE;
}
else if (!strcmp(range, CF_ABSPATHRANGE))
{
return SYNTAX_TYPE_MATCH_ERROR_ABSOLUTE_PATH;
}
else
{
return SYNTAX_TYPE_MATCH_ERROR_SCALAR_OUT_OF_RANGE;
}
return SYNTAX_TYPE_MATCH_OK;
}
示例14: CompareRval
static int CompareRval(const void *rval1_item, RvalType rval1_type,
const void *rval2_item, RvalType rval2_type)
{
if (rval1_type != rval2_type)
{
return -1;
}
switch (rval1_type)
{
case RVAL_TYPE_SCALAR:
if (IsCf3VarString(rval1_item) || IsCf3VarString(rval2_item))
{
return -1; // inconclusive
}
if (strcmp(rval1_item, rval2_item) != 0)
{
return false;
}
break;
case RVAL_TYPE_LIST:
return CompareRlist(rval1_item, rval2_item);
case RVAL_TYPE_FNCALL:
return -1;
default:
return -1;
}
return true;
}
示例15: CheckParseReal
static SyntaxTypeMatch CheckParseReal(const char *lval, const char *s, const char *range)
{
Item *split;
double max = (double) CF_LOWINIT, min = (double) CF_HIGHINIT, val;
int n;
CfDebug("\nCheckParseReal(%s => %s/%s)\n", lval, s, range);
if (strcmp(s, "inf") == 0)
{
return SYNTAX_TYPE_MATCH_ERROR_REAL_INF;
}
if (IsCf3VarString(s))
{
return SYNTAX_TYPE_MATCH_ERROR_UNEXPANDED;
}
/* Numeric types are registered by range separated by comma str "min,max" */
split = SplitString(range, ',');
if ((n = ListLen(split)) != 2)
{
ProgrammingError("Format specifier for real rvalues is not ok for lval %s - %d items", lval, n);
}
sscanf(split->name, "%lf", &min);
sscanf(split->next->name, "%lf", &max);
DeleteItemList(split);
if (min == CF_HIGHINIT || max == CF_LOWINIT)
{
ProgrammingError("Could not parse format specifier for int rvalues for lval %s", lval);
}
if (!DoubleFromString(s, &val))
{
return SYNTAX_TYPE_MATCH_ERROR_REAL_OUT_OF_RANGE;
}
if (val > max || val < min)
{
return SYNTAX_TYPE_MATCH_ERROR_REAL_OUT_OF_RANGE;
}
return SYNTAX_TYPE_MATCH_OK;
}