summaryrefslogtreecommitdiff
path: root/include/hybbx/texts.h
diff options
context:
space:
mode:
authorinfo@mode42.com <info@mode42.com>2026-08-08 03:54:55 +0000
committerinfo@mode42.com <info@mode42.com>2026-08-08 03:54:55 +0000
commit20cb29c2f8c5c87bc590896854a20b1473ceb358 (patch)
tree2857f41513a56ad41af97b57362639298aa7f033 /include/hybbx/texts.h
#2
Diffstat (limited to 'include/hybbx/texts.h')
-rw-r--r--include/hybbx/texts.h84
1 files changed, 84 insertions, 0 deletions
diff --git a/include/hybbx/texts.h b/include/hybbx/texts.h
new file mode 100644
index 0000000..ef1b9e3
--- /dev/null
+++ b/include/hybbx/texts.h
@@ -0,0 +1,84 @@
+#ifndef HYBBX_TEXTS_H
+#define HYBBX_TEXTS_H
+
+#include "hybbx/types.h"
+#include "hybbx/limits.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct hybbx_session;
+
+#define HYBBX_DEFAULT_TEXTS_PATH HYBBX_DIR_TEXT
+
+#define HYBBX_TEXT_BANNER "banner.txt"
+#define HYBBX_TEXT_MOTD "motd.txt"
+#define HYBBX_TEXT_NEWS "news.txt"
+#define HYBBX_TEXT_RULES "rules.txt"
+#define HYBBX_TEXT_VERSION "version.txt"
+
+/** Substituted in banner.txt / version.txt — HyBBX version number (e.g. 2.4.0). */
+#define HYBBX_BANNER_TOKEN_VERSION "@version@"
+/** Substituted in banner.txt line 2. */
+#define HYBBX_BANNER_TOKEN_SERVICE "@service@"
+/** Substituted in motd.txt (current session nickname). */
+#define HYBBX_TEXT_TOKEN_USERNAME "@username@"
+/** Substituted in version.txt — host operating system name (e.g. Linux). */
+#define HYBBX_TEXT_TOKEN_OS "@os@"
+/** Substituted in text files — local time per `[time]` (default HH:MM:SS). */
+#define HYBBX_TEXT_TOKEN_TIME "%time%"
+/** Substituted in text files — local date per `[time] date=` (default YYYY/MM/DD). */
+#define HYBBX_TEXT_TOKEN_DATE "%date%"
+
+#define HYBBX_TEXTS_PATH_MAX 512
+
+typedef struct hybbx_texts_config {
+ char path[HYBBX_TEXTS_PATH_MAX];
+} hybbx_texts_config_t;
+
+void hybbx_texts_config_defaults(hybbx_texts_config_t *texts);
+
+/**
+ * Build full path to a text file under the configured texts directory.
+ * Returns HYBBX_OK on success.
+ */
+hybbx_result_t hybbx_texts_resolve(const hybbx_texts_config_t *texts,
+ const char *filename,
+ char *out, size_t out_len);
+
+/**
+ * Send a text file line-by-line to the session (connection output).
+ * Expands @version@, @service@, @username@, @os@, %time%, and %date%.
+ * Missing files are skipped silently.
+ */
+hybbx_result_t hybbx_texts_send_file(const hybbx_texts_config_t *texts,
+ struct hybbx_session *session,
+ const char *filename);
+
+/**
+ * Send banner.txt with @version@ and @service@ tokens expanded.
+ */
+hybbx_result_t hybbx_texts_send_banner(const hybbx_texts_config_t *texts,
+ struct hybbx_session *session,
+ const char *version,
+ const char *service_name);
+
+/**
+ * Send motd.txt with @username@ expanded from @p session.
+ */
+hybbx_result_t hybbx_texts_send_motd(const hybbx_texts_config_t *texts,
+ struct hybbx_session *session);
+
+/**
+ * Send version.txt with @version@ and @os@ expanded from this host.
+ * Falls back to the built-in two-line version block if the file is missing.
+ */
+hybbx_result_t hybbx_texts_send_version(const hybbx_texts_config_t *texts,
+ struct hybbx_session *session);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HYBBX_TEXTS_H */
git clone -b <branch> https://cgit.mode42.com/<repo>.git
git clone -b <branch> git://cgit.mode42.com/<repo>.git

info@mode42.com