Skip to content

Commit

Permalink
b64idx: move to base64.h
Browse files Browse the repository at this point in the history
  • Loading branch information
dankamongmen committed Dec 20, 2021
1 parent 08eca8c commit 22d989a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 16 additions & 0 deletions src/lib/base64.h
Original file line number Diff line number Diff line change
Expand Up @@ -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+/";
Expand Down
16 changes: 0 additions & 16 deletions src/lib/kitty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 22d989a

Please sign in to comment.