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/shortcuts/shortcuts.c | 65 ------------------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 plugins/shortcuts/shortcuts.c (limited to 'plugins/shortcuts/shortcuts.c') diff --git a/plugins/shortcuts/shortcuts.c b/plugins/shortcuts/shortcuts.c deleted file mode 100644 index e26fb66..0000000 --- a/plugins/shortcuts/shortcuts.c +++ /dev/null @@ -1,65 +0,0 @@ -#include -#include -#include - -#include "../strings/strings.h" - -#define SHORTCUT_N 41 -#define DEBUG false - -/* Inspired by https://duckduckgo.com/bangs */ -int shortcut_expand(const char* uri, char* output) -{ - int len_uri = strlen(uri); - int len_output = strlen(output); - - if ((len_output - len_uri) < SHORTCUT_N) { - fprintf(stderr, "Not enough memory\n"); - return 1; // not enough memory. - } else { - char* shortcuts[] = { - "!aa", - "!blog", - "!fnf", - "!fnc", - "!hn", - "!hnb" - "!x", - }; - - char* expansions[] = { - "https://annas-archive.org", - "https://nunosempere.com/blog", - "https://forum.nunosempere.com/frontpage", - "https://forum.nunosempere.com/comments", - "https://news.ycombinator.com", - "https://news.ycombinator.com/best", - "https://twitter.com", - }; - - // len = sizeof(shortcuts) / sizeof(shortcuts[0]); - int len = sizeof(shortcuts) / sizeof(char*); - - for (int i = 0; i < len; i++) { - str_init(output, len_output); - int replace_check = str_replace_start(uri, shortcuts[i], - expansions[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); - } - if (DEBUG) printf("No match found\n\n"); - return 0; -} -- cgit v1.2.3