aboutsummaryrefslogtreecommitdiff
path: root/plugins/libre_redirect
diff options
context:
space:
mode:
authorNunoSempere <nuno.semperelh@protonmail.com>2024-03-23 21:51:55 -0300
committerNunoSempere <nuno.semperelh@protonmail.com>2024-03-23 21:51:55 -0300
commit07cae73c7116aee9686432783394eaba2c854ab9 (patch)
treef41dcb6e3e3d986e10094765dfbe68f2270294cd /plugins/libre_redirect
parented76b7e9e72cc2c3b5eeef0707638ff39a7cd31a (diff)
remove extra files
Diffstat (limited to 'plugins/libre_redirect')
-rw-r--r--plugins/libre_redirect/README.md3
-rw-r--r--plugins/libre_redirect/libre_redirect.c66
-rw-r--r--plugins/libre_redirect/libre_redirect.h5
-rw-r--r--plugins/libre_redirect/str_replace_test/build-example.sh11
-rw-r--r--plugins/libre_redirect/str_replace_test/example.c19
5 files changed, 0 insertions, 104 deletions
diff --git a/plugins/libre_redirect/README.md b/plugins/libre_redirect/README.md
deleted file mode 100644
index f3f58c9..0000000
--- a/plugins/libre_redirect/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-## About
-
-This code automatically redirects webpage to their open-source frontends. It is based on <https://libredirect.codeberg.page/> \ No newline at end of file
diff --git a/plugins/libre_redirect/libre_redirect.c b/plugins/libre_redirect/libre_redirect.c
deleted file mode 100644
index 55ddb84..0000000
--- a/plugins/libre_redirect/libre_redirect.c
+++ /dev/null
@@ -1,66 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-
-#include "../strings/strings.h"
-
-#define LIBRE_N 50
-
-/* Inspired by https://libredirect.github.io/, but in C. */
-int libre_redirect(const char* uri, char* output)
-{
- int len_uri = strlen(uri);
- int len_output = strlen(output);
-
- if ((len_output - len_uri) < LIBRE_N) {
- fprintf(stderr, "Not enough memory\n");
- return 1; // not enough memory.
- } else {
- char* annoying_sites[] = {
- "https://www.reddit.com",
- "https://www.youtube.com",
- "https://google.com",
- "https://medium.com",
- "https://translate.google.com",
- "https://www.bloomberg.com",
- "https://www.royalroad.com",
- "https://genius.com",
- // "https://archive.org",
- // "https://twitter.com"
- };
-
- char* alternatives[] = {
- "https://old.reddit.com", // "https://teddit.nunosempere.com",
- "https://invidious.private.coffee",
- "https://search.nunosempere.com",
- "https://scribe.rip",
- "https://translate.riverside.rocks",
- "https://archive.is/https://www.bloomberg.com",
- "https://royalread.nunosempere.com",
- "https://dumb.vern.cc",
- // "https://wayback.nunosempere.com",
- // "https://nitter.net"
- };
-
- int len = sizeof(annoying_sites) / sizeof(annoying_sites[0]);
- for (int i = 0; i < len; i++) {
- str_init(output, len_output);
- int replace_check = str_replace_start(uri, annoying_sites[i],
- alternatives[i], output);
- switch (replace_check) {
- case 0: // no match found
- break;
- case 1: // str_replace_start somehow failed
- fprintf(stderr, "str_replace_start failed\n");
- return 1;
- break;
- case 2: // match succeeded
- return 2;
- break;
- default:
- fprintf(stderr, "Unreachable state\n");
- }
- }
- strcpy(output, uri);
- }
- return 0;
-}
diff --git a/plugins/libre_redirect/libre_redirect.h b/plugins/libre_redirect/libre_redirect.h
deleted file mode 100644
index 7addeb0..0000000
--- a/plugins/libre_redirect/libre_redirect.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#pragma once
-
-#define LIBRE_N 50
-
-int libre_redirect(const char* uri, char* uri_filtered);
diff --git a/plugins/libre_redirect/str_replace_test/build-example.sh b/plugins/libre_redirect/str_replace_test/build-example.sh
deleted file mode 100644
index a9f8022..0000000
--- a/plugins/libre_redirect/str_replace_test/build-example.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/bash
-CC=gcc
-
-FLAGS="-std=c99 -Wall -lm"
-
-SRC=example.c
-REQS="../str_replace_start.c ../libre_redirect.c"
-
-echo -e "\n\n\n"
-$CC $FLAGS $SRC $REQS -o example
-
diff --git a/plugins/libre_redirect/str_replace_test/example.c b/plugins/libre_redirect/str_replace_test/example.c
deleted file mode 100644
index b93634a..0000000
--- a/plugins/libre_redirect/str_replace_test/example.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include "../libre_redirect.h"
-#include <stdio.h>
-#include <string.h>
-
-int main()
-{
- char uri[] = "https://reddit.com/r/blah";
-
- int l = LIBRE_N + strlen(uri) + 1;
- char uri_filtered[l];
- str_init(uri_filtered, l);
-
- if (!libre_redirect(uri, uri_filtered)) {
- printf("Filtered uri: %s\n", uri_filtered);
- } else {
- printf("Uri: %s\n", uri);
- // failure; do something with the original uri.
- }
-}