36 lines
1.1 KiB
C
36 lines
1.1 KiB
C
#ifndef JOURNAL_H
|
|
#define JOURNAL_H
|
|
|
|
#include <stdint.h> /* uint32_t 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 */
|
|
};
|
|
|
|
#define TREE_NAME day
|
|
#define TREE_KEY union date32
|
|
#define TREE_VALUE const char *
|
|
#define TREE_HEAD
|
|
#include "../src/tree.h"
|
|
|
|
union date32 date32_last_month(union date32 d);
|
|
union date32 date32_next_month(union date32 d);
|
|
#include "text.h"
|
|
struct journal { struct day_tree days; struct char_array backing; };
|
|
struct journal_iterator { struct day_tree_iterator _; };
|
|
struct journal journal(void);
|
|
void journal_(struct journal *);
|
|
int journal_is_empty(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 /* JOURNAL_H */
|