aboutsummaryrefslogtreecommitdiff
path: root/src/fallback.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/fallback.h')
-rw-r--r--src/fallback.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/fallback.h b/src/fallback.h
new file mode 100644
index 0000000..cfca233
--- /dev/null
+++ b/src/fallback.h
@@ -0,0 +1,37 @@
+#ifndef FALLBACK_H
+#define FALLBACK_H
+
+/*
+ Fallback reads the fallback.json to get fallbacks for downloads (currently only for rss).
+ If the regular download fails then the download is retried with fallbacks until one succeeds.
+ That fallback is then used for all downloads for the current sync for that domain.
+*/
+
+#include "buffer.h"
+#include <stdbool.h>
+
+typedef struct {
+ char *source;
+ /* If this is NULL (default) then |source| is used. This is set to the first fallback that succeeds if |source| fails and is reset to NULL the next sync. This is a reference. */
+ const char *source_to_use;
+ /* list of char* (malloced) */
+ Buffer fallbacks;
+} fallback_item;
+
+typedef struct fallback fallback;
+struct fallback {
+ /* list of fallback_item */
+ Buffer fallbacks;
+};
+
+bool fallback_load_from_file(fallback *self, const char *filepath);
+void fallback_deinit(fallback *self);
+
+/* Given an url, look for a fallback item that has a matching source or source_to_use (matching by host). If no match found, return NULL */
+fallback_item* fallback_get_from_url(fallback *self, const char *url);
+void fallback_clear_sources_to_use(fallback *self);
+void fallback_replace_url_with_fallback_url(const char *url, const char *fallback_url, char *new_url, size_t new_url_len);
+void fallback_replace_active_fallback_url_with_source_url(fallback *self, const char *url, char *new_url, size_t new_url_len);
+void fallback_item_replace_url_with_fallback_url(fallback_item *self, const char *url, char *new_url, size_t new_url_len);
+
+#endif /* FALLBACK_H */