PebbleOS
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions
Timeline attributes

Typed key/value attributes describing timeline items and actions. More...

Data Structures

struct  Uint32List
 Variable-length list of 32-bit values. More...
 
struct  Attribute
 Attribute: an id and a value whose type depends on the id. More...
 
struct  AttributeList
 List of attributes. More...
 
union  Attribute.__unnamed79__
 Value; the member matching the type of Attribute::id is valid. More...
 

Macros

#define ATTRIBUTE_ICON_LARGE_SIZE_PX   80
 Size of large icons, in pixels.
 
#define ATTRIBUTE_ICON_SMALL_SIZE_PX   50
 Size of small icons, in pixels.
 
#define ATTRIBUTE_ICON_TINY_SIZE_PX   25
 Size of tiny icons, in pixels.
 
#define ATTRIBUTE_TITLE_MAX_LEN   64
 Maximum length of a title, in bytes.
 
#define ATTRIBUTE_SUBTITLE_MAX_LEN   64
 Maximum length of a subtitle, in bytes.
 
#define ATTRIBUTE_APP_GLANCE_SUBTITLE_MAX_LEN   (150)
 Maximum length of an app glance subtitle template string, in bytes.
 
#define Uint32ListSize(num_values)   (sizeof(Uint32List) + (num_values) * sizeof(uint32_t))
 Size in bytes of a Uint32List holding a number of values.
 

Enumerations

enum  AttributeId {
  AttributeIdUnused = 0 , AttributeIdTitle = 1 , AttributeIdSubtitle = 2 , AttributeIdBody = 3 ,
  AttributeIdIconTiny = 4 , AttributeIdIconSmall = 5 , AttributeIdIconLarge = 6 , AttributeIdAncsAction = 7 ,
  AttributeIdCannedResponses = 8 , AttributeIdShortTitle = 9 , AttributeIdIconPin = 10 , AttributeIdLocationName = 11 ,
  AttributeIdSender = 12 , AttributeIdLaunchCode = 13 , AttributeIdLastUpdated = 14 , AttributeIdRankAway = 15 ,
  AttributeIdRankHome = 16 , AttributeIdNameAway = 17 , AttributeIdNameHome = 18 , AttributeIdRecordAway = 19 ,
  AttributeIdRecordHome = 20 , AttributeIdScoreAway = 21 , AttributeIdScoreHome = 22 , AttributeIdSportsGameState = 23 ,
  AttributeIdBroadcaster = 24 , AttributeIdHeadings = 25 , AttributeIdParagraphs = 26 , AttributeIdPrimaryColor = 27 ,
  AttributeIdBgColor = 28 , AttributeIdSecondaryColor = 29 , AttributeIdAppName = 30 , AttributeIdDisplayRecurring = 31 ,
  AttributeIdiOSAppIdentifier = 32 , AttributeIdEmojiSupported = 33 , AttributeIdAncsId = 34 , AttributeIdHealthInsightType = 35 ,
  AttributeIdShortSubtitle = 36 , AttributeIdTimestamp = 37 , AttributeIdDisplayTime = 38 , AttributeIdAddress = 39 ,
  AttributeIdMuteDayOfWeek = 40 , AttributeIdMetricNames = 41 , AttributeIdMetricValues = 42 , AttributeIdMetricIcons = 43 ,
  AttributeIdHealthActivityType = 44 , AttributeIdAlarmKind = 45 , AttributeIdAuthCode = 46 , AttributeIdSubtitleTemplateString = 47 ,
  AttributeIdIcon = 48 , AttributeIdVibrationPattern = 49 , AttributeIdMuteExpiration = 50 , AttributeIdNotificationFilteringRules = 51 ,
  AttributeIdImageAspectRatio = 52 , AttributeIdWeatherPinKind = 53 , NumAttributeIds
}
 Attribute identifiers, as used on the wire. More...
 

Functions

void attribute_init_string (Attribute *attribute, char *buffer, AttributeId attribute_id)
 Initialize a string attribute.
 
bool attribute_copy (Attribute *dest, const Attribute *src, uint8_t **buffer, uint8_t *const buffer_end)
 Deep copy an attribute, placing its string or list data in a buffer.
 
bool attribute_list_copy (AttributeList *out, const AttributeList *in, uint8_t *buffer, uint8_t *const buffer_end)
 Deep copy an attribute list into one contiguous buffer.
 
size_t attribute_list_get_buffer_size (const AttributeList *list)
 Get the size of a buffer holding a deep copy of an attribute list.
 
size_t attribute_list_get_string_buffer_size (const AttributeList *list)
 Get the size of the string and list data of an attribute list.
 
void attribute_list_add_cstring (AttributeList *list, AttributeId id, const char *cstring)
 Add a string attribute, or replace the value of an existing one.
 
void attribute_list_add_uint32 (AttributeList *list, AttributeId id, uint32_t uint32)
 Add a uint32 attribute, or replace the value of an existing one.
 
void attribute_list_add_resource_id (AttributeList *list, AttributeId id, uint32_t resource_id)
 Add a resource id attribute, or replace the value of an existing one.
 
void attribute_list_add_uint8 (AttributeList *list, AttributeId id, uint8_t uint8)
 Add a uint8 attribute, or replace the value of an existing one.
 
void attribute_list_add_string_list (AttributeList *list, AttributeId id, struct pbl_string_list *string_list)
 Add a string list attribute, or replace the value of an existing one.
 
void attribute_list_add_uint32_list (AttributeList *list, AttributeId id, Uint32List *uint32_list)
 Add a Uint32List attribute, or replace the value of an existing one.
 
void attribute_list_add_attribute (AttributeList *list, const Attribute *new_attribute)
 Add an attribute, or replace an existing one with the same id.
 
void attribute_list_init_list (uint8_t num_attributes, AttributeList *list_out)
 Allocate a zeroed attribute list on the kernel heap.
 
void attribute_list_destroy_list (AttributeList *list)
 Free the attributes array of a list.
 
Attribute * attribute_find (const AttributeList *attr_list, AttributeId id)
 Find an attribute by id.
 
const char * attribute_get_string (const AttributeList *attr_list, AttributeId id, char *default_value)
 Get a string attribute.
 
struct pbl_string_list * attribute_get_string_list (const AttributeList *attr_list, AttributeId id)
 Get a string list attribute.
 
uint8_t attribute_get_uint8 (const AttributeList *attr_list, AttributeId id, uint8_t default_value)
 Get a uint8 attribute.
 
uint32_t attribute_get_uint32 (const AttributeList *attr_list, AttributeId id, uint32_t default_value)
 Get a uint32 or resource id attribute.
 
Uint32List * attribute_get_uint32_list (const AttributeList *attr_list, AttributeId id)
 Get a Uint32List attribute.
 
size_t attribute_list_serialize (const AttributeList *attr_list, uint8_t *buffer, uint8_t *buf_end)
 Serialize an attribute list.
 
size_t attribute_list_get_serialized_size (const AttributeList *attr_list)
 Get the serialized size of an attribute list.
 
bool attribute_check_serialized_list (const uint8_t *cursor, const uint8_t *val_end, uint8_t num_attributes, bool has_attribute[])
 Check that a serialized attribute list is well formed and record which ids it contains.
 
int32_t attribute_get_buffer_size_for_serialized_attributes (uint8_t num_attributes, const uint8_t **cursor, const uint8_t *end)
 Get the size of the buffer needed to deserialize attributes.
 
bool attribute_deserialize_list (char **buffer, char *const buf_end, const uint8_t **cursor, const uint8_t *payload_end, AttributeList *attr_list)
 Deserialize attributes into an attribute list.
 

Detailed Description

Typed key/value attributes describing timeline items and actions.

Each AttributeId has a fixed value type: a string, an 8- or 32-bit integer, a resource id, a string list or a Uint32List. The type is noted on each id; the matching Attribute member holds the value.

On the wire (BlobDB, Pebble Protocol) an attribute is a SerializedAttributeHeader followed by length bytes of value: strings without terminator, integers little endian, string lists as their serialized bytes and Uint32Lists as the struct. When deserializing, the title and subtitle are truncated to 64 bytes, the body and string lists to 512 bytes and the subtitle template string to 150 bytes. Attributes with an id this firmware does not know are skipped.

Building a list on the stack and reading it back:

AttributeList list = {0};
attribute_list_add_resource_id(&list, AttributeIdIconPin, TIMELINE_RESOURCE_TIMELINE_CALENDAR);
attribute_list_add_uint8(&list, AttributeIdBgColor, GColorOrangeARGB8);
for (int i = 0; i < list.num_attributes; i++) {
const Attribute *attr = &list.attributes[i];
switch (attr->id) {
PBL_LOG_DBG("%d: %s", attr->id, attr->cstring);
break;
PBL_LOG_DBG("icon: %" PRIu32, attr->uint32);
break;
default:
break;
}
}
const char *location = attribute_get_string(&list, AttributeIdLocationName, "");
#define PBL_LOG_DBG(fmt,...)
Log a routine debug message, possibly queued.
Definition logging.h:570
AttributeId id
Attribute id.
Definition attribute.h:209
Attribute * attributes
Attributes.
Definition attribute.h:238
uint8_t num_attributes
Number of attributes.
Definition attribute.h:236
Attribute: an id and a value whose type depends on the id.
Definition attribute.h:207
List of attributes.
Definition attribute.h:234
void attribute_list_add_uint8(AttributeList *list, AttributeId id, uint8_t uint8)
Add a uint8 attribute, or replace the value of an existing one.
void attribute_list_add_cstring(AttributeList *list, AttributeId id, const char *cstring)
Add a string attribute, or replace the value of an existing one.
const char * attribute_get_string(const AttributeList *attr_list, AttributeId id, char *default_value)
Get a string attribute.
void attribute_list_add_resource_id(AttributeList *list, AttributeId id, uint32_t resource_id)
Add a resource id attribute, or replace the value of an existing one.
void attribute_list_destroy_list(AttributeList *list)
Free the attributes array of a list.
@ AttributeIdTitle
(string) Title shown in a detailed view, at most 64 bytes.
Definition attribute.h:82
@ AttributeIdBgColor
(uint8) Background color of the source, as GColor8 ARGB.
Definition attribute.h:136
@ AttributeIdLocationName
(string) Name of the location, in a broad sense, of the item.
Definition attribute.h:102
@ AttributeIdIconPin
(resource id) Icon shown for the pin in the timeline.
Definition attribute.h:100

Data Structure Documentation

◆ Uint32List

struct Uint32List

Variable-length list of 32-bit values.

Data Fields
uint16_t num_values Number of values.
uint32_t values[] Values.

◆ Attribute

struct Attribute

Attribute: an id and a value whose type depends on the id.

Data Fields
union Attribute.__unnamed79__ __unnamed__ Value; the member matching the type of Attribute::id is valid.
AttributeId id Attribute id.

◆ AttributeList

struct AttributeList

List of attributes.

Data Fields
Attribute * attributes Attributes.
uint8_t num_attributes Number of attributes.

◆ Attribute.__unnamed79__

union Attribute.__unnamed79__

Value; the member matching the type of Attribute::id is valid.

Data Fields
char * cstring String value.
int16_t int16 Signed 16-bit value; no attribute currently uses it.
int32_t int32 Signed 32-bit value; no attribute currently uses it.
int8_t int8 Signed 8-bit value; no attribute currently uses it.
struct pbl_string_list * string_list String list value.
uint16_t uint16 16-bit value; no attribute currently uses it.
uint32_t uint32 32-bit or resource id value.
Uint32List * uint32_list Uint32List value.
uint8_t uint8 8-bit value.

Macro Definition Documentation

◆ ATTRIBUTE_APP_GLANCE_SUBTITLE_MAX_LEN

#define ATTRIBUTE_APP_GLANCE_SUBTITLE_MAX_LEN   (150)

Maximum length of an app glance subtitle template string, in bytes.

◆ ATTRIBUTE_ICON_LARGE_SIZE_PX

#define ATTRIBUTE_ICON_LARGE_SIZE_PX   80

Size of large icons, in pixels.

◆ ATTRIBUTE_ICON_SMALL_SIZE_PX

#define ATTRIBUTE_ICON_SMALL_SIZE_PX   50

Size of small icons, in pixels.

◆ ATTRIBUTE_ICON_TINY_SIZE_PX

#define ATTRIBUTE_ICON_TINY_SIZE_PX   25

Size of tiny icons, in pixels.

◆ ATTRIBUTE_SUBTITLE_MAX_LEN

#define ATTRIBUTE_SUBTITLE_MAX_LEN   64

Maximum length of a subtitle, in bytes.

◆ ATTRIBUTE_TITLE_MAX_LEN

#define ATTRIBUTE_TITLE_MAX_LEN   64

Maximum length of a title, in bytes.

◆ Uint32ListSize

#define Uint32ListSize (   num_values)    (sizeof(Uint32List) + (num_values) * sizeof(uint32_t))

Size in bytes of a Uint32List holding a number of values.

Parameters
num_valuesNumber of values.

Enumeration Type Documentation

◆ AttributeId

Attribute identifiers, as used on the wire.

Enumerator
AttributeIdUnused 

Unused id; never matched by lookups.

AttributeIdTitle 

(string) Title shown in a detailed view, at most 64 bytes.

AttributeIdSubtitle 

(string) Auxiliary text shown under the title, at most 64 bytes.

AttributeIdBody 

(string) Body text of the view, at most 512 bytes.

AttributeIdIconTiny 

(resource id) Tiny icon, shown in the status bar or banner.

AttributeIdIconSmall 

(resource id) Small icon, shown in the rendered view.

AttributeIdIconLarge 

(resource id) Large icon, shown when actions are triggered.

AttributeIdAncsAction 

(uint8) ANCS action id persisted in the actions of ANCS notifications.

AttributeIdCannedResponses 

(string list) Canned responses offered by a reply action.

AttributeIdShortTitle 

(string) Title shown in a list view.

AttributeIdIconPin 

(resource id) Icon shown for the pin in the timeline.

AttributeIdLocationName 

(string) Name of the location, in a broad sense, of the item.

AttributeIdSender 

(string) Sender of a message, organizer of an event, etc.

AttributeIdLaunchCode 

(uint32) Launch code passed to the app by an open watch app action.

AttributeIdLastUpdated 

(uint32) Unix time the item was last updated, e.g.

for weather.

AttributeIdRankAway 

(string) Rank of the away team in the league.

AttributeIdRankHome 

(string) Rank of the home team in the league.

AttributeIdNameAway 

(string) Abbreviated name of the away team, at most 4 characters.

AttributeIdNameHome 

(string) Abbreviated name of the home team, at most 4 characters.

AttributeIdRecordAway 

(string) Record (wins and losses) of the away team.

AttributeIdRecordHome 

(string) Record (wins and losses) of the home team.

AttributeIdScoreAway 

(string) Current score of the away team, in game only.

AttributeIdScoreHome 

(string) Current score of the home team, in game only.

AttributeIdSportsGameState 

(uint8) GameState of a sports pin, selecting the pre-game or in-game view.

AttributeIdBroadcaster 

(string) TV channel, radio station, website, etc.

broadcasting the event.

AttributeIdHeadings 

(string list) Section headings of a generic pin, paired with the paragraphs.

AttributeIdParagraphs 

(string list) Section paragraphs of a generic pin, paired with the headings.

AttributeIdPrimaryColor 

(uint8) Primary color of the source, as GColor8 ARGB.

AttributeIdBgColor 

(uint8) Background color of the source, as GColor8 ARGB.

AttributeIdSecondaryColor 

(uint8) Secondary color of the source, as GColor8 ARGB.

AttributeIdAppName 

(string) Display name of the app the notification originates from.

AttributeIdDisplayRecurring 

(uint8) CalendarRecurringType of a calendar event.

AttributeIdiOSAppIdentifier 

(string) iOS app identifier, e.g.

com.apple.MobileSMS.

AttributeIdEmojiSupported 

(uint8) Whether a reply action offers emoji; emoji are offered when absent.

AttributeIdAncsId 

(uint32) ANCS UID of the item or action, when the parent id links to another item.

AttributeIdHealthInsightType 

(uint8) Health insight the item comes from.

AttributeIdShortSubtitle 

(string) Subtitle shown in a list view.

AttributeIdTimestamp 

(uint32) ANCS timestamp of the notification, seconds since the epoch.

AttributeIdDisplayTime 

(uint8) WeatherTimeType: which time, if any, a weather pin shows.

AttributeIdAddress 

(string) Phone number, email address or other handle of a contact.

AttributeIdMuteDayOfWeek 

(uint8) MuteBitfield of the days on which an app's notifications are muted.

AttributeIdMetricNames 

(string list) Metric names of a pin.

AttributeIdMetricValues 

(string list) Metric values of a pin.

AttributeIdMetricIcons 

(Uint32List) Metric icons, as TimelineResourceId.

AttributeIdHealthActivityType 

(uint8) Health activity the item comes from.

AttributeIdAlarmKind 

(uint8) AlarmKind of an alarm pin.

AttributeIdAuthCode 

(string) Authentication code, e.g.

the Nexmo SMS check-in code.

AttributeIdSubtitleTemplateString 

(string) Template string shown under a title (app glances), at most 150 bytes.

AttributeIdIcon 

(resource id) Generic icon.

AttributeIdVibrationPattern 

(Uint32List) Custom vibration pattern, as passed to vibes_enqueue_custom_pattern().

AttributeIdMuteExpiration 

(uint32) Unix time at which an app's mute expires.

AttributeIdNotificationFilteringRules 

(string list) Notification filtering rules of an app, as bytes: a rule count, then for each rule its match type, match field and case sensitivity bytes and a NUL-terminated pattern.

AttributeIdImageAspectRatio 

(uint8) The phone holds an image for this item, fetchable over the imaging endpoint keyed by the item's UUID.

The value is the image's height/width in sixteenths, so the card can reserve a band of the right shape before the pixels arrive. Absent or 0 means no image.

AttributeIdWeatherPinKind 

(uint8) WeatherPinKind of a weather pin.

NumAttributeIds 

Number of attribute ids.

Function Documentation

◆ attribute_check_serialized_list()

bool attribute_check_serialized_list ( const uint8_t *  cursor,
const uint8_t *  val_end,
uint8_t  num_attributes,
bool  has_attribute[] 
)

Check that a serialized attribute list is well formed and record which ids it contains.

Parameters
cursorStart of the serialized attributes.
val_endEnd of the data.
num_attributesNumber of serialized attributes.
[out]has_attributeArray of NumAttributeIds flags, indexed by id; set for each known id found.
Returns
true if well formed.

◆ attribute_copy()

bool attribute_copy ( Attribute *  dest,
const Attribute *  src,
uint8_t **  buffer,
uint8_t *const  buffer_end 
)

Deep copy an attribute, placing its string or list data in a buffer.

Parameters
[out]destDestination attribute.
srcSource attribute.
[in,out]bufferPointer to free memory for the data; advanced past what was used.
buffer_endEnd of the buffer.
Returns
true on success, false if the buffer is too small.

◆ attribute_deserialize_list()

bool attribute_deserialize_list ( char **  buffer,
char *const  buf_end,
const uint8_t **  cursor,
const uint8_t *  payload_end,
AttributeList *  attr_list 
)

Deserialize attributes into an attribute list.

Attributes with an id this firmware does not know are skipped, and attr_list->num_attributes is updated to the number actually stored.

Parameters
[in,out]bufferBuffer for string and list data; advanced past what was used.
buf_endEnd of the buffer.
[in,out]cursorStart of the serialized attributes; advanced past them.
payload_endEnd of the serialized data.
[in,out]attr_listList with num_attributes set to the serialized count and room for that many attributes.
Returns
true on success, false if the data is malformed.

◆ attribute_find()

Attribute * attribute_find ( const AttributeList *  attr_list,
AttributeId  id 
)

Find an attribute by id.

Parameters
attr_listAttribute list, may be NULL.
idAttribute id.
Returns
Attribute, or NULL if not found or id is AttributeIdUnused.

◆ attribute_get_buffer_size_for_serialized_attributes()

int32_t attribute_get_buffer_size_for_serialized_attributes ( uint8_t  num_attributes,
const uint8_t **  cursor,
const uint8_t *  end 
)

Get the size of the buffer needed to deserialize attributes.

Parameters
num_attributesNumber of serialized attributes.
[in,out]cursorStart of the serialized attributes; advanced past them.
endEnd of the data.
Returns
Size in bytes of the string and list data, or a negative value if the data is malformed.

◆ attribute_get_string()

const char * attribute_get_string ( const AttributeList *  attr_list,
AttributeId  id,
char *  default_value 
)

Get a string attribute.

Asserts if id is not a string attribute.

Parameters
attr_listAttribute list.
idAttribute id.
default_valueValue returned when not found.
Returns
String, or default_value if not found.

◆ attribute_get_string_list()

struct pbl_string_list * attribute_get_string_list ( const AttributeList *  attr_list,
AttributeId  id 
)

Get a string list attribute.

Parameters
attr_listAttribute list.
idAttribute id.
Returns
String list, or NULL if not found.

◆ attribute_get_uint32()

uint32_t attribute_get_uint32 ( const AttributeList *  attr_list,
AttributeId  id,
uint32_t  default_value 
)

Get a uint32 or resource id attribute.

Parameters
attr_listAttribute list.
idAttribute id.
default_valueValue returned when not found.
Returns
Value, or default_value if not found.

◆ attribute_get_uint32_list()

Uint32List * attribute_get_uint32_list ( const AttributeList *  attr_list,
AttributeId  id 
)

Get a Uint32List attribute.

Asserts if id is not a Uint32List attribute.

Parameters
attr_listAttribute list.
idAttribute id.
Returns
List, or NULL if not found.

◆ attribute_get_uint8()

uint8_t attribute_get_uint8 ( const AttributeList *  attr_list,
AttributeId  id,
uint8_t  default_value 
)

Get a uint8 attribute.

Parameters
attr_listAttribute list.
idAttribute id.
default_valueValue returned when not found.
Returns
Value, or default_value if not found.

◆ attribute_init_string()

void attribute_init_string ( Attribute *  attribute,
char *  buffer,
AttributeId  attribute_id 
)

Initialize a string attribute.

Parameters
[out]attributeAttribute to initialize.
bufferString the attribute points to; not copied.
attribute_idAttribute id.

◆ attribute_list_add_attribute()

void attribute_list_add_attribute ( AttributeList *  list,
const Attribute *  new_attribute 
)

Add an attribute, or replace an existing one with the same id.

The attribute is copied shallowly.

Parameters
listAttribute list.
new_attributeAttribute to add.

◆ attribute_list_add_cstring()

void attribute_list_add_cstring ( AttributeList *  list,
AttributeId  id,
const char *  cstring 
)

Add a string attribute, or replace the value of an existing one.

The list grows on the kernel heap. The string is not copied, so it must stay valid until the list is copied or added to a timeline item.

Parameters
listAttribute list.
idString attribute id, e.g. Title, Subtitle or Body.
cstringString value.

◆ attribute_list_add_resource_id()

void attribute_list_add_resource_id ( AttributeList *  list,
AttributeId  id,
uint32_t  resource_id 
)

Add a resource id attribute, or replace the value of an existing one.

Parameters
listAttribute list.
idIcon attribute id.
resource_idTimeline resource id.

◆ attribute_list_add_string_list()

void attribute_list_add_string_list ( AttributeList *  list,
AttributeId  id,
struct pbl_string_list *  string_list 
)

Add a string list attribute, or replace the value of an existing one.

The list is not copied, so it must stay valid until the attribute list is copied or added to a timeline item. Asserts if id is not a string list attribute.

Parameters
listAttribute list.
idString list attribute id, e.g. Headings or Paragraphs.
string_listValue.

◆ attribute_list_add_uint32()

void attribute_list_add_uint32 ( AttributeList *  list,
AttributeId  id,
uint32_t  uint32 
)

Add a uint32 attribute, or replace the value of an existing one.

Parameters
listAttribute list.
iduint32 attribute id.
uint32Value.

◆ attribute_list_add_uint32_list()

void attribute_list_add_uint32_list ( AttributeList *  list,
AttributeId  id,
Uint32List *  uint32_list 
)

Add a Uint32List attribute, or replace the value of an existing one.

The list is not copied, so it must stay valid until the attribute list is copied or added to a timeline item. Asserts if id is not a Uint32List attribute.

Parameters
listAttribute list.
idUint32List attribute id, e.g. MetricIcons.
uint32_listValue.

◆ attribute_list_add_uint8()

void attribute_list_add_uint8 ( AttributeList *  list,
AttributeId  id,
uint8_t  uint8 
)

Add a uint8 attribute, or replace the value of an existing one.

Parameters
listAttribute list.
iduint8 attribute id.
uint8Value.

◆ attribute_list_copy()

bool attribute_list_copy ( AttributeList *  out,
const AttributeList *  in,
uint8_t *  buffer,
uint8_t *const  buffer_end 
)

Deep copy an attribute list into one contiguous buffer.

Parameters
[out]outDestination list; its attributes and data live in buffer.
inSource list.
bufferBuffer of at least attribute_list_get_buffer_size() of in bytes.
buffer_endEnd of the buffer.
Returns
true on success, false if the buffer is too small.

◆ attribute_list_destroy_list()

void attribute_list_destroy_list ( AttributeList *  list)

Free the attributes array of a list.

Only for lists built with attribute_list_add_ or attribute_list_init_list(), not for copies made with attribute_list_copy(). Values are not freed.

Parameters
listAttribute list.

◆ attribute_list_get_buffer_size()

size_t attribute_list_get_buffer_size ( const AttributeList *  list)

Get the size of a buffer holding a deep copy of an attribute list.

Parameters
listAttribute list.
Returns
Size in bytes of the attributes and their data.

◆ attribute_list_get_serialized_size()

size_t attribute_list_get_serialized_size ( const AttributeList *  attr_list)

Get the serialized size of an attribute list.

Parameters
attr_listAttribute list, may be NULL.
Returns
Size in bytes.

◆ attribute_list_get_string_buffer_size()

size_t attribute_list_get_string_buffer_size ( const AttributeList *  list)

Get the size of the string and list data of an attribute list.

Parameters
listAttribute list.
Returns
Size in bytes, including string terminators.

◆ attribute_list_init_list()

void attribute_list_init_list ( uint8_t  num_attributes,
AttributeList *  list_out 
)

Allocate a zeroed attribute list on the kernel heap.

The attributes start as AttributeIdUnused; fill them in place. The attribute_list_add_ functions append after them.

Parameters
num_attributesNumber of attributes.
[out]list_outList to initialize.

◆ attribute_list_serialize()

size_t attribute_list_serialize ( const AttributeList *  attr_list,
uint8_t *  buffer,
uint8_t *  buf_end 
)

Serialize an attribute list.

Parameters
attr_listAttribute list.
[out]bufferOutput buffer of at least attribute_list_get_serialized_size() bytes.
buf_endEnd of the buffer.
Returns
Number of bytes written.