gobj_write_strn_attr()

gobj_write_strn_attr()#

Writes a string attribute to a hgobj object, ensuring the string is properly truncated to the specified length.

Prototype

int gobj_write_strn_attr(
    hgobj gobj,   /* Target object */
    const char *name, /* Attribute name */
    const char *value, /* String value */
    size_t len /* Maximum length */
);

Parameters

Key

Type

Description

gobj

hgobj

The target object where the attribute will be written.

name

const char *

The name of the attribute to be written.

value

const char *

The string value to be written to the attribute.

len

size_t

The maximum length of the string to be written.


Return Value

Returns 0 on success, or -1 if the attribute is not found or an error occurs.

Notes

If value is longer than len, it is truncated before being written. If value is NULL, the attribute is set to json_null().

Prototype

// Not applicable in JS

Prototype

# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples