50 lines
1.7 KiB
C
50 lines
1.7 KiB
C
#ifndef OMIT_BASE /* <!-- base */
|
|
#include <stddef.h>
|
|
union load { const char *text; size_t offset; };
|
|
#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 { union date32 date; uint32_t line; }; /* C11, endian? */
|
|
uint64_t u64; /* C99 optional */
|
|
};
|
|
#else /* base --><!-- !base */
|
|
#undef OMIT_BASE
|
|
#endif /* !base --> */
|
|
|
|
|
|
#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; };
|
|
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 _; };
|
|
#else /* page --><!-- !page */
|
|
#undef OMIT_DAY
|
|
#endif /* !page --> */
|
|
|
|
|
|
#ifndef OMIT_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_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 **);
|
|
#else /* proto --><!-- !proto */
|
|
#undef OMIT_PROTO
|
|
#endif /* !proto --> */
|