47#define KST_STORE_DIR CARD_KST_CONF
52#define KST_STORE_EXT ".TXT"
57#define KST_STORE_BASE_MAX 32
62#define KST_STORE_NAME_MAX (KST_STORE_BASE_MAX + 4 + 1)
67#define KST_STORE_FIRST 1
68#define KST_STORE_LAST 999
73#define KST_STORE_PRESET_MAX 7
84#define KST_STORE_RECORD "KST"
92 KST_STORE_NAME_OK = 0,
119 KST_STORE_CARD_FULL = 7,
120 KST_STORE_WRITE_ERROR = 8,
123 KST_STORE_READ_ERROR = 11,
177 int32_t (*
read)(
void *
ctx,
const char *name,
char *buf,
size_t cap);
184 const char *data,
size_t len);
248 const char *text,
size_t len,
277 size_t *count,
size_t *total,
size_t *skipped);
302 size_t *count,
size_t *total,
319 char *buf,
size_t cap,
size_t *len);
The folders of the panel's SD (Secure Digital) card, and the files in them with a fixed name.
void(*) kst_store_visit_fn(const char *name, bool is_dir, void *visit_ctx)
Receives one directory entry. name does not outlive the call.
Definition kst_store.h:146
kst_store_t kst_store_load(const kst_store_io_t *io, const char *name, char *buf, size_t cap, size_t *len)
Read the file name, a name as kst_store_list() gives it, into buf. len receives the number of bytes.
Definition kst_store.c:465
kst_store_t kst_store_save(const kst_store_io_t *io, const char *base, const char *text, size_t len, kst_store_name_t *why)
Write len bytes of text as the file of base.
Definition kst_store.c:293
kst_store_t kst_store_preset(const kst_store_io_t *io, char *base, size_t base_size)
Propose a base name: "KST" and 3 digits, one above the highest number the directory holds.
Definition kst_store.c:231
kst_store_t kst_store_list(const kst_store_io_t *io, kst_store_entry_t *entries, size_t cap, size_t *count, size_t *total, size_t *skipped)
List the files with KST_STORE_EXT.
Definition kst_store.c:430
kst_store_io_result_t
What the create function reports.
Definition kst_store.h:132
@ KST_STORE_IO_EXISTS
Definition kst_store.h:134
@ KST_STORE_IO_ERROR
Definition kst_store.h:136
@ KST_STORE_IO_FULL
Definition kst_store.h:135
@ KST_STORE_IO_DENIED
Definition kst_store.h:137
kst_store_name_t kst_store_name_check(const char *base)
Whether base is a base name this layer writes.
Definition kst_store.c:151
kst_store_t
The result of a call.
Definition kst_store.h:111
@ KST_STORE_BAD_NAME
Definition kst_store.h:117
@ KST_STORE_NO_CARD
Definition kst_store.h:114
@ KST_STORE_TOO_LARGE
Definition kst_store.h:122
@ KST_STORE_EXISTS
Definition kst_store.h:118
@ KST_STORE_NOT_FOUND
Definition kst_store.h:121
@ KST_STORE_NO_NUMBER
Definition kst_store.h:116
@ KST_STORE_LIST_ERROR
Definition kst_store.h:115
@ KST_STORE_ARG
Definition kst_store.h:113
@ KST_STORE_DENIED
Definition kst_store.h:124
kst_store_name_t
Whether a base name is taken.
Definition kst_store.h:91
@ KST_STORE_NAME_RESERVED
Definition kst_store.h:97
@ KST_STORE_NAME_TOO_LONG
Definition kst_store.h:94
@ KST_STORE_NAME_BAD_CHAR
Definition kst_store.h:95
@ KST_STORE_NAME_EMPTY
Definition kst_store.h:93
@ KST_STORE_NAME_EDGE
Definition kst_store.h:102
bool kst_store_file_name(const char *base, char *out, size_t out_size)
The file name of base: the base name and KST_STORE_EXT.
Definition kst_store.c:156
kst_store_t kst_store_list_after(const kst_store_io_t *io, const char *after, kst_store_entry_t *entries, size_t cap, size_t *count, size_t *total, size_t *skipped)
kst_store_list() from the file behind after on: entries receives the first cap files the order has be...
Definition kst_store.c:438
#define KST_STORE_NAME_MAX
Room for a file name: base name, extension and terminator.
Definition kst_store.h:62
One row of a list.
Definition kst_store.h:190
char name[KST_STORE_NAME_MAX]
Definition kst_store.h:191
The card.
Definition kst_store.h:154
int32_t(*) read(void *ctx, const char *name, char *buf, size_t cap)
Up to cap bytes from the start of the file.
Definition kst_store.h:177
kst_store_io_result_t(*) create(void *ctx, const char *name, const char *data, size_t len)
Create the directory when it is missing, create the file and fail when the name exists,...
Definition kst_store.h:183
bool(*) walk(void *ctx, kst_store_visit_fn visit, void *visit_ctx)
Call visit for every entry of the directory, files and directories, once each.
Definition kst_store.h:167
bool(*) mounted(void *ctx)
Whether a card is mounted.
Definition kst_store.h:159
void * ctx
Definition kst_store.h:155
int32_t(*) size(void *ctx, const char *name)
Size of a file in bytes; -1 when no file has that name.
Definition kst_store.h:171