Skip to content

Commit

Permalink
update workflows and stability. (#12)
Browse files Browse the repository at this point in the history
* fix workflows.

* Specify anonymous namespace explicitly.
  • Loading branch information
dojyorin authored Nov 9, 2023
1 parent b00fdfb commit 1f87cdb
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 23 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "test",
"on": {
"push": {
"branches": [
"dev"
"branches-ignore": [
"master"
],
"paths-ignore": [
".git*",
Expand All @@ -13,8 +13,7 @@
},
"pull_request": {
"branches": [
"master",
"dev"
"master"
],
"paths-ignore": [
".git*",
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
name: test
on:
push:
branches:
- dev
branches-ignore:
- master
paths-ignore:
- .git*
- '**.md'
- '*.properties'
pull_request:
branches:
- master
- dev
paths-ignore:
- .git*
- '**.md'
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/to_yaml.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
set -eu

cd ${0%/*}

for _v in $(find ./ -maxdepth 1 -type f -name '*.json'); do
yq -I 4 -o y ${_v} | head -c -1 > ${_v%.*}.yaml
done; unset _v
6 changes: 0 additions & 6 deletions .github/workflows_json/to_yaml.sh

This file was deleted.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# **Arduino Base64**
![actions:test](https://github.com/dojyorin/arduino_base64/actions/workflows/test.yaml/badge.svg)
![actions:release](https://github.com/dojyorin/arduino_base64/actions/workflows/release.yaml/badge.svg)
![shields:license](https://img.shields.io/github/license/dojyorin/arduino_base64)
![shields:release](https://img.shields.io/github/release/dojyorin/arduino_base64)

Convert between binary and base64 encoded string.
Easily convert sensor raw values, structures, etc...
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name=base64_encode
author=dojyorin
version=2.0.1
version=2.0.2
architectures=*
includes=arduino_base64.hpp
sentence=Convert between binary and base64 encoded string.
Expand Down
18 changes: 9 additions & 9 deletions src/base64.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "./arduino_base64.hpp"

namespace{
constexpr char symbols[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
constexpr char CODE[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

uint8_t indexOf(char search){
for(uint8_t i = 0; i < 64; i++){
if(symbols[i] == search){
if(::CODE[i] == search){
return i;
}
}
Expand Down Expand Up @@ -36,10 +36,10 @@ void base64::encode(const uint8_t* input, size_t inputLength, char* output){
bit8x3[position++] = *input++;

if(position == 3){
to6x4(bit8x3, bit6x4);
::to6x4(bit8x3, bit6x4);

for(const auto &v: bit6x4){
*output++ = symbols[v];
*output++ = ::CODE[v];
}

position = 0;
Expand All @@ -51,10 +51,10 @@ void base64::encode(const uint8_t* input, size_t inputLength, char* output){
bit8x3[i] = 0x00;
}

to6x4(bit8x3, bit6x4);
::to6x4(bit8x3, bit6x4);

for(uint8_t i = 0; i < position + 1; i++){
*output++ = symbols[bit6x4[i]];
*output++ = ::CODE[bit6x4[i]];
}

while(position++ < 3){
Expand All @@ -80,10 +80,10 @@ void base64::decode(const char* input, uint8_t* output){
break;
}

bit6x4[position++] = indexOf(*input++);
bit6x4[position++] = ::indexOf(*input++);

if(position == 4){
to8x3(bit6x4, bit8x3);
::to8x3(bit6x4, bit8x3);

for(const auto &v: bit8x3){
*output++ = v;
Expand All @@ -98,7 +98,7 @@ void base64::decode(const char* input, uint8_t* output){
bit6x4[i] = 0x00;
}

to8x3(bit6x4, bit8x3);
::to8x3(bit6x4, bit8x3);

for(uint8_t i = 0; i < position - 1; i++){
*output++ = bit8x3[i];
Expand Down

0 comments on commit 1f87cdb

Please sign in to comment.