C API: Content filters¶
Which items a game allows, by section, slot, source, game, tag or id, with presets and JSON rules: Content filters.
sona_filter_create¶
sona_result sona_filter_create(sona_ctx *ctx, const sona_catalogue *cat,
sona_filter **out);
| Parameter and type | Meaning |
|---|---|
ctxsona_ctx * |
The context (NULL allowed (below)) |
catconst sona_catalogue * |
The catalogue (required) |
outsona_filter ** |
Receives the new filter (required) |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_NOT_FOUND, SONA_E_LIMIT, SONA_E_MEMORY (what each means).
ctx may be NULL (malloc; errors only as codes); with one, its allocator and sona_last_error. cat may be NULL: then only id, slot, section (from the id) and source rules can match. The filter may outlive both.
sona_filter_free¶
void sona_filter_free(sona_filter *f);
| Parameter and type | Meaning |
|---|---|
fsona_filter * |
The filter (required) |
Returns Nothing.
Frees the filter.
sona_filter_reset¶
sona_result sona_filter_reset(sona_filter *f);
| Parameter and type | Meaning |
|---|---|
fsona_filter * |
The filter (required) |
Returns SONA_OK. Errors SONA_E_ARGUMENT (what each means).
Every rule goes; tags stay.
sona_filter_sections¶
sona_result sona_filter_sections(sona_filter *f, uint32_t mode,
uint32_t sections);
| Parameter and type | Meaning |
|---|---|
fsona_filter * |
The filter (required) |
modeuint32_t |
SONA_CONTENT_ALLOW or SONA_CONTENT_DENY |
sectionsuint32_t |
SONA_SECTION_* bits |
Returns SONA_OK. Errors SONA_E_ARGUMENT (what each means).
Adds a rule on sections: bits (1u << sona_section). mode is SONA_CONTENT_ALLOW or _DENY; each call adds to the rules.
sona_filter_slots¶
sona_result sona_filter_slots(sona_filter *f, uint32_t mode,
uint32_t slots);
| Parameter and type | Meaning |
|---|---|
fsona_filter * |
The filter (required) |
modeuint32_t |
SONA_CONTENT_ALLOW or SONA_CONTENT_DENY |
slotsuint32_t |
Slot mask bits |
Returns SONA_OK. Errors SONA_E_ARGUMENT (what each means).
Adds a rule on slots (AssetMask bits): an item matches when it covers any of them. mode is SONA_CONTENT_ALLOW or _DENY.
sona_filter_sources¶
sona_result sona_filter_sources(sona_filter *f, uint32_t mode,
uint32_t sources);
| Parameter and type | Meaning |
|---|---|
fsona_filter * |
The filter (required) |
modeuint32_t |
SONA_CONTENT_ALLOW or SONA_CONTENT_DENY |
sourcesuint32_t |
SONA_ITEM_* source bits |
Returns SONA_OK. Errors SONA_E_ARGUMENT (what each means).
Example (also in Content filters):
sona_filter_game(f, SONA_CONTENT_ALLOW, "Racer X");
sona_filter_sources(f, SONA_CONTENT_ALLOW, SONA_CONTENT_STOCK);
Adds a rule on where items come from (SONA_CONTENT_STOCK and the other source bits). mode is SONA_CONTENT_ALLOW or _DENY.
sona_filter_game¶
sona_result sona_filter_game(sona_filter *f, uint32_t mode,
const char *game);
| Parameter and type | Meaning |
|---|---|
fsona_filter * |
The filter (required) |
modeuint32_t |
SONA_CONTENT_ALLOW or SONA_CONTENT_DENY |
gameconst char * |
A game's name, as the catalogue spells it (required) |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_NOT_FOUND (what each means).
Example (also in Content filters):
sona_filter_game(f, SONA_CONTENT_ALLOW, "Racer X");
sona_filter_sources(f, SONA_CONTENT_ALLOW, SONA_CONTENT_STOCK);
A game as sona_catalogue_game names it (ASCII case folded). SONA_E_NOT_FOUND when no item has that game.
sona_filter_tag¶
sona_result sona_filter_tag(sona_filter *f, uint32_t mode, const char *tag);
| Parameter and type | Meaning |
|---|---|
fsona_filter * |
The filter (required) |
modeuint32_t |
SONA_CONTENT_ALLOW or SONA_CONTENT_DENY |
tagconst char * |
A tag's name (required) |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_NOT_FOUND (what each means).
A tag by name ("weapon", "logo", or one the host defined). SONA_E_NOT_FOUND for an unknown name.
sona_filter_item¶
sona_result sona_filter_item(sona_filter *f, uint32_t mode,
const sona_guid *id);
| Parameter and type | Meaning |
|---|---|
fsona_filter * |
The filter (required) |
modeuint32_t |
SONA_CONTENT_ALLOW or SONA_CONTENT_DENY |
idconst sona_guid * |
An item id (required) |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_MEMORY (what each means).
Adds a rule on one item by id. mode is SONA_CONTENT_ALLOW or _DENY.
sona_filter_preset¶
sona_result sona_filter_preset(sona_filter *f, uint32_t preset);
| Parameter and type | Meaning |
|---|---|
fsona_filter * |
The filter (required) |
presetuint32_t |
Which preset, one of the header's constants for it |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_MEMORY (what each means).
Adds a preset's rules (SONA_FILTER_PRESET_*, listed in Content filters).
sona_filter_load¶
sona_result sona_filter_load(sona_filter *f, const char *json, size_t len,
char *why, size_t why_cap);
| Parameter and type | Meaning |
|---|---|
fsona_filter * |
The filter (required) |
jsonconst char * |
Filter rules as JSON text (required) |
lensize_t |
How many bytes there are |
whychar * |
Receives what was refused, NUL-terminated; may be NULL (NULL: not written) |
why_capsize_t |
How many bytes why holds |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_LIMIT, SONA_E_MEMORY (what each means).
Rules from JSON (Content filters): {"preset": [...], "allow": {...}, "deny": {...}, "tags": {...}, "untag": {...}}. All or nothing: on an error the filter is unchanged and why (may be NULL) says what was wrong.
sona_filter_tag_count¶
uint32_t sona_filter_tag_count(const sona_filter *f);
| Parameter and type | Meaning |
|---|---|
fconst sona_filter * |
The filter (required) |
Returns uint32_t.
How many tags the filter knows, built-in and host-defined.
sona_filter_tag_name¶
const char * sona_filter_tag_name(const sona_filter *f, uint32_t tag);
| Parameter and type | Meaning |
|---|---|
fconst sona_filter * |
The filter (required) |
taguint32_t |
A tag's bit |
Returns const char *.
NULL past the last.
sona_filter_tag_find¶
int32_t sona_filter_tag_find(const sona_filter *f, const char *name);
| Parameter and type | Meaning |
|---|---|
fconst sona_filter * |
The filter (required) |
nameconst char * |
The name to look up (required) |
Returns int32_t.
-1 when unknown.
sona_filter_tag_define¶
sona_result sona_filter_tag_define(sona_filter *f, const char *name,
uint32_t *out_tag);
| Parameter and type | Meaning |
|---|---|
fsona_filter * |
The filter (required) |
nameconst char * |
The new tag's name (required) |
out_taguint32_t * |
Receives the new tag's bit (required) |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_LIMIT (what each means).
A new tag (a name of 1 to 31 bytes of a-z, 0-9 and '-'), or the index of the one of that name. SONA_E_LIMIT past 64 tags.
sona_filter_tag_set¶
sona_result sona_filter_tag_set(sona_filter *f, const sona_guid *id,
uint32_t tag, int on);
| Parameter and type | Meaning |
|---|---|
fsona_filter * |
The filter (required) |
idconst sona_guid * |
An item id (required) |
taguint32_t |
A tag's bit |
onint |
1 on, 0 off |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_MEMORY (what each means).
Puts a tag on an item (on 1) or takes it off (0), for ids in the catalogue or not.
sona_filter_item_tags¶
uint64_t sona_filter_item_tags(const sona_filter *f, const sona_guid *id);
| Parameter and type | Meaning |
|---|---|
fconst sona_filter * |
The filter (required) |
idconst sona_guid * |
An item id (required) |
Returns uint64_t.
The bits of an item's tags (bit n is tag n).
sona_filter_tag_items¶
uint32_t sona_filter_tag_items(const sona_filter *f, uint32_t tag);
| Parameter and type | Meaning |
|---|---|
fconst sona_filter * |
The filter (required) |
taguint32_t |
A tag's bit |
Returns uint32_t.
How many catalogue items carry a tag.
sona_filter_allows¶
int sona_filter_allows(const sona_filter *f, const sona_guid *id);
| Parameter and type | Meaning |
|---|---|
fconst sona_filter * |
The filter (required) |
idconst sona_guid * |
An item id (required) |
Returns int.
1 when the item is allowed; a NULL filter allows everything.
sona_filter_check¶
sona_result sona_filter_check(const sona_filter *f, const sona_guid *id,
sona_filter_verdict *out);
| Parameter and type | Meaning |
|---|---|
fconst sona_filter * |
The filter (required) |
idconst sona_guid * |
An item id (required) |
outsona_filter_verdict * |
Receives the sona_filter_verdict (required) |
Returns SONA_OK. Errors SONA_E_ARGUMENT (what each means).
Whether the item is allowed, and if not, which rule denied it (SONA_CONTENT_BY_*) and the item's tags.
sona_filter_search¶
sona_result sona_filter_search(const sona_filter *f,
const sona_catalogue *cat,
const sona_catalogue_query *q,
uint32_t *out_indexes, uint32_t max,
uint32_t *total);
| Parameter and type | Meaning |
|---|---|
fconst sona_filter * |
The filter (required) |
catconst sona_catalogue * |
The catalogue (required) |
qconst sona_catalogue_query * |
A sona_catalogue_query (required) |
out_indexesuint32_t * |
Receives catalogue indexes, up to max (required) |
maxuint32_t |
How many entries out holds |
totaluint32_t * |
Receives how many there are in all; may be NULL (NULL: not written) |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_NOT_FOUND, SONA_E_MEMORY (what each means).
sona_catalogue_search over cat, allowed items only (offset and total count allowed ones). Any catalogue works; items are matched by id.
sona_filter_allowed_count¶
uint32_t sona_filter_allowed_count(const sona_filter *f);
| Parameter and type | Meaning |
|---|---|
fconst sona_filter * |
The filter (required) |
Returns uint32_t.
Catalogue items allowed.
sona_filter_manifest¶
sona_result sona_filter_manifest(const sona_filter *f, sona_manifest *m,
sona_filter_report *report);
| Parameter and type | Meaning |
|---|---|
fconst sona_filter * |
The filter (required) |
msona_manifest * |
Receives the sona_manifest (required) |
reportsona_filter_report * |
Receives what the call did; may be NULL (NULL allowed (below)) |
Returns SONA_OK. Errors SONA_E_ARGUMENT (what each means).
Takes every denied item off a manifest: worn items go back to the body's defaults, props are hidden. report (may be NULL) lists what changed.
sona_filter_manifest_bytes¶
sona_result sona_filter_manifest_bytes(
const sona_filter *f, uint8_t manifest[SONA_MANIFEST_BYTES],
sona_filter_report *report);
| Parameter and type | Meaning |
|---|---|
fconst sona_filter * |
The filter (required) |
manifestuint8_t [SONA_MANIFEST_BYTES] |
The manifest's 1,000 bytes, changed in place (required) |
reportsona_filter_report * |
Receives what the call did; may be NULL (NULL: not written) |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_MANIFEST (what each means).
The same on the 1000 bytes, in place; unchanged bytes when nothing is denied. SONA_E_MANIFEST for bad bytes.
sona_ctx_set_filter¶
sona_result sona_ctx_set_filter(sona_ctx *ctx, const sona_filter *f);
| Parameter and type | Meaning |
|---|---|
ctxsona_ctx * |
The context (required) |
fconst sona_filter * |
The filter (required) |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_NOT_FOUND, SONA_E_MEMORY (what each means).
The ctx's filter: a copy of f (NULL takes it away), applied to an avatar when its manifest is read, whoever's it is (sona_avatar_add, headless renders); an avatar read before the change keeps what it wore until it is removed and added again. A preview of a denied item fails with SONA_E_NOT_FOUND. Pickers read it back with sona_ctx_filter: NULL when none; owned by the ctx and gone at the next sona_ctx_set_filter or sona_close.
sona_ctx_filter¶
const sona_filter * sona_ctx_filter(const sona_ctx *ctx);
| Parameter and type | Meaning |
|---|---|
ctxconst sona_ctx * |
The context (required) |
Returns const sona_filter *.
Example:
const sona_filter * x_got = sona_ctx_filter(ctx);
printf("sona_ctx_filter: %s\n", x_got ? "a value" : "none");
The ctx's filter as sona_ctx_set_filter left it: NULL when none; owned by the ctx and gone at the next sona_ctx_set_filter or sona_close.
sona_avatar_filter_report¶
sona_result sona_avatar_filter_report(const sona_avatar *a,
sona_filter_report *out);
| Parameter and type | Meaning |
|---|---|
aconst sona_avatar * |
The avatar (required) |
outsona_filter_report * |
Receives the sona_filter_report (required) |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_NOT_READY, SONA_E_NOT_FOUND (what each means).
Example:
sona_filter_report x_filter_report;
memset(&x_filter_report, 0, sizeof x_filter_report);
x_filter_report.size = sizeof x_filter_report;
sona_result result = sona_avatar_filter_report(avatar, &x_filter_report);
if (result != SONA_OK) printf("sona_avatar_filter_report: %s\n",
sona_result_name(result));
What the ctx's filter changed on this avatar. SONA_E_NOT_READY before its manifest is read, SONA_E_NOT_FOUND when no filter was set then.
This page as Markdown · All the docs as one file (llms-full.txt)