Skip to content

Commit

Permalink
Merge pull request #14 from illuusio/code-format
Browse files Browse the repository at this point in the history
Code formating for C and PHP code
  • Loading branch information
illuusio committed Jan 12, 2023
2 parents 51356f1 + 08eb28d commit 116fa39
Show file tree
Hide file tree
Showing 8 changed files with 981 additions and 922 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/code-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
name: Test code formating guidelines

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
test-code-format:
runs-on: "ubuntu-latest"
container: "ubuntu:22.10"

env:
DEBIAN_FRONTEND: "noninteractive"
TZ: "Etc/GMT"

steps:
- uses: actions/checkout@v3
- name: Link correct timezone to '/etc/localtime'
run: ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
- name: Run 'apt update'
run: apt update
- name: Install astyle
run: apt install -y astyle php-codesniffer
- name: Test code formating with astyle
run: astyle --indent=spaces=4 --style=1tbs --max-code-length=120 --lineend=linux --align-pointer=name --align-reference=name --add-braces --formatted --convert-tabs --break-after-logical --pad-oper --break-blocks=all --indent-col1-comments *.c *.h > c_format_output.txt
- name: Test code formating with PHPCS
run: phpcs tools/blencode.php > php_format_output.txt
- name: Test if there is problems
run: |
if [ "$(stat -c %s c_format_output.txt)" != "0" ]
then
echo "These C files are not formated as expected:"
cat c_format_output.txt
exit 1
fi
if [ "$(stat -c %s php_format_output.txt)" != "0" ]
then
echo "These PHP files are not formated as expected:"
cat php_format_output.txt
exit 1
fi
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,10 @@ If you have added keys to correct place you should be able to run it as before.

## Extra things to do
For extra safety main encoding key should be changed in **blenc_protect.h** (It's named BLENC_PROTECT_MAIN_KEY). default is '0123456789abcdef0123456789abcdef'. In **blenc_protect.h** you can also make module expire.

# Code formating
Current formating is mainly [One True Brace Style (1TBS)](https://astyle.sourceforge.net/astyle.html#_style=1tbs) with some changes:
```
astyle --indent=spaces=4 --style=1tbs --max-code-length=120 --lineend=linux --align-pointer=name --align-reference=name --add-braces --formatted --convert-tabs --break-after-logical --pad-oper --break-blocks=all --indent-col1-comments *.c *.h
```
It's tested with CI when doing Pull Request.
746 changes: 376 additions & 370 deletions bf_algo.c

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions bf_algo.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ See blowfish.c for more information about this file.


typedef struct {
unsigned long P[16 + 2];
unsigned long S[4][256];
unsigned long P[16 + 2];
unsigned long S[4][256];
} BLOWFISH_CTX;

void Blowfish_Init(BLOWFISH_CTX *ctx, unsigned char *key, int keyLen);
Expand Down
Loading

0 comments on commit 116fa39

Please sign in to comment.