aboutsummaryrefslogtreecommitdiff
path: root/src/blocks/text.c
blob: 270b19765e65e08568cb1630e1664303addace5c (plain)
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
#include "scheme.h"

#include "../any_log.h"

static void block_text_clean(block_t *block)
{
    block_text_t *text = (block_text_t *)block;
    free(text->text);
}

static bool block_text_validate(block_t *block, const block_scheme_t *scheme)
{
    block_text_t *text = (block_text_t *)block;

    if (text->text == NULL) {
        log_error("Block '%s' requires key '%s'", block->label, "text");
        return false;
    }

    return true;
}

const block_scheme_t block_text_scheme = {
    .name = "text",
    .block = {
        .type = BLOCK_TEXT,
        .clean_fn = block_text_clean,
    },
    .size = sizeof(block_text_t),
    .entries = NULL,
    .validate = block_text_validate,
};