Files
ChameleonUltra/resource/tools/make_style.sh
Foxushka cf00761902 Key recovery via backdoor for static encrypted nonce cards (#263)
* Implement MF1_ENC_NESTED_ACQUIRE in firmware

* Implement MF1_ENC_NESTED_ACQUIRE in software + fix code formatter

* Remove xz and pthreads from sources, use CMake FetchContent

* Update changelog

* lzma.h

* Update CMakeLists.txt

* Update CMakeLists.txt

* Probably fix workflow taking wrong commit for building

* Fix CMake building tools into bin/Debug on Windows

* Added cmd for fetching all slots nicks (without 16 commands)

* Fix type and use temp directory instead cwd (https://github.com/RfidResearchGroup/ChameleonUltra/pull/261)

* Fix endian for mfu_read_emu_counter_data and mfu_write_emu_counter_data

* Fix  --key interpreted as list
2025-08-01 22:12:07 +02:00

50 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
# Make sure astyle is installed
if ! command -v astyle >/dev/null; then
echo "Please install 'astyle' package first" ;
exit 1
fi
if ! command -v autopep8 >/dev/null; then
echo "Please install 'python3-autopep8' package first" ;
exit 1
fi
# Remove spaces & tabs at EOL, add LF at EOF if needed on *.c, *.h, *.py, Makefile, *.txt
find . \( -not -path "./.git/*" -and -not -path "./firmware/nrf52_sdk/*" -and -not -path "*/venv/*" -and -not -path "*/tmp/*" -and \
\( -name "*.[ch]" -or -name "*.py" -or -name "Makefile" -or -name "*.txt" \) \) \
-exec perl -pi -e 's/[ \t]+$$//' {} \; \
-exec sh -c "tail -c1 {} | xxd -p | tail -1 | grep -q -v 0a\$" \; \
-exec sh -c "echo >> {}" \;
# Apply astyle on *.c, *.h
find . \( -not -path "./.git/*" -and -not -path "./firmware/nrf52_sdk/*" -and -not -path "*/venv/*" -and -not -path "*/tmp/*" -and \
-name "*.[ch]" \) \
-exec astyle --formatted --mode=c --suffix=none \
--indent=spaces=4 --indent-switches \
--keep-one-line-blocks \
--style=google --pad-oper --unpad-paren --pad-header \
--align-pointer=name {} \;
# Apply autopep8 on *py
find . \( -not -path "./.git/*" -and -not -path "./firmware/nrf52_sdk/*" -and -not -path "*/venv/*" -and -not -path "*/tmp/*" -and \
-name "*.py" \) \
-exec autopep8 --in-place --max-line-length 120 {} \;
# Detecting tabs.
if [[ "$(uname)" == "Darwin" ]]; then
TABSCMD="egrep -l '\t' {}"
else
TABSCMD="grep -lP '\t' {}"
fi
${REWRITE_TABS:=false}
if $REWRITE_TABS; then
TABSCMD="$TABSCMD && vi {} -c ':set tabstop=4' -c ':set et|retab' -c ':wq'"
echo "Files with tabs: (EDIT enabled, files will be rewritten!)"
else
echo "Files with tabs: (rerun with \"REWRITE_TABS=true $0\" if you want to convert them with vim)"
fi
# to remove tabs within lines, one can try with: vi $file -c ':set tabstop=4' -c ':set et|retab' -c ':wq'
find . \( -not -path "./.git/*" -and -not -path "./firmware/nrf52_sdk/*" -and -not -path "*/venv/*" -and -not -path "*/tmp/*" -and \
\( -name "*.[ch]" -or -name "*.py" -or -name "*.md" -or -name "*.txt" \) \) \
-exec sh -c "$TABSCMD" \;