interpret/src/journal.h

53 lines
1.7 KiB
C

#if defined BASE \
|| !defined BASE && !defined GENERIC && !defined PROTO /* <!-- base */
#include <stddef.h>
#include <stdint.h> /* C99 */
/** Assumes: reverse ordering of byte-fields; unsigned is defined; C11 or GNU
anonymous unions. */
union date32 {
struct { uint32_t day : 5, month : 4, year : 23; }; /* C11, reverse */
uint32_t u32;
};
void date32_to_string(const union date32 d, char (*const a)[12]);
union line64 {
struct { uint32_t line; union date32 date; }; /* C11, little-endian */
uint64_t u64; /* C99 optional */
};
#endif /* base --> */
#if defined GENERIC \
|| !defined BASE && !defined GENERIC && !defined PROTO /* <!-- generic */
struct tree_day_node;
struct tree_day_tree { struct tree_day_node *node; unsigned height; };
struct day_tree { struct tree_day_tree root; };
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; };
struct day_tree_iterator { struct tree_day_iterator _; };
#endif /* generic --> */
#if defined PROTO \
|| !defined BASE && !defined GENERIC && !defined PROTO /* <!-- proto */
#include "text.h"
struct journal { struct day_tree days; struct text backing; };
struct journal_iterator { struct day_tree_iterator _; };
struct journal journal(void);
void journal_(struct journal *);
//int journal_is_valid(const struct journal *);
const char *journal_to_string(const struct journal *);
struct journal_iterator journal_iterator(struct journal *const j);
int journal_next(struct journal_iterator *, union date32 *, const char **);
#endif /* proto --> */
#ifdef BASE
#undef BASE
#endif
#ifdef GENERIC
#undef GENERIC
#endif
#ifdef PROTO
#undef PROTO
#endif