2023-03-19 00:30:13 -04:00
|
|
|
#ifndef JOURNAL_H
|
|
|
|
#define JOURNAL_H
|
|
|
|
|
|
|
|
#include <stdint.h> /* uint32_t C99 */
|
2023-02-01 03:58:51 -05:00
|
|
|
/** Assumes: reverse ordering of byte-fields; unsigned is defined; C11 or GNU
|
2022-12-27 23:45:57 -05:00
|
|
|
anonymous unions. */
|
|
|
|
union date32 {
|
|
|
|
struct { uint32_t day : 5, month : 4, year : 23; }; /* C11, reverse */
|
|
|
|
uint32_t u32;
|
|
|
|
};
|
2022-12-29 02:54:59 -05:00
|
|
|
void date32_to_string(const union date32 d, char (*const a)[12]);
|
2023-02-01 03:58:51 -05:00
|
|
|
union line64 {
|
2023-02-04 22:06:43 -05:00
|
|
|
struct { uint32_t line; union date32 date; }; /* C11, little-endian */
|
2023-02-01 03:58:51 -05:00
|
|
|
uint64_t u64; /* C99 optional */
|
|
|
|
};
|
2022-12-27 23:45:57 -05:00
|
|
|
|
2023-03-19 00:30:13 -04:00
|
|
|
#define TREE_NAME day
|
|
|
|
#define TREE_KEY union date32
|
|
|
|
#define TREE_VALUE const char *
|
|
|
|
#define TREE_HEAD
|
|
|
|
#include "../src/tree.h"
|
2022-12-27 23:45:57 -05:00
|
|
|
|
2022-12-28 03:03:55 -05:00
|
|
|
#include "text.h"
|
2023-03-18 23:41:40 -04:00
|
|
|
struct journal { struct day_tree days; struct char_array backing; };
|
2022-12-29 02:54:59 -05:00
|
|
|
struct journal_iterator { struct day_tree_iterator _; };
|
2023-04-19 18:11:44 -04:00
|
|
|
struct journal journal(const char *);
|
2022-12-27 23:45:57 -05:00
|
|
|
void journal_(struct journal *);
|
2023-03-12 23:43:27 -04:00
|
|
|
int journal_is_empty(const struct journal *);
|
2022-12-27 23:45:57 -05:00
|
|
|
const char *journal_to_string(const struct journal *);
|
2023-02-12 00:21:29 -05:00
|
|
|
struct journal_iterator journal_iterator(struct journal *const j);
|
2023-02-02 01:23:35 -05:00
|
|
|
int journal_next(struct journal_iterator *, union date32 *, const char **);
|
|
|
|
|
2023-03-19 00:30:13 -04:00
|
|
|
#endif /* JOURNAL_H */
|