Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
babenek committed Jul 24, 2022
1 parent 7c92719 commit 6cc42f9
Show file tree
Hide file tree
Showing 13 changed files with 468 additions and 336 deletions.
21 changes: 0 additions & 21 deletions .circleci/config.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '31 5 * * 5'
- cron: '20 21 * * 5'

jobs:
analyze:
Expand Down
39 changes: 33 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,42 @@
name: CI

on: [push]
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [created]

jobs:

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Run a one-line script
run: echo Hello, world!
- name: Run a multi-line script
run: cmake . && make

- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: echo "$GITHUB_CONTEXT"

- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: CMake
run: cmake .

- name: Make
run: make all

- name: Test
run: make test

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
cmake_minimum_required(VERSION 3.10)
project(base91)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 20)

add_executable(base91 base91.cpp)

add_executable(test_base91 test_base91.cpp test_base91.cpp)

add_test(NAME test_base91 COMMAND test_base91)

enable_testing()

install(TARGETS base91)
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ It may hurt C or C++ code when the string is placed into code.
But sequence %%% should not appear. So, encoded string might be placed with raw string literal:

char string[]=R"%%%( a string )%%%";

Workaround: use space | line feed | tab in encoded text to break wrong sequence due the algorithm skips non alphabet symbols.
e.g. Ma^7*/0629 -> Ma^7* /0629
18 changes: 18 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Security Policy

## Supported Versions

Use this section to tell people about which versions of your project are
currently being supported with security updates.

| Version | Supported |
| ------- | ------------------ |
| 0.0.0 | :x: |

## Reporting a Vulnerability

Use this section to tell people how to report a vulnerability.

Tell them where to go, how often they can expect to get an update on a
reported vulnerability, what to expect if the vulnerability is accepted or
declined, etc.
96 changes: 46 additions & 50 deletions base91.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,72 +6,68 @@

//------------------------------------------------------------------------------

template<typename Container>
void
readFile(const std::string & fileName, Container &container)
template <typename Container>
void readFile(const std::string &fileName, Container &container)
{
std::fstream fs(fileName, std::ios::in | std::ios::binary);
if (fs.is_open() and fs.good())
{
fs.seekg(0, std::ios::end);
auto newSize = fs.tellp();
fs.seekg(0, std::ios::beg);
container.clear();
container.resize(newSize);
fs.read(&container[0], newSize);
fs.close();
}
return;
std::fstream fs(fileName, std::ios::in | std::ios::binary);
if (fs.is_open() and fs.good())
{
fs.seekg(0, std::ios::end);
auto newSize = fs.tellp();
fs.seekg(0, std::ios::beg);
container.clear();
container.resize(newSize);
fs.read(&container[0], newSize);
fs.close();
}
return;
}

//------------------------------------------------------------------------------

template<typename Container>
void
writeFile(const std::string & fileName, const Container &container)
template <typename Container>
void writeFile(const std::string &fileName, const Container &container)
{
std::fstream fs(fileName, std::ios::trunc | std::ios::out | std::ios::binary);
std::fstream fs(fileName, std::ios::trunc | std::ios::out | std::ios::binary);

if (fs.good())
{
fs.write(container.data(), container.size());
fs.close();
}
return;
if (fs.good())
{
fs.write(container.data(), container.size());
fs.close();
}
return;
}

//------------------------------------------------------------------------------

int
main(const int argc, const char *argv[])
int main(const int argc, const char *argv[])
{
if (argc!=4 or not(0==strncmp("-e", argv[1], 3) or 0==strncmp("-d", argv[1], 3)))
{
std::cerr << "base91 -e|-d <in-file> <out-file>";
return -1;
}
if (argc != 4 or not(0 == strncmp("-e", argv[1], 3) or 0 == strncmp("-d", argv[1], 3)))
{
std::cerr << "base91 -e|-d <in-file> <out-file>";
return -1;
}

if (0==strncmp("-e", argv[1], 3))
{
std::vector<char> in;
std::string out;
if (0 == strncmp("-e", argv[1], 3))
{
std::vector<char> in;
std::string out;

readFile(argv[2], in);
base91::encode(in, out);
writeFile(argv[3], out);
}
else
{
std::string in;
std::vector<char> out;
readFile(argv[2], in);
base91::encode(in, out);
writeFile(argv[3], out);
}
else
{
std::string in;
std::vector<char> out;

readFile(argv[2], in);
base91::decode(in, out);
writeFile(argv[3], out);
}
readFile(argv[2], in);
base91::decode(in, out);
writeFile(argv[3], out);
}

return 0;
return 0;
}

//------------------------------------------------------------------------------

Loading

0 comments on commit 6cc42f9

Please sign in to comment.