==> include/mesh/state_file.h <==1/* @ajax/mesh-state-file: meshd's --state file (mesh-host loader.rs Saved,
2 * read_state, write_state): one line per loaded program, in slot order:
3 * `name dir 0|1` (its catalog dir under --programs, and whether it runs).
4 * Written whole and renamed into place, so a crash leaves the old file. */
5#ifndef MESH_STATE_FILE_H
6#define MESH_STATE_FILE_H
7
8#include <stdbool.h>
9#include <stddef.h>
10
11typedef struct {
12 char *name;
13 char *dir;
14 bool running;
15} mesh_saved;
16
17/* A missing file is an empty set. False with *err, e.g.
18 * "--state /x line 1: expected `name dir 0|1`, got \"hello ../x 1\"". */
19bool mesh_state_read(const char *path, mesh_saved **set, size_t *n, char **err);
20bool mesh_state_write(const char *path, const mesh_saved *set, size_t n, char **err);
21void mesh_state_free(mesh_saved *set, size_t n);
22
23#endif