Skip to content

C API: Manifests

Pure functions; no ctx needed. A manifest is the 1000-byte AvatarDescription. sona_guid is 16 bytes in wire (big-endian) order.

sona_manifest is the parsed form: version (0), weight and height (raw, not clamped), chin, nose, ears, face[6] (mouth, eyes, eyebrows, facial hair, eye shadow, facial feature; each a GUID and four words), colours[9] (skin, hair, mouth, eyes, eyebrows, eye shadow, facial hair, facial feature, facial feature 2), figure_a (the body, and the gender source), figure_b (the head), worn[13] (all 13 slots; zero GUIDs are empty), required[4] (the last-worn cache: shoes, trousers, shirt, hair), blob5[5], xuid, padding[91], and the derived gender (1 male, 2 female, 0 unknown) and valid.

A sona_asset_ref holds id, mask (the u16 type mask after the GUID), pad (kept verbatim) and colours[3] (primary, secondary, tertiary, 0xAARRGGBB).

sona_route says where an item goes: SONA_ROUTE_REJECTED, WORN, BARE or FACE.

The edit verbs follow the editor's rules. Each changes *m in place, or returns SONA_E_ARGUMENT with m unchanged where the editor refuses. Edit flags: SONA_EDIT_NO_REQUIRED, SONA_EDIT_STACK_PROPS, SONA_EDIT_NO_DRESS.

sona_manifest_parse

sona_result sona_manifest_parse(const uint8_t bytes[SONA_MANIFEST_BYTES],
                                sona_manifest *out);
Parameter and type Meaning
bytes
const uint8_t [SONA_MANIFEST_BYTES]
The manifest's 1,000 bytes (required)
out
sona_manifest *
Receives the sona_manifest (required)

Returns SONA_OK. Errors SONA_E_ARGUMENT (what each means).

Example (also in Untrusted files, long sessions and speed):

sona_manifest m;
/* any 1,000 bytes from a player */
if (sona_manifest_parse(manifest, &m) != SONA_OK)
  puts("not an avatar");                            /* SONA_E_MANIFEST */
else
  /* its items load through your sources */
  sona_avatar_add(ctx, manifest, NULL, &avatar);

Reads 1000 bytes into a sona_manifest.

sona_manifest_write

sona_result sona_manifest_write(const sona_manifest *m,
                                uint8_t out[SONA_MANIFEST_BYTES]);
Parameter and type Meaning
m
const sona_manifest *
A sona_manifest (required)
out
uint8_t [SONA_MANIFEST_BYTES]
Receives the manifest's 1,000 bytes (required)

Returns SONA_OK. Errors SONA_E_ARGUMENT (what each means).

Example (also in Manifests):

sona_manifest m;
sona_guid tee;
/* 0xAARRGGBB */
const uint32_t colours[3] = { 0xff2a5caa, 0xffffffff, 0xffffffff };
if (sona_manifest_parse(manifest, &m) == SONA_OK &&
    sona_guid_parse("00000008-006e-0001-c1c8-f109a19cb2e0",
        &tee) == SONA_OK &&
    sona_manifest_wear(&m, &tee, colours, 0) == SONA_OK &&
    sona_manifest_write(&m, manifest) == SONA_OK)
  sona_avatar_add(ctx, manifest, NULL, &avatar);

Writes it back. Byte-exact: write(parse(x)) == x for every manifest.

sona_slot_of

sona_route sona_slot_of(const sona_guid *id, uint32_t *mask_out);
Parameter and type Meaning
id
const sona_guid *
An item id (required)
mask_out
uint32_t *
Receives the item's slot mask; may be NULL (NULL: not written)

Returns sona_route.

Where an item id goes, and its slot mask in *mask_out.

sona_guid_parse

sona_result sona_guid_parse(const char *text, sona_guid *out);
Parameter and type Meaning
text
const char *
An id as text (required)
out
sona_guid *
Receives the sona_guid (required)

Returns SONA_OK. Errors SONA_E_ARGUMENT (what each means).

Example (also in Manifests):

sona_manifest m;
sona_guid tee;
/* 0xAARRGGBB */
const uint32_t colours[3] = { 0xff2a5caa, 0xffffffff, 0xffffffff };
if (sona_manifest_parse(manifest, &m) == SONA_OK &&
    sona_guid_parse("00000008-006e-0001-c1c8-f109a19cb2e0",
        &tee) == SONA_OK &&
    sona_manifest_wear(&m, &tee, colours, 0) == SONA_OK &&
    sona_manifest_write(&m, manifest) == SONA_OK)
  sona_avatar_add(ctx, manifest, NULL, &avatar);

Parses the 36-character text form.

sona_guid_format

void sona_guid_format(const sona_guid *id, char out[SONA_ID_CHARS]);
Parameter and type Meaning
id
const sona_guid *
An item id (required)
out
char [SONA_ID_CHARS]
Receives the id as text with its NUL (required)

Returns Nothing.

Example:

sona_guid x_guid;
memset(&x_guid, 0, sizeof x_guid);
char x_out2[SONA_ID_CHARS];
memset(x_out2, 0, sizeof x_out2);
sona_guid_format(&x_guid, x_out2);

Writes the lowercase 36-character form and a NUL.

sona_base64_decode

sona_result sona_base64_decode(const char *text, uint8_t *out, size_t cap,
                               size_t *len);
Parameter and type Meaning
text
const char *
base64 text (required)
out
uint8_t *
Receives the bytes (required)
cap
size_t
How many bytes out holds
len
size_t *
Receives how many bytes were written (required)

Returns SONA_OK. Errors SONA_E_ARGUMENT (what each means).

Decodes base64 into at most cap bytes, and the length in *len.

sona_manifest_wear

sona_result sona_manifest_wear(sona_manifest *m, const sona_guid *item,
                               const uint32_t colours[3], uint32_t flags);
Parameter and type Meaning
m
sona_manifest *
Receives the sona_manifest (required)
item
const sona_guid *
A sona_guid (required)
colours
const uint32_t [3]
The item's three colours, 0xAARRGGBB; NULL: its own (NULL: its own)
flags
uint32_t
Option bits for the call; 0: none (0: none)

Returns SONA_OK. Errors SONA_E_ARGUMENT (what each means).

Example (also in Manifests):

sona_manifest m;
sona_guid tee;
/* 0xAARRGGBB */
const uint32_t colours[3] = { 0xff2a5caa, 0xffffffff, 0xffffffff };
if (sona_manifest_parse(manifest, &m) == SONA_OK &&
    sona_guid_parse("00000008-006e-0001-c1c8-f109a19cb2e0",
        &tee) == SONA_OK &&
    sona_manifest_wear(&m, &tee, colours, 0) == SONA_OK &&
    sona_manifest_write(&m, manifest) == SONA_OK)
  sona_avatar_add(ctx, manifest, NULL, &avatar);

Puts an item on, with its three colours.

sona_manifest_unwear

sona_result sona_manifest_unwear(sona_manifest *m, uint32_t slot_mask,
                                 uint32_t flags);
Parameter and type Meaning
m
sona_manifest *
Receives the sona_manifest (required)
slot_mask
uint32_t
The slots to take off
flags
uint32_t
Option bits for the call; 0: none (0: none)

Returns SONA_OK. Errors SONA_E_ARGUMENT (what each means).

Example:

sona_manifest x_manifest;
memset(&x_manifest, 0, sizeof x_manifest);
sona_result result = sona_manifest_unwear(&x_manifest, 0, 0);
if (result != SONA_OK) printf("sona_manifest_unwear: %s\n",
    sona_result_name(result));

Takes off what is in the slots of slot_mask.

sona_manifest_undress_all

sona_result sona_manifest_undress_all(sona_manifest *m);
Parameter and type Meaning
m
sona_manifest *
Receives the sona_manifest (required)

Returns SONA_OK. Errors SONA_E_ARGUMENT (what each means).

Example:

sona_manifest x_manifest;
memset(&x_manifest, 0, sizeof x_manifest);
sona_result result = sona_manifest_undress_all(&x_manifest);
if (result != SONA_OK) printf("sona_manifest_undress_all: %s\n",
    sona_result_name(result));

Takes everything off.

sona_manifest_set_colour

sona_result sona_manifest_set_colour(sona_manifest *m, uint32_t colour_slot,
                                     uint32_t argb);
Parameter and type Meaning
m
sona_manifest *
Receives the sona_manifest (required)
colour_slot
uint32_t
Which of the manifest's colours to set
argb
uint32_t
The colour, 0xAARRGGBB

Returns SONA_OK. Errors SONA_E_ARGUMENT (what each means).

Example:

sona_manifest x_manifest;
memset(&x_manifest, 0, sizeof x_manifest);
sona_result result = sona_manifest_set_colour(&x_manifest, 0, 0);
if (result != SONA_OK) printf("sona_manifest_set_colour: %s\n",
    sona_result_name(result));

Sets one of the nine body colours, by its index in colours.

sona_manifest_set_gender

sona_result sona_manifest_set_gender(sona_manifest *m, uint32_t gender,
                                     uint32_t flags);
Parameter and type Meaning
m
sona_manifest *
Receives the sona_manifest (required)
gender
uint32_t
1 male, 2 female
flags
uint32_t
Option bits for the call; 0: none (0: none)

Returns SONA_OK. Errors SONA_E_ARGUMENT (what each means).

Example:

sona_manifest x_manifest;
memset(&x_manifest, 0, sizeof x_manifest);
sona_result result = sona_manifest_set_gender(&x_manifest, 0, 0);
if (result != SONA_OK) printf("sona_manifest_set_gender: %s\n",
    sona_result_name(result));

Sets the gender: 1 male, 2 female.

sona_manifest_set_shape

sona_result sona_manifest_set_shape(sona_manifest *m, float weight,
                                    float height);
Parameter and type Meaning
m
sona_manifest *
Receives the sona_manifest (required)
weight
float
The body's weight, as the manifest stores it
height
float
The body's height, as the manifest stores it

Returns SONA_OK. Errors SONA_E_ARGUMENT (what each means).

Example:

sona_manifest x_manifest;
memset(&x_manifest, 0, sizeof x_manifest);
sona_result result = sona_manifest_set_shape(&x_manifest, 0.5f, 16);
if (result != SONA_OK) printf("sona_manifest_set_shape: %s\n",
    sona_result_name(result));

Sets the weight and height.

sona_manifest_ready_for_xbox

int sona_manifest_ready_for_xbox(const sona_manifest *m);
Parameter and type Meaning
m
const sona_manifest *
A sona_manifest (required)

Returns int.

Example:

sona_manifest x_manifest;
memset(&x_manifest, 0, sizeof x_manifest);
int x_got = sona_manifest_ready_for_xbox(&x_manifest);
printf("sona_manifest_ready_for_xbox: %lld\n", (long long)x_got);

1 when the body (and so the gender) is known and the editor's Xbox clean-up would change nothing: the manifest can be saved to Xbox as it is. 0 otherwise.

This page as Markdown · All the docs as one file (llms-full.txt)