Loading...
Searching...
No Matches
long_text.h
Go to the documentation of this file.
1
18#pragma once
19#include <stdbool.h>
20#include <stddef.h>
21#include <stdint.h>
22
27
29#define LONG_TEXT_CAP_MAX 1024
30
38typedef void (*LongTextReceiver)(const char *text);
39
47typedef void (*LongTextProvider)(char *out, size_t size);
48
54typedef struct
55{
56 uint32_t key;
57 uint16_t cap;
60} LongText;
61
79bool long_text_set(LongText *slot, uint32_t key, uint16_t cap, LongTextProvider provider,
80 LongTextReceiver receiver, bool opened);
81
96bool long_text_fits(uint32_t text_bytes, uint32_t reply_bytes, uint32_t outbox_max, uint32_t inbox_room);
97
104void long_text_held(const LongText *slot, char *out);
105
117bool long_text_arrived(const LongText *slot, const char *text);
118
bool long_text_set(LongText *slot, uint32_t key, uint16_t cap, LongTextProvider provider, LongTextReceiver receiver, bool opened)
Sets up the face's long text setting, replacing one set before.
Definition long_text.c:13
void(*) LongTextReceiver(const char *text)
Called with a long text setting the phone sent, for the face to store.
Definition long_text.h:38
bool long_text_fits(uint32_t text_bytes, uint32_t reply_bytes, uint32_t outbox_max, uint32_t inbox_room)
Whether the text at its cap fits both buffers: the outbox beside the rest of the settings reply,...
Definition long_text.c:44
void(*) LongTextProvider(char *out, size_t size)
Called to write the long text setting the face holds, for the settings reply and to tell a save that ...
Definition long_text.h:47
bool long_text_arrived(const LongText *slot, const char *text)
Hands a text that arrived to the receiver when it differs from the one the face holds.
Definition long_text.c:58
void long_text_held(const LongText *slot, char *out)
Writes the text the face holds, as its provider writes it, ended inside the cap.
Definition long_text.c:49
The face's long text setting: its key, its cap, and the provider and receiver.
Definition long_text.h:55
LongTextReceiver receiver
Stores a text that arrived.
Definition long_text.h:59
uint16_t cap
The most bytes the text takes, its end included. 0 means no setting.
Definition long_text.h:57
uint32_t key
The MESSAGE_KEY_* value the text rides on.
Definition long_text.h:56
LongTextProvider provider
Writes the text the face holds.
Definition long_text.h:58