diff --git a/src/PrinterDriverFactory.cpp b/src/PrinterDriverFactory.cpp index 55dbdd8..29cd109 100644 --- a/src/PrinterDriverFactory.cpp +++ b/src/PrinterDriverFactory.cpp @@ -1,3 +1,22 @@ +/* + ptrnt - print labels on linux + Copyright (C) 2024-2025 Moritz Martinius + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + */ + #include "PrinterDriverFactory.hpp" #include diff --git a/src/PrinterDriverFactory.hpp b/src/PrinterDriverFactory.hpp index b7f675f..a20cd7b 100644 --- a/src/PrinterDriverFactory.hpp +++ b/src/PrinterDriverFactory.hpp @@ -1,6 +1,26 @@ +/* + ptrnt - print labels on linux + Copyright (C) 2024-2025 Moritz Martinius + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + */ + #include -#include #include +#include + #include "interface/IPrinterDriver.hpp" #include "libusbwrap/LibUsbTypes.hpp" @@ -45,4 +65,4 @@ class PrinterDriverFactory { private: }; -} \ No newline at end of file +} // namespace ptprnt \ No newline at end of file diff --git a/src/PtouchPrint.cpp b/src/PtouchPrint.cpp index d0d352e..f2137f2 100644 --- a/src/PtouchPrint.cpp +++ b/src/PtouchPrint.cpp @@ -1,6 +1,6 @@ /* ptrnt - print labels on linux - Copyright (C) 2023 Moritz Martinius + Copyright (C) 2023-2025 Moritz Martinius This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/PtouchPrint.hpp b/src/PtouchPrint.hpp index 22b5c8f..911eea8 100644 --- a/src/PtouchPrint.hpp +++ b/src/PtouchPrint.hpp @@ -1,6 +1,6 @@ /* ptrnt - print labels on linux - Copyright (C) 2023 Moritz Martinius + Copyright (C) 2023-2025 Moritz Martinius This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/graphics/Bitmap.cpp b/src/graphics/Bitmap.cpp index 1bbcb13..9b29204 100644 --- a/src/graphics/Bitmap.cpp +++ b/src/graphics/Bitmap.cpp @@ -1,6 +1,6 @@ /* ptrnt - print labels on linux - Copyright (C) 2023 Moritz Martinius + Copyright (C) 2023-2025 Moritz Martinius This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/graphics/Bitmap.hpp b/src/graphics/Bitmap.hpp index 11a2b46..09fefc5 100644 --- a/src/graphics/Bitmap.hpp +++ b/src/graphics/Bitmap.hpp @@ -1,6 +1,6 @@ /* ptrnt - print labels on linux - Copyright (C) 2023 Moritz Martinius + Copyright (C) 2023-2025 Moritz Martinius This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/graphics/Label.cpp b/src/graphics/Label.cpp index 8ab09c3..c4d112f 100644 --- a/src/graphics/Label.cpp +++ b/src/graphics/Label.cpp @@ -1,6 +1,6 @@ /* ptrnt - print labels on linux - Copyright (C) 2023 Moritz Martinius + Copyright (C) 2023-2025 Moritz Martinius This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/graphics/Label.hpp b/src/graphics/Label.hpp index f7625ab..cee53e3 100644 --- a/src/graphics/Label.hpp +++ b/src/graphics/Label.hpp @@ -1,6 +1,6 @@ /* ptrnt - print labels on linux - Copyright (C) 2023 Moritz Martinius + Copyright (C) 2023-2025 Moritz Martinius This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/graphics/Monochrome.cpp b/src/graphics/Monochrome.cpp index 333e114..07f1100 100644 --- a/src/graphics/Monochrome.cpp +++ b/src/graphics/Monochrome.cpp @@ -1,6 +1,6 @@ /* ptrnt - print labels on linux - Copyright (C) 2023 Moritz Martinius + Copyright (C) 2023-2025 Moritz Martinius This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/graphics/Monochrome.hpp b/src/graphics/Monochrome.hpp index 958deb7..ec6b3c0 100644 --- a/src/graphics/Monochrome.hpp +++ b/src/graphics/Monochrome.hpp @@ -1,6 +1,6 @@ /* ptrnt - print labels on linux - Copyright (C) 2023 Moritz Martinius + Copyright (C) 2023-2025 Moritz Martinius This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/graphics/interface/ILabel.hpp b/src/graphics/interface/ILabel.hpp index d63c6e6..5c5c059 100644 --- a/src/graphics/interface/ILabel.hpp +++ b/src/graphics/interface/ILabel.hpp @@ -1,6 +1,6 @@ /* ptrnt - print labels on linux - Copyright (C) 2023 Moritz Martinius + Copyright (C) 2024-2025 Moritz Martinius This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/interface/IPrinterDriver.hpp b/src/interface/IPrinterDriver.hpp index 7a60462..48106fb 100644 --- a/src/interface/IPrinterDriver.hpp +++ b/src/interface/IPrinterDriver.hpp @@ -1,6 +1,6 @@ /* ptrnt - print labels on linux - Copyright (C) 2023 Moritz Martinius + Copyright (C) 2023-2025 Moritz Martinius This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/interface/IPrinterTypes.hpp b/src/interface/IPrinterTypes.hpp index d1b3d70..908a482 100644 --- a/src/interface/IPrinterTypes.hpp +++ b/src/interface/IPrinterTypes.hpp @@ -1,6 +1,6 @@ /* ptrnt - print labels on linux - Copyright (C) 2023 Moritz Martinius + Copyright (C) 2023-2024 Moritz Martinius This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/libusbwrap/LibUsbTypes.hpp b/src/libusbwrap/LibUsbTypes.hpp index 054210f..f11c79b 100644 --- a/src/libusbwrap/LibUsbTypes.hpp +++ b/src/libusbwrap/LibUsbTypes.hpp @@ -1,6 +1,6 @@ /* ptrnt - print labels on linux - Copyright (C) 2023 Moritz Martinius + Copyright (C) 2023-2024 Moritz Martinius This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/libusbwrap/UsbDevice.cpp b/src/libusbwrap/UsbDevice.cpp index c3c632f..dd22aee 100644 --- a/src/libusbwrap/UsbDevice.cpp +++ b/src/libusbwrap/UsbDevice.cpp @@ -1,6 +1,6 @@ /* ptrnt - print labels on linux - Copyright (C) 2023 Moritz Martinius + Copyright (C) 2023-2024 Moritz Martinius This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/libusbwrap/UsbDevice.hpp b/src/libusbwrap/UsbDevice.hpp index 8daa52a..475b1a3 100644 --- a/src/libusbwrap/UsbDevice.hpp +++ b/src/libusbwrap/UsbDevice.hpp @@ -1,6 +1,6 @@ /* ptrnt - print labels on linux - Copyright (C) 2023 Moritz Martinius + Copyright (C) 2023-2024 Moritz Martinius This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/libusbwrap/UsbDeviceFactory.cpp b/src/libusbwrap/UsbDeviceFactory.cpp index e5aead0..5ad5349 100644 --- a/src/libusbwrap/UsbDeviceFactory.cpp +++ b/src/libusbwrap/UsbDeviceFactory.cpp @@ -1,6 +1,6 @@ /* ptrnt - print labels on linux - Copyright (C) 2023 Moritz Martinius + Copyright (C) 2023-2025 Moritz Martinius This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/libusbwrap/interface/IUsbDevice.hpp b/src/libusbwrap/interface/IUsbDevice.hpp index 335e2ca..fe80de7 100644 --- a/src/libusbwrap/interface/IUsbDevice.hpp +++ b/src/libusbwrap/interface/IUsbDevice.hpp @@ -1,3 +1,22 @@ +/* + ptrnt - print labels on linux + Copyright (C) 2023-2024 Moritz Martinius + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + */ + #pragma once #include diff --git a/src/libusbwrap/interface/IUsbDeviceFactory.hpp b/src/libusbwrap/interface/IUsbDeviceFactory.hpp index a148e44..725edad 100644 --- a/src/libusbwrap/interface/IUsbDeviceFactory.hpp +++ b/src/libusbwrap/interface/IUsbDeviceFactory.hpp @@ -1,3 +1,22 @@ +/* + ptrnt - print labels on linux + Copyright (C) 2023 Moritz Martinius + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + */ + #pragma once #include @@ -9,8 +28,8 @@ namespace libusbwrap { class IUsbDeviceFactory { public: - virtual ~IUsbDeviceFactory() = default; - virtual std::vector> findAllDevices() = 0; + virtual ~IUsbDeviceFactory() = default; + virtual std::vector> findAllDevices() = 0; virtual std::vector> findDevices(uint16_t vid, uint16_t pid) = 0; }; } // namespace libusbwrap \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index ed35bcc..19a160a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,6 @@ /* ptrnt - print labels on linux - Copyright (C) 2023 Moritz Martinius + Copyright (C) 2022-2023 Moritz Martinius This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/printers/FakePrinter.cpp b/src/printers/FakePrinter.cpp index 4183aa2..caf3e67 100644 --- a/src/printers/FakePrinter.cpp +++ b/src/printers/FakePrinter.cpp @@ -1,6 +1,6 @@ /* ptrnt - print labels on linux - Copyright (C) 2023 Moritz Martinius + Copyright (C) 2025 Moritz Martinius This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/printers/FakePrinter.hpp b/src/printers/FakePrinter.hpp index 09baafa..12cd1ff 100644 --- a/src/printers/FakePrinter.hpp +++ b/src/printers/FakePrinter.hpp @@ -1,6 +1,6 @@ /* ptrnt - print labels on linux - Copyright (C) 2023 Moritz Martinius + Copyright (C) 2025 Moritz Martinius This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/printers/P700Printer.cpp b/src/printers/P700Printer.cpp index 23e75f0..b3f8e22 100644 --- a/src/printers/P700Printer.cpp +++ b/src/printers/P700Printer.cpp @@ -1,6 +1,6 @@ /* ptrnt - print labels on linux - Copyright (C) 2023 Moritz Martinius + Copyright (C) 2025 Moritz Martinius This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/printers/P700Printer.hpp b/src/printers/P700Printer.hpp index 43882e6..e14f500 100644 --- a/src/printers/P700Printer.hpp +++ b/src/printers/P700Printer.hpp @@ -1,6 +1,6 @@ /* ptrnt - print labels on linux - Copyright (C) 2023 Moritz Martinius + Copyright (C) 2025 Moritz Martinius This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/update_copyright.sh b/update_copyright.sh new file mode 100755 index 0000000..0823e8d --- /dev/null +++ b/update_copyright.sh @@ -0,0 +1,115 @@ +#!/bin/bash + +# update_copyright.sh +# Updates copyright year ranges in a source file based on git history +# +# Usage: ./update_copyright.sh [--dry-run] +# +# Examples: +# # Update a single file +# ./update_copyright.sh src/main.cpp +# +# # Dry-run on a single file +# ./update_copyright.sh --dry-run src/main.cpp +# +# # Update all C++ files using find -exec +# find src \( -name "*.cpp" -o -name "*.hpp" \) -exec ./update_copyright.sh {} \; +# +# # Dry-run on all C++ files +# find src \( -name "*.cpp" -o -name "*.hpp" \) -exec ./update_copyright.sh --dry-run {} \; + +set -e + +# Check for dry-run flag +DRY_RUN=false +FILE="" + +if [ "$1" = "--dry-run" ]; then + DRY_RUN=true + FILE="$2" +elif [ "$1" = "--help" ] || [ "$1" = "-h" ]; then + grep "^#" "$0" | sed 's/^# \?//' + exit 0 +else + FILE="$1" +fi + +# Check if file argument provided +if [ -z "$FILE" ]; then + echo "Error: No file specified" + echo "Usage: $0 [--dry-run] " + echo "Run '$0 --help' for more information" + exit 1 +fi + +# Check if file exists +if [ ! -f "$FILE" ]; then + echo "Error: File not found: $FILE" + exit 1 +fi + +# Get the repository root +REPO_ROOT=$(git rev-parse --show-toplevel) +cd "$REPO_ROOT" + +# Copyright holder name +COPYRIGHT_HOLDER="Moritz Martinius" + +# Function to get first and last commit years for a file +get_years_for_file() { + local file="$1" + + # Get the year of the first commit that touched this file + first_year=$(git log --follow --format=%ad --date=format:%Y --reverse "$file" 2>/dev/null | head -1) + + # Get the year of the last commit that touched this file + last_year=$(git log --follow --format=%ad --date=format:%Y -1 "$file" 2>/dev/null) + + # If file is not in git, use current year + if [ -z "$first_year" ]; then + first_year=$(date +%Y) + last_year=$(date +%Y) + fi + + echo "$first_year $last_year" +} + +# Get years from git history +read -r first_year last_year <<< "$(get_years_for_file "$FILE")" + +# Determine the copyright year string +if [ "$first_year" = "$last_year" ]; then + year_string="$first_year" +else + year_string="$first_year-$last_year" +fi + +# Check if file has a copyright notice +if ! grep -q "Copyright (C)" "$FILE"; then + echo "No copyright notice found in $FILE, skipping" + exit 0 +fi + +if [ "$DRY_RUN" = true ]; then + # Just show what would be changed + current_year=$(grep "Copyright (C)" "$FILE" | sed -n 's/.*Copyright (C) \([0-9]\{4\}\(-[0-9]\{4\}\)\?\).*/\1/p' | head -1) + if [ "$current_year" != "$year_string" ]; then + echo "Would update $FILE: $current_year → $year_string" + else + echo "No change needed for $FILE (already $year_string)" + fi +else + # Update the copyright line + # Matches patterns like "Copyright (C) 2023 Moritz Martinius" or "Copyright (C) 2023-2024 Moritz Martinius" + # Handle variable whitespace between year and name + + # Get current year from file for comparison + current_year=$(grep "Copyright (C)" "$FILE" | sed -n 's/.*Copyright (C) \([0-9]\{4\}\(-[0-9]\{4\}\)\?\).*/\1/p' | head -1) + + if [ "$current_year" = "$year_string" ]; then + echo "No changes needed for $FILE (already $year_string)" + else + sed -i "s/Copyright (C) [0-9]\{4\}\(-[0-9]\{4\}\)\? \+$COPYRIGHT_HOLDER/Copyright (C) $year_string $COPYRIGHT_HOLDER/" "$FILE" + echo "✓ Updated $FILE: $current_year → $year_string" + fi +fi