From 22d989a847271dc09b0bbc44b6a0bbf446176364 Mon Sep 17 00:00:00 2001 From: nick black Date: Mon, 20 Dec 2021 13:55:35 -0500 Subject: [PATCH] b64idx: move to base64.h --- src/lib/base64.h | 16 ++++++++++++++++ src/lib/kitty.c | 16 ---------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/lib/base64.h b/src/lib/base64.h index c6c0cda2e7..b4ccd1c8b9 100644 --- a/src/lib/base64.h +++ b/src/lib/base64.h @@ -5,6 +5,22 @@ extern "C" { #endif +// convert a base64 character into its equivalent integer 0..63 +static inline int +b64idx(char b64){ + if(b64 >= 'A' && b64 <= 'Z'){ + return b64 - 'A'; + }else if(b64 >= 'a' && b64 <= 'z'){ + return b64 - 'a' + 26; + }else if(b64 >= '0' && b64 <= '9'){ + return b64 - '0' + 52; + }else if(b64 == '+'){ + return 62; + }else{ + return 63; + } +} + // lookup table for base64 static unsigned const char b64subs[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; diff --git a/src/lib/kitty.c b/src/lib/kitty.c index 17568ef354..af99d7a1b2 100644 --- a/src/lib/kitty.c +++ b/src/lib/kitty.c @@ -47,22 +47,6 @@ // // https://sw.kovidgoyal.net/kitty/graphics-protocol.html -// convert a base64 character into its equivalent integer 0..63 -static inline int -b64idx(char b64){ - if(b64 >= 'A' && b64 <= 'Z'){ - return b64 - 'A'; - }else if(b64 >= 'a' && b64 <= 'z'){ - return b64 - 'a' + 26; - }else if(b64 >= '0' && b64 <= '9'){ - return b64 - '0' + 52; - }else if(b64 == '+'){ - return 62; - }else{ - return 63; - } -} - // null out part of a triplet (a triplet is 3 pixels, which map to 12 bytes, which map to // 16 bytes when base64 encoded). skip the initial |skip| pixels, and null out a maximum // of |max| pixels after that. returns the number of pixels nulled out. |max| must be