about summary refs log tree commit diff
path: root/core.h
blob: d380d24656cadc0169bb3428100e26fd55e34fdb (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
37
38
39
40
41
42
43
44
45
46
47
48
/*!
 * @file core.h
 * @brief Central type definitions of sternenblog
 */
#include <time.h>

/*!
 * @brief Resolved blog entry
 *
 * Represents a resolved entry and should only be
 * constructed using `make_entry()` and populated using
 * `entry_get_text()`.
 *
 * If constructed correctly, you can expect such an entry to exist.
 *
 * Use `free_entry()` to free allocated `char *` in an `entry`
 * constructed by `make_entry()` (and `entry_get_text()`).
 *
 * @see make_entry
 * @see entry_get_text
 * @see free_entry
 * @see make_index
 */
struct entry {
    // mandatory: part of each well-formed entry
    time_t time;       //!< last modification time of the entry
    char *path;        //!< path (on disk) to the entry
    char *link;        //!< absolute path on the http server to the entry
    char *title;       //!< title of the post, currently `PATH_INFO` without the initial slash
    size_t text_size;  //!< size of text, -1 to indicate it's missing
    // optional: may be NULL, depending on context
    char *text;        //!< contents of the entry (mmap-ed file) or `NULL`
};

/*!
 * @brief Type of a HTML response
 *
 * This enum describes the three types of HTML responses sternenblog can
 * generate: a single entry, an index and an error page.
 *
 * Used internally for routing and passed to the template for context.
 */
enum page_type {
  PAGE_TYPE_ENTRY,
  PAGE_TYPE_INDEX,
  PAGE_TYPE_ERROR
};