From a8be16b1ee80f5d1d89b66494ec74af999652c2a Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Sat, 13 May 2023 23:50:14 -0400 Subject: debug shortcuts plugin --- plugins/libre_redirect/libre_redirect.c | 8 +------- plugins/libre_redirect/str_init.c | 7 +++++++ plugins/libre_redirect/str_init.h | 1 + plugins/shortcuts/README.md | 4 ++++ plugins/shortcuts/shortcuts.c | 11 +++-------- plugins/shortcuts/shortcuts.h | 3 +-- 6 files changed, 17 insertions(+), 17 deletions(-) create mode 100644 plugins/libre_redirect/str_init.c create mode 100644 plugins/libre_redirect/str_init.h (limited to 'plugins') diff --git a/plugins/libre_redirect/libre_redirect.c b/plugins/libre_redirect/libre_redirect.c index 134eabe..5f384d9 100644 --- a/plugins/libre_redirect/libre_redirect.c +++ b/plugins/libre_redirect/libre_redirect.c @@ -2,6 +2,7 @@ #include #include +#include "str_init.h" #include "str_replace_start.h" #define LIBRE_N 19 @@ -11,13 +12,6 @@ /* Inspired by https://libredirect.github.io/, but in C. */ -void str_init(char* str, int n) -{ - for (int i = 0; i < n; i++) - str[i] = ' '; - str[n] = '\0'; -} // could also use - int libre_redirect(const char* uri, char* output) { int l1 = strlen(uri); diff --git a/plugins/libre_redirect/str_init.c b/plugins/libre_redirect/str_init.c new file mode 100644 index 0000000..edbe2ab --- /dev/null +++ b/plugins/libre_redirect/str_init.c @@ -0,0 +1,7 @@ +void str_init(char* str, int n) +{ + for (int i = 0; i < n; i++) + str[i] = ' '; + str[n] = '\0'; +} // could also use + diff --git a/plugins/libre_redirect/str_init.h b/plugins/libre_redirect/str_init.h new file mode 100644 index 0000000..b282b7f --- /dev/null +++ b/plugins/libre_redirect/str_init.h @@ -0,0 +1 @@ +void str_init(char* str, int n); diff --git a/plugins/shortcuts/README.md b/plugins/shortcuts/README.md index 724c5d6..9718c4d 100644 --- a/plugins/shortcuts/README.md +++ b/plugins/shortcuts/README.md @@ -1,3 +1,7 @@ ## About This code automatically redirects shortcuts to their longer expansions. Similar to DuckDuckGo's bangs () + +Note that Whoogle (the default search engine) also has its own bangs! +- See: https://github.com/benbusby/whoogle-search/blob/main/app/utils/bangs.py +- and https://duckduckgo.com/bang.v255.js diff --git a/plugins/shortcuts/shortcuts.c b/plugins/shortcuts/shortcuts.c index bc25bbf..1af4fda 100644 --- a/plugins/shortcuts/shortcuts.c +++ b/plugins/shortcuts/shortcuts.c @@ -3,23 +3,18 @@ #include #include "../libre_redirect/str_replace_start.h" +#include "../libre_redirect/str_init.h" -#define SHORTCUT_N 20 +#define SHORTCUT_N 41 /* Uncomment for debug */ /* #define DEBUG */ /* Inspired by https://duckduckgo.com/bangs */ -void str_init(char* str, int n) -{ - for (int i = 0; i < n; i++) - str[i] = ' '; - str[n] = '\0'; -} // could also use - int shortcut_expand(const char* uri, char* output) { + printf("SHORTCUT EXPAND!"); int l1 = strlen(uri); int l2 = strlen(output); int len; diff --git a/plugins/shortcuts/shortcuts.h b/plugins/shortcuts/shortcuts.h index 00d08bd..5276281 100644 --- a/plugins/shortcuts/shortcuts.h +++ b/plugins/shortcuts/shortcuts.h @@ -1,6 +1,5 @@ #pragma once -#define SHORTCUT_N 20 +#define SHORTCUT_N 41 int shortcut_expand(const char* uri, char* output); -void str_init(char* str, int n); -- cgit v1.2.3