about summary refs log tree commit diff
path: root/index.h
blob: 586d2038b65810feda8531f7159ddf3e03d9a87a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*!
 * @file index.h
 * @brief Construction and destruction of entry indices
 *
 * Requires prior inclusion of core.h.
 */
#include <stdbool.h>

/*!
 * @brief Build index of given `blog_dir`
 *
 * Allocates an array of entries, reads `blog_dir` and adds a `struct entry` to the
 * array for every file for which `make_entry()` reports no error. It doesn't enter
 * subdirectories.
 *
 * Note that it's error handling is very simple and it doesn't distinguish between an
 * error occuring and the end of the directory.
 *
 * @param blog_dir path to the directory entries are stored in
 * @param script_name the value of the `SCRIPT_NAME` environment variable
 * @param get_text whether to call `entry_get_text()` on successfully constructed entries
 * @param entries pointer to an array that should be used
 * @return size of the dynamically allocated entries array
 * @see free_index
 */
int make_index(const char *blog_dir, char *script_name, bool get_text, struct entry *entries[]);

/*!
 * @brief Free dynamically allocated index
 *
 * Call `free_entry()` for every entry and free entire array afterwards.
 *
 * @param entries pointer to array of entries
 * @param count size of the given array
 */
void free_index(struct entry *entries[], int count);