C API

Decisions

Compose a decision from checked query-presence bits.

Compose a decision from already checked query results. A failed query is not false: handle its error before passing presence bits to this helper.

Enum: decision_t

C · enumSince v0.10.0
decision_t

#include <maelys/datalog.h>

Composed outcome of the explicit allow, reduce and deny presence bits.
Members
DECISION_DENY0
Deny was present without allow or reduce.
DECISION_ALLOW1
Allow was present without reduce or deny.
DECISION_REDUCED2
Reduce was present without deny, whether or not allow was present.
DECISION_DENY_DEFAULT3
No allow, reduce or deny was present.
DECISION_DENY_CONFLICT4
Deny was present together with allow or reduce.
Typedef
typedef enum {
    MAELYS_DATALOG_DECISION_DENY = 0,
    MAELYS_DATALOG_DECISION_ALLOW = 1,
    MAELYS_DATALOG_DECISION_REDUCED = 2,
    MAELYS_DATALOG_DECISION_DENY_DEFAULT = 3,
    MAELYS_DATALOG_DECISION_DENY_CONFLICT = 4
} maelys_datalog_decision_t;

Functions

decision_from_presence()

C · functionSince v0.10.0
decision_from_presence()

#include <maelys/datalog.h>

maelys_datalog_status_t
maelys_datalog_decision_from_presence(
int allow,
int reduce,
int deny,
maelys_datalog_decision_t *out_decision
);
Combines already known query-presence bits into a decision. It does not run a query or evaluate a policy. Deny takes precedence, then reduce, then allow; deny combined with allow or reduce is a conflict, and no presence yields the default deny.
Arguments
allowintin
Presence of allow after a successful query; valid values: 0, 1.
reduceintin
Presence of reduce after a successful query; valid values: 0, 1.
denyintin
Presence of deny after a successful query; valid values: 0, 1.
Outputs

Written on success.

out_decisionmaelys_datalog_decision_t *out
Receives the composed outcome.
Return status

maelys_datalog_status_t — OK on success.

OK when every presence bit is zero or one and the output pointer is valid; INVALID_ARGUMENT otherwise.

Example
maelys_datalog_decision_t decision;
maelys_datalog_status_t status = maelys_datalog_decision_from_presence(1, 0, 0, &decision);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("decision is allow: %s\n", decision == MAELYS_DATALOG_DECISION_ALLOW ? "yes" : "no");
status: ok
decision is allow: yes

Usage guides