2022-12-27 23:45:57 -05:00
|
|
|
#ifndef OMIT_BASE /* <!-- base */
|
2022-12-29 02:54:59 -05:00
|
|
|
#include <stddef.h>
|
|
|
|
union load { const char *text; size_t offset; };
|
2022-12-27 23:45:57 -05:00
|
|
|
#include <stdint.h> /* C99 */
|
|
|
|
/** Assumes: reverse ordering of byte-fields; unsigned is defined; C11 and GNU
|
|
|
|
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]);
|
2022-12-27 23:45:57 -05:00
|
|
|
#else /* base --><!-- !base */
|
|
|
|
#undef OMIT_BASE
|
|
|
|
#endif /* !base --> */
|
2022-12-27 02:31:08 -05:00
|
|
|
|
2022-12-27 23:45:57 -05:00
|
|
|
|
|
|
|
#ifndef OMIT_DAY /* <!-- page */
|
|
|
|
struct tree_day_node;
|
|
|
|
struct tree_day_tree { struct tree_day_node *node; unsigned height; };
|
|
|
|
struct day_tree { struct tree_day_tree root; };
|
2022-12-29 02:54:59 -05:00
|
|
|
struct tree_day_ref { struct tree_day_node *node; unsigned height, idx; };
|
|
|
|
struct tree_day_iterator {
|
|
|
|
struct tree_day_tree *root; struct tree_day_ref ref; int seen;
|
|
|
|
};
|
|
|
|
struct day_tree_iterator { struct tree_day_iterator _; };
|
2022-12-27 23:45:57 -05:00
|
|
|
#else /* page --><!-- !page */
|
|
|
|
#undef OMIT_DAY
|
|
|
|
#endif /* !page --> */
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef OMIT_PROTO /* <!-- proto */
|
2022-12-28 03:03:55 -05:00
|
|
|
#include "text.h"
|
|
|
|
struct journal { struct day_tree days; struct text backing; };
|
2022-12-29 02:54:59 -05:00
|
|
|
struct journal_iterator { struct day_tree_iterator _; };
|
2022-12-27 23:45:57 -05:00
|
|
|
struct journal journal(void);
|
|
|
|
void journal_(struct journal *);
|
|
|
|
int journal_is_valid(const struct journal *);
|
|
|
|
const char *journal_to_string(const struct journal *);
|
2022-12-29 02:54:59 -05:00
|
|
|
struct journal_iterator journal_begin(struct journal *const j);
|
|
|
|
struct journal_iterator journal_begin_at(struct journal *, const union date32);
|
|
|
|
union load;
|
|
|
|
int journal_next(struct journal_iterator *, union date32 *, union load **);
|
2022-12-27 23:45:57 -05:00
|
|
|
#else /* proto --><!-- !proto */
|
|
|
|
#undef OMIT_PROTO
|
|
|
|
#endif /* !proto --> */
|