cfengine  3.15.4
About: CFEngine is a configuration management system for configuring and maintaining Unix-like computers (using an own high level policy language). Community version.
  Fossies Dox: cfengine-3.15.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

promises.c File Reference
#include <promises.h>
#include <policy.h>
#include <syntax.h>
#include <expand.h>
#include <files_names.h>
#include <scope.h>
#include <vars.h>
#include <locks.h>
#include <misc_lib.h>
#include <fncall.h>
#include <eval_context.h>
#include <string_lib.h>
#include <audit.h>
Include dependency graph for promises.c:

Go to the source code of this file.

Functions

static void AddDefaultBodiesToPromise (EvalContext *ctx, Promise *promise, const PromiseTypeSyntax *syntax)
 
void CopyBodyConstraintsToPromise (EvalContext *ctx, Promise *pp, const Body *bp)
 
static JsonElementGetBodyRewriter (const EvalContext *ctx, const Body *current_body, const Rval *called_rval, bool in_inheritance_chain)
 
static void AppendExpandedBodies (EvalContext *ctx, Promise *pcopy, const Seq *bodies_and_args, bool flatten_slists, bool expand_body_vars)
 
PromiseDeRefCopyPromise (EvalContext *ctx, const Promise *pp)
 
static bool EvaluateConstraintIteration (EvalContext *ctx, const Constraint *cp, Rval *rval_out)
 
static ExpressionValue CheckVarClassExpression (const EvalContext *ctx, const Constraint *cp, Promise *pcopy)
 Helper function to determine whether the Rval of ifvarclass/if/unless is defined. If the Rval is a function, call that function. More...
 
static void DereferenceAndPutComment (Promise *pp, const char *comment)
 
PromiseExpandDeRefPromise (EvalContext *ctx, const Promise *pp, bool *excluded)
 
void PromiseRef (LogLevel level, const Promise *pp)
 
const char * PromiseID (const Promise *pp)
 

Function Documentation

◆ AddDefaultBodiesToPromise()

◆ AppendExpandedBodies()

static void AppendExpandedBodies ( EvalContext ctx,
Promise pcopy,
const Seq bodies_and_args,
bool  flatten_slists,
bool  expand_body_vars 
)
static

Appends expanded bodies to the promise #pcopy. It expands the bodies based on arguments, inheritance, and it can optionally flatten the '@' slists and expand the variables in the body according to the EvalContext.

Definition at line 123 of file promises.c.

References Constraint_::classes, Body_::conlist, ExpandPrivateRval(), free(), GetBodyRewriter(), IsDefinedClass(), Rval::item, JsonDestroy(), Log(), LOG_LEVEL_DEBUG, Constraint_::lval, NULL, Constraint_::offset, PromiseAppendConstraint(), RlistFlatten(), Constraint_::rval, RVAL_TYPE_LIST, RvalCopyRewriter(), RvalDestroy(), RvalToString(), SeqAt(), SeqLength(), and Rval::type.

Referenced by DeRefCopyPromise().

◆ CheckVarClassExpression()

static ExpressionValue CheckVarClassExpression ( const EvalContext ctx,
const Constraint cp,
Promise pcopy 
)
static

Helper function to determine whether the Rval of ifvarclass/if/unless is defined. If the Rval is a function, call that function.

Definition at line 494 of file promises.c.

References CheckClassExpression(), EvaluateConstraintIteration(), EXPRESSION_VALUE_ERROR, Log(), LOG_LEVEL_DEBUG, Constraint_::lval, NULL, PromiseAppendConstraint(), RVAL_TYPE_FNCALL, RVAL_TYPE_SCALAR, and RvalScalarValue().

Referenced by ExpandDeRefPromise().

◆ CopyBodyConstraintsToPromise()

◆ DeRefCopyPromise()

◆ DereferenceAndPutComment()

static void DereferenceAndPutComment ( Promise pp,
const char *  comment 
)
static

Definition at line 543 of file promises.c.

References Promise_::comment, free(), NULL, Promise_::promiser, strstr(), xasprintf(), and xstrdup().

Referenced by ExpandDeRefPromise().

◆ EvaluateConstraintIteration()

◆ ExpandDeRefPromise()

◆ GetBodyRewriter()

static JsonElement* GetBodyRewriter ( const EvalContext ctx,
const Body current_body,
const Rval called_rval,
bool  in_inheritance_chain 
)
static

Get a map that rewrites body according to parameters.

@NOTE make sure you free the returned map with JsonDestroy().

Definition at line 63 of file promises.c.

References FnCall_::args, Body_::args, FatalError(), JsonObjectAppendString(), JsonObjectCreate(), Body_::name, Rlist_::next, Body_::ns, NULL, RlistLen(), RlistScalarValue(), RVAL_TYPE_FNCALL, RVAL_TYPE_SCALAR, RvalFnCallValue(), and Rval::type.

Referenced by AppendExpandedBodies().

◆ PromiseID()

◆ PromiseRef()

void PromiseRef ( LogLevel  level,
const Promise pp 
)