about summary refs log tree commit diff
diff options
context:
space:
mode:
authorsternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2020-09-19 11:29:36 +0200
committersternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2020-09-19 11:29:36 +0200
commit79776dc45429f1c724b9037f18ebc172058fc734 (patch)
tree182853b6fad5e50623f925be82b9a6b626b877d3
parentf4b7cf4448effa168f2e1c247353c00e2741e831 (diff)
refactor(headers): allow multiple inclusions
-rw-r--r--sternenblog/cgiutil.h5
-rw-r--r--sternenblog/core.h5
-rw-r--r--sternenblog/entry.h9
-rw-r--r--sternenblog/index.h9
-rw-r--r--sternenblog/stringutil.h5
-rw-r--r--sternenblog/template.h9
-rw-r--r--sternenblog/timeutil.h6
-rw-r--r--sternenblog/xml.h6
8 files changed, 48 insertions, 6 deletions
diff --git a/sternenblog/cgiutil.h b/sternenblog/cgiutil.h
index f809b25..fc359e7 100644
--- a/sternenblog/cgiutil.h
+++ b/sternenblog/cgiutil.h
@@ -3,6 +3,9 @@
  * @brief Simple CGI/HTTP helper functions used by sternenblog.
  */
 
+#ifndef STERNENBLOG_CGIUTIL_H
+#define STERNENBLOG_CGIUTIL_H
+
 #include <stdbool.h>
 
 /*!
@@ -109,3 +112,5 @@ int urlencode_realloc(char **input, int size);
  * @return Pointer to dynamically allocated char buffer containing the URL.
  */
 char *server_url(bool https);
+
+#endif
diff --git a/sternenblog/core.h b/sternenblog/core.h
index d380d24..8f317ec 100644
--- a/sternenblog/core.h
+++ b/sternenblog/core.h
@@ -2,6 +2,10 @@
  * @file core.h
  * @brief Central type definitions of sternenblog
  */
+
+#ifndef STERNENBLOG_CORE_H
+#define STERNENBLOG_CORE_H
+
 #include <time.h>
 
 /*!
@@ -46,3 +50,4 @@ enum page_type {
   PAGE_TYPE_ERROR
 };
 
+#endif
diff --git a/sternenblog/entry.h b/sternenblog/entry.h
index de8d868..66e76bb 100644
--- a/sternenblog/entry.h
+++ b/sternenblog/entry.h
@@ -1,10 +1,13 @@
 /*!
  * @file entry.h
  * @brief Construction and destruction of entries
- *
- * Requires prior inclusion of core.h.
  */
 
+#ifndef STERNENBLOG_ENTRY_H
+#define STERNENBLOG_ENTRY_H
+
+#include "core.h"
+
 /*!
  * @brief Construct an entry for a given `PATH_INFO`
  *
@@ -107,3 +110,5 @@ void entry_unget_text(struct entry *entry);
  * @see entry_unget_text
  */
 void free_entry(struct entry *entry);
+
+#endif
diff --git a/sternenblog/index.h b/sternenblog/index.h
index 586d203..ae0a91b 100644
--- a/sternenblog/index.h
+++ b/sternenblog/index.h
@@ -1,9 +1,12 @@
 /*!
  * @file index.h
  * @brief Construction and destruction of entry indices
- *
- * Requires prior inclusion of core.h.
  */
+
+#ifndef STERNENBLOG_INDEX_H
+#define STERNENBLOG_INDEX_H
+
+#include "core.h"
 #include <stdbool.h>
 
 /*!
@@ -34,3 +37,5 @@ int make_index(const char *blog_dir, char *script_name, bool get_text, struct en
  * @param count size of the given array
  */
 void free_index(struct entry *entries[], int count);
+
+#endif
diff --git a/sternenblog/stringutil.h b/sternenblog/stringutil.h
index c7cb40d..11c678f 100644
--- a/sternenblog/stringutil.h
+++ b/sternenblog/stringutil.h
@@ -3,6 +3,9 @@
  * @brief Utilities for string construction
  */
 
+#ifndef STERNENBLOG_STRINGUTIL_H
+#define STERNENBLOG_STRINGUTIL_H
+
 /*!
  * @brief Returns hex digit for given integer
  *
@@ -25,3 +28,5 @@ char nibble_hex(short h);
  * @return pointer to concatenated strings or `NULL` on error.
  */
 char *catn_alloc(size_t n, ...);
+
+#endif
diff --git a/sternenblog/template.h b/sternenblog/template.h
index 24b9504..21ff38b 100644
--- a/sternenblog/template.h
+++ b/sternenblog/template.h
@@ -2,8 +2,6 @@
  * @file template.h
  * @brief Declarations of functions to be implemented by a sternenblog template
  *
- * Requires prior inclusion of core.h.
- *
  * The functions declared in template.h are called by `blog_index()`
  * and `blog_entry()` to generate the HTML document CGI responses
  * involving HTML (contrary to the RSS feed which is independent
@@ -20,6 +18,11 @@
  * * template_footer()
  */
 
+#ifndef STERNENBLOG_TEMPLATE_H
+#define STERNENBLOG_TEMPLATE_H
+
+#include "core.h"
+
 /*!
  * @brief (Meta) data about the page being served
  *
@@ -99,3 +102,5 @@ void template_footer(struct template_data data);
  * @see struct template_data
  */
 void template_main(struct template_data data);
+
+#endif
diff --git a/sternenblog/timeutil.h b/sternenblog/timeutil.h
index 7d0270e..4d36967 100644
--- a/sternenblog/timeutil.h
+++ b/sternenblog/timeutil.h
@@ -2,6 +2,10 @@
  * @file
  * @brief Utilities for rendering timestamps as strings
  */
+
+#ifndef STERNENBLOG_TIMEUTIL_H
+#define STERNENBLOG_TIMEUTIL_H
+
 enum time_format {
     RSS_TIME_FORMAT,          //!< RFC822 formatted time with 4 instead of 2 year digits
     ATOM_TIME_FORMAT,         //!< RFC3339 formatted time
@@ -41,3 +45,5 @@ enum time_format {
  * @return `0` on error, otherwise length of the string placed in `b` excluding terminating `NUL` byte
  */
 size_t flocaltime(char *b, enum time_format type, size_t size, const time_t *time);
+
+#endif
diff --git a/sternenblog/xml.h b/sternenblog/xml.h
index 869a579..e790f76 100644
--- a/sternenblog/xml.h
+++ b/sternenblog/xml.h
@@ -30,6 +30,10 @@
  *
  * @include xml_example.c
  */
+
+#ifndef STERNENBLOG_XML_H
+#define STERNENBLOG_XML_H
+
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>
@@ -338,3 +342,5 @@ void xml_open_cdata(struct xml_context *ctx);
  * @see xml_open_cdata
  */
 void xml_close_cdata(struct xml_context *ctx);
+
+#endif