aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/engine.h8
-rw-r--r--include/msg.h2
-rw-r--r--src/engine/eachdo.c12
-rw-r--r--src/msg.c2
-rw-r--r--src/template.c2
5 files changed, 16 insertions, 10 deletions
diff --git a/include/engine.h b/include/engine.h
index aec55b2..8184567 100644
--- a/include/engine.h
+++ b/include/engine.h
@@ -57,9 +57,9 @@ void handle_eachdo(char **buffer,
key_match_t *match,
directive_t *directive,
config_t *config);
-void handle_page_source(list_t *atoms,
- eachdo_operands_t *operands,
- list_t *directives,
- config_t *config);
+void handle_config_source(list_t *atoms,
+ eachdo_operands_t *operands,
+ list_t *directives,
+ config_t *config);
#endif
diff --git a/include/msg.h b/include/msg.h
index da6cd19..f292ca1 100644
--- a/include/msg.h
+++ b/include/msg.h
@@ -19,6 +19,7 @@
#ifndef __MSG_H
#define __MSG_H
+#include <config.h>
#include <stdbool.h>
#define PARTIALS "partials"
@@ -30,6 +31,7 @@ typedef struct {
char *base_directory;
char *output_directory;
bool verbose;
+ config_t *config;
} msg_t;
int run(bool log);
diff --git a/src/engine/eachdo.c b/src/engine/eachdo.c
index 2b1cf07..1bebfd9 100644
--- a/src/engine/eachdo.c
+++ b/src/engine/eachdo.c
@@ -154,10 +154,10 @@ handle_file_source(list_t *atoms,
}
void
-handle_page_source(list_t *atoms,
- eachdo_operands_t *operands,
- list_t *directives,
- config_t *config)
+handle_config_source(list_t *atoms,
+ eachdo_operands_t *operands,
+ list_t *directives,
+ config_t *config)
{
if (config == NULL) {
printf("EACHDO with page variables as a source will not work without "
@@ -210,7 +210,9 @@ handle_eachdo(char **buffer,
if (!strcmp(operands->source, "resources"))
handle_file_source(atoms, operands, directives);
else if (!strcmp(operands->source, "page"))
- handle_page_source(atoms, operands, directives, config);
+ handle_config_source(atoms, operands, directives, config);
+ else if (!strcmp(operands->source, "config"))
+ handle_config_source(atoms, operands, directives, msg->config);
else
printf("Unknown source: %s\n", operands->source);
diff --git a/src/msg.c b/src/msg.c
index 7bdc295..dce8ba1 100644
--- a/src/msg.c
+++ b/src/msg.c
@@ -160,6 +160,8 @@ run(bool log)
if (config == NULL)
return EXIT_FAILURE;
+ msg->config = config;
+
template_initialize();
int err = mkdir(msg->output_directory, 0700);
diff --git a/src/template.c b/src/template.c
index c228ffe..ee15516 100644
--- a/src/template.c
+++ b/src/template.c
@@ -205,7 +205,7 @@ template_write(engine_t *engine, FILE *f, void *doc, bool is_markdown)
list_t *atoms = list_create(sizeof(ptr_wrapper_t));
list_t *directives = lex(operands->content);
- handle_page_source(atoms, operands, directives, engine->config);
+ handle_config_source(atoms, operands, directives, engine->config);
for (size_t i = 0; i < atoms->size; i++) {
atom_t *atom = list_get(atoms, i);