aboutsummaryrefslogtreecommitdiff
path: root/beaker.h
diff options
context:
space:
mode:
Diffstat (limited to 'beaker.h')
-rw-r--r--beaker.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/beaker.h b/beaker.h
index 96125d3..cc87634 100644
--- a/beaker.h
+++ b/beaker.h
@@ -20,6 +20,14 @@
#define TEMPLATES_DIR "templates/"
#define STATIC_DIR "static/"
+#define LOCALES_DIR "locales/"
+
+#define INITIAL_LOCALES_CAPACITY 8
+#define INITIAL_LOCALE_KEYS_CAPACITY 16
+#define MAX_LOCALES_HARD 1024
+#define MAX_LOCALE_KEYS_HARD 65536
+#define MAX_LOCALE_ID_LEN 64
+#define MAX_LOCALE_VALUE_LEN 512
typedef enum {
CONTEXT_TYPE_STRING,
@@ -68,6 +76,28 @@ typedef struct {
bool secure;
} Cookie;
+typedef struct {
+ char id[MAX_LOCALE_ID_LEN];
+ char name[MAX_VALUE_LEN];
+ char direction[16];
+} LocaleMeta;
+
+typedef struct {
+ char key[MAX_KEY_LEN];
+ char value[MAX_LOCALE_VALUE_LEN];
+} LocaleKV;
+
+typedef struct {
+ LocaleMeta meta;
+ LocaleKV *keys;
+ int key_count;
+ int key_capacity;
+} Locale;
+
+typedef struct {
+ LocaleMeta meta;
+} LocaleInfo;
+
typedef int (*RequestHandler)(UrlParams *params);
typedef struct {
@@ -85,6 +115,13 @@ void context_set_array_of_arrays(TemplateContext *ctx, const char *key,
void free_context(TemplateContext *ctx);
char *render_template(const char *template_file, TemplateContext *ctx);
+int beaker_load_locales(void);
+void beaker_set_locale(TemplateContext *ctx, const char *locale_id);
+int beaker_get_all_locales(LocaleInfo *out, int max_count);
+const LocaleMeta *beaker_get_locale_meta(const char *locale_id);
+const char *beaker_get_locale_value(const char *locale_id, const char *key);
+void beaker_free_locales(void);
+
void send_response(const char *html);
void send_redirect(const char *location);
void set_cookie(const char *name, const char *value, const char *expires,