From 07cae73c7116aee9686432783394eaba2c854ab9 Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Sat, 23 Mar 2024 21:51:55 -0300 Subject: remove extra files --- plugins/libre_redirect/README.md | 3 - plugins/libre_redirect/libre_redirect.c | 66 ---------------------- plugins/libre_redirect/libre_redirect.h | 5 -- .../str_replace_test/build-example.sh | 11 ---- plugins/libre_redirect/str_replace_test/example.c | 19 ------- 5 files changed, 104 deletions(-) delete mode 100644 plugins/libre_redirect/README.md delete mode 100644 plugins/libre_redirect/libre_redirect.c delete mode 100644 plugins/libre_redirect/libre_redirect.h delete mode 100644 plugins/libre_redirect/str_replace_test/build-example.sh delete mode 100644 plugins/libre_redirect/str_replace_test/example.c (limited to 'plugins/libre_redirect') 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 \ 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 -#include - -#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 -#include - -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. - } -} -- cgit v1.2.3